Skip to content

Commit

Permalink
Return empty search result list when an LDAP error occurs.
Browse files Browse the repository at this point in the history
Fixes issue conestack#50.
  • Loading branch information
mauritsvanrees committed Sep 6, 2019
1 parent fdc39be commit 8bad15e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ History
1.0b11 (unreleased)
-------------------

- Return empty search result list when an LDAP error occurs.
Fixes `issue #50 <https://github.com/bluedynamics/node.ext.ldap/issues/50>`_.
[maurits]

- Skip objects that were found in LDAP while searching on several attributes but don't contain the required attribute.
[fredvd, maurits]

Expand Down
20 changes: 12 additions & 8 deletions src/node/ext/ldap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,18 @@ def _search(baseDN, scope, queryFilter,
# in case we do pagination of results
if type(attrlist) in (list, tuple):
attrlist = [str(_) for _ in attrlist]
msgid = self._con.search_ext(
baseDN,
scope,
queryFilter,
attrlist,
attrsonly,
serverctrls=serverctrls
)
try:
msgid = self._con.search_ext(
baseDN,
scope,
queryFilter,
attrlist,
attrsonly,
serverctrls=serverctrls
)
except ldap.LDAPError as e:
logger.warn(str(e))
return []
rtype, results, rmsgid, rctrls = self._con.result3(msgid)
ctype = ldap.controls.libldap.SimplePagedResultsControl.controlType
pctrls = [c for c in rctrls if c.controlType == ctype]
Expand Down

0 comments on commit 8bad15e

Please sign in to comment.