1

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?

1

Use 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:

http://social.technet.microsoft.com/wiki/contents/articles/5884.sharepoint-2010-get-site-users-with-full-controlowners-permissions-with-powershell-script.aspx

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.