aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go31
1 files changed, 22 insertions, 9 deletions
diff --git a/util.go b/util.go
index 96bb00b..95ad102 100644
--- a/util.go
+++ b/util.go
@@ -98,19 +98,14 @@ func parseDN(dn string) ([]DNComponent, error) {
return nil, fmt.Errorf("Wrong DN component: %s (expected type=value)", rdn)
}
ret = append(ret, DNComponent{
- Type: strings.TrimSpace(splits[0]),
- Value: strings.TrimSpace(splits[1]),
+ Type: strings.ToLower(strings.TrimSpace(splits[0])),
+ Value: strings.ToLower(strings.TrimSpace(splits[1])),
})
}
return ret, nil
}
-func canonicalDN(dn string) (string, error) {
- path, err := parseDN(dn)
- if err != nil {
- return "", err
- }
-
+func unparseDN(path []DNComponent) string {
ret := ""
for _, c := range path {
if ret != "" {
@@ -118,7 +113,16 @@ func canonicalDN(dn string) (string, error) {
}
ret = ret + c.Type + "=" + c.Value
}
- return ret, nil
+ return ret
+}
+
+func canonicalDN(dn string) (string, error) {
+ path, err := parseDN(dn)
+ if err != nil {
+ return "", err
+ }
+
+ return unparseDN(path), nil
}
func checkRestrictedAttr(attr string) error {
@@ -162,3 +166,12 @@ func valueMatch(attr, val1, val2 string) bool {
return strings.EqualFold(val1, val2)
}
}
+
+func listContains(list []string, key string) bool {
+ for _, v := range list {
+ if key == v {
+ return true
+ }
+ }
+ return false
+}