Query on finding the members inside a nested group inside Active Directory
Alex Davies
alex at davz.net
Thu Sep 4 17:33:02 CEST 2008
Hi Everyone,
I am trying to query an AD Domain Controller for some information, and i'd
like to do this without having to install the win32 and AD libraries for
Python.
I am using the following code to obtain a list of users inside a group
(test). This works well, but i'd like to be able to add groups that contain
users into the "test" group, and return them too. If I do this, the code
below returns nothing at all - not even the names of the groups in the test
group. Can anyone advise me how to do this?
--
import ldap
ldap.set_option(ldap.OPT_REFERRALS, 0)
l = ldap.initialize("ldap://10.3.x.x")
l.simple_bind_s('alexd at XXX.LOCAL', 'xxx')
baseDN = "OU=Location, DC=xxx, DC=local"
searchScope = ldap.SCOPE_SUBTREE
retrieveAttributes = ['sn'] # Surename
searchFilter = "(memberOf=CN=test,OU=Machines,OU=Linux
Auth,DC=xxx,DC=local)"
try:
ldap_result_id = l.search(baseDN, searchScope, searchFilter,
retrieveAttributes)
result_set = []
while 1:
result_type, result_data = l.result(ldap_result_id, 0)
if (result_data == []):
break
else:
if result_type == ldap.RES_SEARCH_ENTRY:
print result_set
except ldap.LDAPError, e:
print e
--
Any help gratefully received.
Many thanks for your time!
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20080904/58e606fb/attachment.html>
More information about the python-ldap
mailing list