def search(self, base, scope=ldap.SCOPE_SUBTREE, ldap_filter='(objectClass=*)', attributes=None,
serverctrls=None):
"""
Perform a low level LDAP search (synchronous) using the given arguments.
:param base: Base DN of the search
:param scope: Scope of the search, default is SCOPE_SUBTREE
:param ldap_filter: ldap filter, default is '(objectClass=*)'
:param attributes: An array of attributes to return, default is ['*']
:param serverctrls: An array server extended controls
:return: a list of tuples (dn, attributes)
"""
if serverctrls is None:
logger.debug("Performing LDAP search: base: {}, scope: {}, filter: {}".format(base, scope, ldap_filter))
return self._server.search_s(base, scope, ldap_filter, attributes)
else:
logger.debug("Performing ext LDAP search: base: {}, scope: {}, filter: {}, serverctrls={}".
format(base,
scope,
ldap_filter,
serverctrls))
return self._server.search_ext_s(base, scope, ldap_filter, attrlist=attributes,
serverctrls=serverctrls)
评论列表
文章目录