diff --git a/LdapServer.py b/LdapServer.py index 169c817..b32b859 100644 --- a/LdapServer.py +++ b/LdapServer.py @@ -50,8 +50,17 @@ class LdapServer(object): return False return True - def search(self,basedn,filter,attrs,sizelimit=0): - res_id = self.con.search(basedn,ldap.SCOPE_SUBTREE,filter,attrs) + def get_scope(self, scope): + if scope == 'base': + return ldap.SCOPE_BASE + elif scope == 'one': + return ldap.SCOPE_ONELEVEL + elif scope == 'sub': + return ldap.SCOPE_SUBTREE + raise Exception("Unknown LDAP scope '%s'" % scope) + + def search(self, basedn, filterstr, attrs, sizelimit=0, scope='sub'): + res_id = self.con.search(basedn, self.get_scope(scope), filterstr, attrs) ret = {} c=0 while 1: