i have a c# function that gives me all of domain group's name :
public static List<String> ListAllDomainGroups()
{
List<String> groups = new List<string>();
// create your domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// define a "query-by-example" principal - here, we search for a GroupPrincipal
GroupPrincipal qbeGroup = new GroupPrincipal(ctx);
// create your principal searcher passing in the QBE principal
PrincipalSearcher srch = new PrincipalSearcher(qbeGroup);
// find all matches
foreach (var found in srch.FindAll())
{
// do whatever here - "found" is of type "Principal" - it could be user, group, computer.....
//listBox2.Items.Add(found.ToString());
groups.Add(found.ToString());
}
return groups;
}
function returns about 70 names including :
WinRMRemoteWMIUsers_
Administrators
Users
Guest
Print Operations
Backup Operators
Replicator
IIS_IUSRS
Remote Desktop Users
... ...
(then groups i defined)
how can i get only the groups that i have defined in my AD and not the built-in groups ?