mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Update LDAP search operation
This commit is contained in:
parent
183ed78dc4
commit
447748175e
1 changed files with 15 additions and 15 deletions
|
@ -73,16 +73,18 @@ class Authenticator(BaseAuthenticator):
|
||||||
# TODO: Review these methods
|
# TODO: Review these methods
|
||||||
|
|
||||||
def search(self, base=None, filter='(objectClass=*)', attrs=['dn']):
|
def search(self, base=None, filter='(objectClass=*)', attrs=['dn']):
|
||||||
"""
|
"""Search in LDAP base
|
||||||
Search in LDAP base
|
|
||||||
|
Perform an LDAP search operation with given arguments and return
|
||||||
|
results as a list.
|
||||||
|
|
||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
base -- Base to search into
|
- base -- The dn to search into
|
||||||
filter -- LDAP filter
|
- filter -- A string representation of the filter to apply
|
||||||
attrs -- Array of attributes to fetch
|
- attrs -- A list of attributes to fetch
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Boolean | Dict
|
A list of all results
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not base:
|
if not base:
|
||||||
|
@ -93,16 +95,14 @@ class Authenticator(BaseAuthenticator):
|
||||||
except:
|
except:
|
||||||
raise MoulinetteError(169, _('An error occured during LDAP search'))
|
raise MoulinetteError(169, _('An error occured during LDAP search'))
|
||||||
|
|
||||||
if result:
|
result_list = []
|
||||||
result_list = []
|
if not attrs or 'dn' not in attrs:
|
||||||
for dn, entry in result:
|
result_list = [entry for dn, entry in result]
|
||||||
if attrs != None:
|
|
||||||
if 'dn' in attrs:
|
|
||||||
entry['dn'] = [dn]
|
|
||||||
result_list.append(entry)
|
|
||||||
return result_list
|
|
||||||
else:
|
else:
|
||||||
return False
|
for dn, entry in result:
|
||||||
|
entry['dn'] = [dn]
|
||||||
|
result_list.append(entry)
|
||||||
|
return result_list
|
||||||
|
|
||||||
def add(self, rdn, attr_dict):
|
def add(self, rdn, attr_dict):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue