So my problem is this:

I have created a Sharepoint Group and added a New User, which in fact is an Active Directory Group. Now I loggin using an account from this Active Directory Group. I need this user active directory group name, in code? How can I grab it?

1 Answer 1

public List<String> GetADGroups()
    List<String> result = new List<String>();

    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, ServerName, UserName, Password);
    GroupPrincipal findAllGroups = new GroupPrincipal(ctx, "*");
    PrincipalSearcher ps = new PrincipalSearcher(findAllGroups);
    foreach (Principal group in ps.FindAll())

    return result;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.