Click here to Skip to main content
15,885,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have five groups (UserGrp1, UserGrp2, UserGrp3, UserGrp4, UserGrp5). The five groups total together have over 1000 users. I am currently using the statement below to find one user. For instance, I have the domain user named John Doe (sAMAcountName = JDOE)and I need to find the groups to which he belong. I do not have the Domain, DefaultOU, DefaultRootOU, ServiceUser or ServicePassword. How can I write the code find this person and know what group he actually belong with in these five groups.

GroupPrincipal gp1 = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name,
UserGrp1);

GroupPrincipal gp2 = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name,
UserGrp2);

GroupPrincipal gp3 = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name,
UserGrp3);

GroupPrincipal gp4 = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name,
UserGrp4);

GroupPrincipal gp5 = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name,
UserGrp5);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900