aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-02 13:51:47 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-02 13:53:29 +0100
commit0c801e02d5b9804c5444d4e923babc34ee05b61c (patch)
treecb1bcfe3b792614dd9b28ed0c30ae3de1b1d5f72 /util.go
parent4c037dcb94d2c663da9e624ba44dac0f833bc804 (diff)
downloadbottin-0c801e02d5b9804c5444d4e923babc34ee05b61c.tar.gz
bottin-0c801e02d5b9804c5444d4e923babc34ee05b61c.zip
Remove spaces between dn components, use warnings when necessary
Diffstat (limited to 'util.go')
-rw-r--r--util.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/util.go b/util.go
index 4add5ee..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,