aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/util.go b/util.go
index d778bc2..96bb00b 100644
--- a/util.go
+++ b/util.go
@@ -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,
@@ -138,3 +154,11 @@ func genUuid() string {
}
return uuid.String()
}
+
+func valueMatch(attr, val1, val2 string) bool {
+ if strings.EqualFold(attr, ATTR_USERPASSWORD) {
+ return val1 == val2
+ } else {
+ return strings.EqualFold(val1, val2)
+ }
+}