Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

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;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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