If I have a sub site URL and a user with Site Admin, can I list all users in that sub site that have Full Control at that level?
Any C# code sample?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityUse the following C# code:
using(SPWeb web = SPSite(webUrl).OpenWeb())
{
SPRoleDefinitionCollection roleDefinitions = web.RoleDefinitions;
SPRoleDefinition roleDefinition = roleDefinitions["Full Control"];
foreach (SPRoleAssignment roleAssigment in web.RoleAssignments)
{
if (roleAssigment.RoleDefinitionBindings.Contains(roleDefinition))
{
SPPrincipal oPrincipal = roleAssigment.Member;//it can be SPUser or SPGroup, you can process and add it to the result
}
}
}
OR you can use:
bool userhasPermissions = web.DoesUserHavePermissions(user.LoginName, SPBasePermissions.FullMask);
For getting in Powershell use: