Skip to content

Commit

Permalink
added methods read_rootdse_s() and get_naming_contexts()
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Jul 24, 2016
1 parent 7d1a375 commit 0169316
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Lib/
* LDAPObject.unbind_ext() now removes class attribute
LDAPObject._l to completely invalidate C wrapper object
* LDAPObject.unbind_ext() now flushes trace file
* ldap.ldapobject.SimpleLDAPObject:
added convenience methods read_rootdse_s() and get_naming_contexts()
* added functions ldap.strf_secs() and ldap.strp_secs()
* added function ldap.filter.time_span_filter()
* Refactored ldif.LDIFParser
Expand Down Expand Up @@ -1270,4 +1272,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.385 2016/07/24 16:05:28 stroeder Exp $
$Id: CHANGES,v 1.386 2016/07/24 16:24:44 stroeder Exp $
22 changes: 21 additions & 1 deletion Lib/ldap/ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
\$Id: ldapobject.py,v 1.155 2016/07/17 14:49:22 stroeder Exp $
\$Id: ldapobject.py,v 1.156 2016/07/24 16:22:32 stroeder Exp $
Compability:
- Tested with Python 2.0+ but should work with Python 1.5.x
Expand Down Expand Up @@ -745,6 +745,26 @@ def find_unique_entry(self,base,scope=ldap.SCOPE_SUBTREE,filterstr='(objectClass
raise NO_UNIQUE_ENTRY('No or non-unique search result for %s' % (repr(filterstr)))
return r[0]

def read_rootdse_s(self, filterstr='(objectClass=*)', attrlist=None):
"""
convenience wrapper around read_s() for reading rootDSE
"""
ldap_rootdse = self.read_s(
'',
filterstr=filterstr,
attrlist=attrlist or ['*', '+'],
)
return ldap_rootdse # read_rootdse_s()

def get_naming_contexts(self):
"""
returns all attribute values of namingContexts in rootDSE
if namingContexts is not present (not readable) then empty list is returned
"""
return self.read_rootdse_s(
attrlist=['namingContexts']
).get('namingContexts', [])


class NonblockingLDAPObject(SimpleLDAPObject):

Expand Down

0 comments on commit 0169316

Please sign in to comment.