diff options
Diffstat (limited to 'util.go')
-rw-r--r-- | util.go | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -98,13 +98,29 @@ func parseDN(dn string) ([]DNComponent, error) { return nil, fmt.Errorf("Wrong DN component: %s (expected type=value)", rdn) } ret = append(ret, DNComponent{ - Type: splits[0], - Value: splits[1], + Type: strings.TrimSpace(splits[0]), + Value: strings.TrimSpace(splits[1]), }) } return ret, nil } +func canonicalDN(dn string) (string, error) { + path, err := parseDN(dn) + if err != nil { + return "", err + } + + ret := "" + for _, c := range path { + if ret != "" { + ret = ret + "," + } + ret = ret + c.Type + "=" + c.Value + } + return ret, nil +} + func checkRestrictedAttr(attr string) error { RESTRICTED_ATTRS := []string{ ATTR_MEMBEROF, |