SharePoint 2013: Adding user permissions to specific lists
The intranet I am working on requires limited access to certain document libraries. This is easy enough - as I make my way through my configuration file in PowerShell, I gave the required users access to the document libraries they could see.
The only problem is that the users did not have access to the root site, so the sub site did not appear in the Navigation Bar. I tried adding 'View Only' permissions at the end, but that undid all my good work.
The solution was a change of approach; give the users access to the site and remove access from the items they should not see.
Its always helpful to sharpen the saw.
$list = $web.Lists["MyList"]
$web.AllowUnsafeUpdates = $true
if ($list.HasUniqueRoleAssignments -eq $false)
{
$list.BreakRoleInheritance($true)
}
$user = $web.EnsureUser("Domain\user")
$list.RoleAssignments.Remove($user)
$list.Update()
$web.AllowUnsafeUpdates = $false
$web.Update()
$web.Dispose()
The only problem is that the users did not have access to the root site, so the sub site did not appear in the Navigation Bar. I tried adding 'View Only' permissions at the end, but that undid all my good work.
The solution was a change of approach; give the users access to the site and remove access from the items they should not see.
Its always helpful to sharpen the saw.
$list = $web.Lists["MyList"]
$web.AllowUnsafeUpdates = $true
if ($list.HasUniqueRoleAssignments -eq $false)
{
$list.BreakRoleInheritance($true)
}
$user = $web.EnsureUser("Domain\user")
$list.RoleAssignments.Remove($user)
$list.Update()
$web.AllowUnsafeUpdates = $false
$web.Update()
$web.Dispose()
Comments
Post a Comment