Reputation: 463
In Sharepoint 2010, clicking "Site Actions"--> "Site Permission" --> "Check Permissin"
, you can get permission by user. How can I do the same thing using sharepoint API in c#?
Upvotes: 1
Views: 9294
Reputation: 2167
The method "GetUserEffectivePermissionInfo" server users only. If the permissions need to find a group, just do this:
using (SPSite site = new SPSite("/"))
{
using (SPWeb web = site.OpenWeb())
{
SPGroup spGroupItem = web.Groups["GroupName"];
SPRoleAssignment oRoleAssignment = web.RoleAssignments.GetAssignmentByPrincipal(spGroupItem);
foreach (SPRoleDefinition inRole in oRoleAssignment.RoleDefinitionBindings)
{
//inRole.id //inRole.Name
//1073741829 //limited access
}
}
}
Upvotes: 3
Reputation: 10335
Try SPWeb.GetUserEffectivePermissionInfo
Gets the effective permissions that the specified user has and the role assignments related to this user within this scope.
Upvotes: 2