I have a SPUser and I want to get all the user groups in which the SPUser exists. How can i get all the SPGroups containing the SPUser programatically?. Sample codes and useful links would be very helpful. Thanks.

2 Answers 2


Do something like this..(I have not tested..pls debug and test)

List<string> lstgroup=new List<string>();

 SPGroupCollection groupCollection = web.Groups;
        foreach (SPGroup grp in groupCollection)
            if (grp.ContainsCurrentUser)

SPUser.Groups returns a collection of SPGroups which the user is a member. Here is the documentation link

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.