Geeks With Blogs

Lance's TextBox

In the last LDAP series post, I mentioned how to search for the members of a group.  Now the opposite, here's how to search for what groups a particular user is a part of:

To do this search, all I do is form a search filter that is searching for all groups that has a particular member in it.  So really this is a slight alteration of the search for all groups.

PS C:\> get-ldap -server testboy -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree 
-search "(&(member=CN=Lance Robinson,CN=Users,DC=JUNGLE)(objectcategory=group))"

Host DN
---- --
testboy CN=Domain Admins,CN=Users,DC=JUNGLE
testboy CN=DnsAdmins,CN=Users,DC=JUNGLE

PS C:\>

Here I can see that I (CN=Lance Robinson,CN=Users,DC=JUNGLE) am a member of two groups:  Domain Admins and DNS Admins.  That sounds a lot cooler than it actually is since "testboy" is just a test machine.  ;)

Technorati Tags: , , ,

Posted on Friday, August 3, 2007 12:51 PM PowerShell | Back to top

Comments on this post: LDAP - Search for What Groups a Particular User Belongs to

# re: LDAP - Search for What Groups a Particular User Belongs to
Requesting Gravatar...

Is it possible that we get all groups that particular user belongs to, for both direct and indirect?

Kindly suggest, please.

Thanks & Regards,
Left by Nidjarin K. on Feb 23, 2010 1:49 AM

Your comment:
 (will show your gravatar)

Copyright © Lance Robinson | Powered by: