From a65293114a1adbb45d047a8f9014a307ec0d9051 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 12 Jan 2018 09:10:27 +0000 Subject: [PATCH] Add ParseScope function --- ldap/parse.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ldap/parse.go diff --git a/ldap/parse.go b/ldap/parse.go new file mode 100644 index 0000000..22a285c --- /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) + } +} -- GitLab