I have been struggling to find a good way to query out the members of a specified AD Group.
I have no issues in finding the group, or even querying users based on criteria.
currently I have
PrincipalContext context = new PrincipalContext(ContextType.Domain, _domain, ADServerUser, ADServerPassword);
UserPrincipal userPrinciple = new UserPrincipal(context);
userPrinciple.GivenName = "stringToSearchForFirstName";
userPrinciple.Name = "stringToSearchForUserName";
userPrinciple.Surname = "stringToSearchForLastName";
PrincipalSearcher srch = new PrincipalSearcher(new UserPrincipal(context));
srch.QueryFilter = userPrinciple;
var result = srch.FindAll();
This give me all the users that I want, however it doesn't filter the group down.
I can use the GroupPrinciple Object along with the principal search, but then I can't filter down the Users.
I kind of want a way to be able to apply both a UserPrincipal and GroupPrincipal to filter the returned results by BOTH Group and User parameters.
I've used a linq where clause to try and do a match to see if the user is in a group but when i get all users the query times out. makes sense over all.
However if i query out the group, I have no way of using the principalSearcher to apply the query.
Any ideas on how to do this?
pFirstName, pUserName, pLastName and context
– MethodMan