SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.