Thus, the crazy hyper magic number involved in a recursive search is explained in the search filter syntax .
To find in one search (recursively) all groups in which "user1" is a member:
- Install the base in the group container DN; e.g. root of DN (dc = dom, dc = fr)
- Set Subtree Area
- Use the following filter:
(member:1.2.840.113556.1.4.1941:=cn=user1,cn=users,DC=x)
using LDIFDE.EXE, the command line tool included with Windows Server gives:
ldifde -f user1Grps.ldf -d "dc=societe,dc=local" -r "(member:1.2.840.113556.1.4.1941:=cn=user1,ou=Monou,dc=societe,dc=local)"
If you are running this on a W2K8 or W2K8 R2 server, be careful with administrative privileges.
If you are programming in C #, you can use:
Console.WriteLine("Retreiving a principal context"); PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, "WM2008R2ENT:389", "dc=dom,dc=fr", "jpb", "PWD"); UserPrincipal aUser = UserPrincipal.FindByIdentity(domainContext, "user1"); PrincipalSearchResult<Principal> a = aUser.GetAuthorizationGroups(); foreach (GroupPrincipal gTmp in a) { Console.WriteLine(gTmp.Name); }
source share