2

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?

2
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())
    {
        result.Add(group.Name);
    }

    return result;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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