Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have been trying to find how to find what permission level a group (within SPWeb.Groups) has. But it seems like there is no easy way to do this. Any ideas?

I have tried creating SPRoleAssignment and passing the group to get the RoleDefinitionBindings, but it seems like creating a new instance does not help with finding existing permission level.

Using SPWeb.AssociatedOwnerGroup does not give me all the "full permission" groups either.

Any help will be greatly appreciated. Thank you!

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Prints out all the groups for the SPWeb and the group's role names:

using (SPSite site = new SPSite("http://server/sites/sitecollection/"))
{
    using (SPWeb web = site.OpenWeb("test"))
    {
        foreach (SPRoleAssignment roleAssignment in web.RoleAssignments)
        {
            if (roleAssignment.Member is SPGroup)
            {
                Console.WriteLine("Group: " + roleAssignment.Member.Name);
                foreach (SPRoleDefinition roleDefinition in roleAssignment.RoleDefinitionBindings)
                {
                    Console.WriteLine("\t" + roleDefinition.Name);
                }
            }
        }
    }
}
}
share|improve this answer
    
Thank you!! I was creating the SPRoleAssignment and passing the group to it for instantiation - silly me :) Thanks a bunch! –  Tom Apr 17 '12 at 19:36
    
@Tom You're welcome :) –  Kit Menke Apr 17 '12 at 19:37
    
this throws an exception if my user permission level is low can any one tell me how solve this. –  user8284 May 10 '12 at 9:33
    
@thomas Not sure what you're trying to do... you need permission to view the groups? –  Kit Menke May 10 '12 at 19:02
add comment

Your Answer

 
discard

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.