diff --git a/ldap/parse.go b/ldap/parse.go new file mode 100644 index 0000000000000000000000000000000000000000..22a285c6c6d4f82694106852293f93f97a0b1f91 --- /dev/null +++ b/ldap/parse.go @@ -0,0 +1,20 @@ +package ldaputil + +import ( + "fmt" + + "gopkg.in/ldap.v2" +) + +func ParseScope(s string) (int, error) { + switch s { + case "base": + return ldap.ScopeBaseObject, nil + case "one": + return ldap.ScopeSingleLevel, nil + case "sub": + return ldap.ScopeWholeSubtree, nil + default: + return 0, fmt.Errorf("unknown LDAP scope '%s'", s) + } +}