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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def search(self,basedn,filter,attrs,sizelimit=0):
|
def get_scope(self, scope):
|
||||||
res_id = self.con.search(basedn,ldap.SCOPE_SUBTREE,filter,attrs)
|
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 = {}
|
ret = {}
|
||||||
c=0
|
c=0
|
||||||
while 1:
|
while 1:
|
||||||
|
|
Loading…
Reference in a new issue