If anyone knows how to get a list of all the groups to which a particular user belongs to using LDAP query against Active Directory on windows environment, please let me know. Assume that you have the user id available as an only input.
I need this urgently. I don’t care if its ADSI dialect or SQL dialect (i.e. with ADO)
I already have a LDAP query that works and returns ALL the groups without the user id filter.
well, if u have XP u can use the "dsget" query to get the membership:
e.g. "dsget user "CN=FULLNAME,OU=OUNAME,DC=DOMAIN,DC=com" -memberof"
replace OUNAME and DOMAIN, and use the right extension. There's vb scripts that can help you there as well.
In the same series there are other "ds***" apps, e.g. dsquery, dsadd, etc.
I am not aware of any paramaters that would take the other parts out. The other backward way, if you don't wanna do the parsing is to do a 'dsget' or 'dsquery' against all the groups and if that name is present mark that group true or something similar. All depends on where u are running the query from and what you want to accomplish. There is a really good book on Active Directory called the Active Directory Cookbook by O'reilley that covers all kinds of stuff. Let me know if u wanna look thru it ;)
Thanks for your help again. I made progress yesterday, and won’t be back to work until Monday. I still need to write more queries for nested groups and to avoid infinite looping due to recursively nested groups.
When the actual group whose membership we are trying to find is 10 OU levels deep then what exactly do you put for the OU. Do you keep doing ou=something, ou=the next something?
^^ for a general search like if you want to know all the groups in your AD then it should be
something like that..
Examples:
To find all groups in the current domain whose name startswith "ms" and whose description starts with "admin",and display their DNs:
dsquery group domainroot -name ms* -desc admin*
Find all groups in the domain given by dc=microsoft,dc=com
and display their DNs:
dsquery group dc=microsoft,dc=com