Add possibility to specify the scope of an LDAP search
This commit is contained in:
parent
15cb807c2f
commit
9d42fa6c71
1 changed files with 11 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue