KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to get the list of groups which the user is in. This is my code: PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "mydomain.ac.uk", "DC=mydomain,DC=AC,DC=UK", "user", "password"); UserPrincipal user = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, "MyUser"); PrincipalSearchResult<Principal> results = user.GetGroups(); foreach(Principal p in results) { Response.Write(p.Name); } When I run, I got the following error at the line Response.Write(p.Name); System.Runtime.InteropServices.COMException: The specified directory service attribute or value does not exist. When I checked the count of the results, it returned 9 and the first group is DomainUsers . How can I iterate all 9 groups in the list? Thanks. The following is the list of users I get:
Tags (comma-separated)
Save Edits
Cancel