Dear group: My company makes use of Active Directory to determine what rights a given user has in an application system. If the user is a member of a certain group, then (s)he has the right to perform some set of functions. For example, if VCOLE is a member of WCPO-CREATE then I can create new purchase orders.
The method I am using to determine a user's group membership consists of looking at all the members of each target group, and finding whether my user is on that list. Something like the following code snippet: v v v v v v glist = ['A','List',"of","possible",'group','names'] _username = win32api.GetUserName().upper() _LoginServer = win32net.NetGetAnyDCName() if True: # begin snippet groups = set() for g in glist: resume = 0 while True: try: entries, total, resume = \ win32net.NetGroupGetUsers( _LoginServer,g, 0, resume) except KeyboardInterrupt: raise except: print 'Group Name "%s" could not be found' % g break for de in entries: name = de['name'].upper() if name == _username: groups.add(g) if resume == 0: break # end snippet if 'possible' in groups: print 'You can do it.' ^ ^ ^ ^ ^ My question is this: There MUST be some better way. Is there no system call for "Is user U a member of group G"? -- Vernon Cole
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32