Code to find Active Directory based on search criteria (wildcard options).
- var context = new PrincipalContext(ContextType.Domain, "domain");
- var groupPrincipal = new GroupPrincipal(context) { Name = "yourADGroupName*" };
- var principalSearcher = new PrincipalSearcher(groupPrincipal);
- var listOfADGroupNames = principalSearcher.FindAll().OfType<GroupPrincipal>().Select(principal => principal.Name).ToList();
Happy Coding.