After developing and configuring SharePoint to make use of claims-based authentication, you may get involved in deployment of the solution which can involve assignment of permissions to claims. This is easily achieved using the SharePoint people-picker control however doing so using a PowerShell script can be hair-scratching. Here is a sample to save your scalp :-)
$webSiteURL = "<web address>"
$provider = Get-SPClaimProvider -Identity "<provider name>"
$claim = New-SPClaimsPrincipal
-ClaimValue "<claim value>"
-ClaimType "http://<cliam type>"
-ClaimProvider $provider.ClaimProvider
$user = New-SPUser
-UserAlias $claim.ToEncodedString()
-Web $webSiteURL
Set-SPUser
-Identity $user
-Web $webSiteURL
–AddPermissionLevel "Read"
You may need to perform a further step on or after the last step such as adding the user to a role-assignments collection.
Notice that the parameters are placed on new lines for clarity.
You'll have to ensure that the PowerShell instance has the SharePoint plugins enabled.
0 comments:
Post a Comment