0
votes

I am trying to get users who are members of a particular group in AD.

I am trying with the following filters but i am unsuccessful.

1)

DirectoryEntry entry1 = new DirectoryEntry("LDAP://DC=xxinfo,DC=com");
string query = "(&(objectCategory=person)(objectClass=user)(memberOf=CN=Guests))";

2)

objSearchADAM.Filter = "(&(ObjectClass=user)(memberOf=CN=Network Configuration perators,CN=Builtin,DC=xxxx,DC=xxinfo,DC=com))";

also, is there any way to get users using this approach?

PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "group_name");

this searches the current domain, i want to search the whole forest.is there any way to initialize ctx for whole forest?

any help would be appreciated. thank you.

1

1 Answers

0
votes

Got the answer!! used below code using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "subdomain.domain.comany.com:3268", "DC=comapny,DC=com")) { GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "Group_Name");

port 3268 is used to search in global catalog.