Zoek
USING POWERSHELL TO ADD CLAIMPRINCIPALS TO SITES AND GROUPS

Microsoft documentation for the SharePoint Powershell only shows how to set the site owner or site collection admin to a claim.

To add a Claim to a SharePoint group you need to perform three steps:

  1. Create the claim.
  2. Create a new group using the new claim.
  3. Add the new user to the group.

Create the claim

Example for the default SharePoint IP/STS:

$principal = New-SPClaimsPrincipal "<contoso\jane>" -IdentityType WindowsSamAccountName

Example for an external STS (like ADFS):

$prov = Get-SPClaimProviderManager
$tti = Get-SPTrustedIdentityTokenIssuer -Identity "ADFS20"
$principal = New-SPClaimsPrincipal -ClaimValue $strippedLogin -ClaimType "http://schemas.microsoft.com/ws/2008/06/identity/claims/role" -TrustedIdentityTokenIssuer $tti

Or an Identity claim:

$principal = New-SPClaimsPrincipal  -ClaimValue $theUser.Email  -ClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IdentifierClaim -TrustedIdentityTokenIssuer $tti

Create the user

$newUsr = New-SPUser -UserAlias $usrEncodedClaim -Web $theGroup.ParentWeb

You can set additional properties for the user object using the -Email and -DisplayName switches.
Now you should be able to add it to a group using the -Group switch, but somehow that does not work. Ik you find out how to to this: please let me know. 

Add the user to the group

 $web = Get-SPWeb -Identity "http://www.test.nl"   
$group = $web.SiteGroups( "Visitors")
$group.AddUser($newUsr)

Er zijn nog geen commentaren voor dit bericht.
Voor items in deze lijst moet de inhoud worden goedgekeurd. De ingediende gegevens worden pas weergegeven in openbare weergaven als deze zijn goedgekeurd door iemand met de vereiste machtigingen.
Titel * 
Opmerking * 
 
Microsoft Partner - Gold competence Portals and Collaboration
Microsoft Partner - Gold competence Systems Management
© COPYRIGHT ADVANTIVE 2010 | LEGAL NOTICE