[python-win32] AD group membership - recursive query
M K
mjukr at forthwith.org
Tue Jun 26 16:10:23 CEST 2007
Hello there,
First let me say that I'm new to both Python and LDAP programming in
general, so you can safely assume that I'm coding somewhat blindly.
What I'm trying to do is build a program against a Microsoft Active
Directory that will find all group memberships for the current user. Because
we have nested groups, it will need to do so recursively.
There is a VBScript that I'm using as a basis:
http://www.microsoft.com/technet/technetmag/issues/2006/03/ScriptingGuy/default.aspx
I wanted to share this before I delve any further to make sure I'm not
making any newbie mistakes. My ultimate goal is to build a List of all these
Groups, and remove any duplicates that may show up.
Here's the current state:
____________________
import active_directory
def nestedlookup (group):
""" does a recursive lookup """
nested_list = group.memberOf
for members in nested_list:
print "DESCENDENT: ", members.cn
nestedlookup(members)
user = active_directory.find_user ()
print "User:", user.cn
group_list = user.memberOf
for group in user.memberOf:
print "PARENT: ", group.cn
nestedlookup(group)
______________________
Many thanks for any advice!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070626/e90db19c/attachment.htm
More information about the Python-win32
mailing list