Thursday, June 4, 2015

Changing Authentication from Windows to Claim base in SharePoint 2010


# Changing Authentication from Windows to Claim base in SharePoint 2010

$setcba = Get-SPWebApplication "http://s11:91/"
$setcba.UseClaimsAuthentication = 1;
$setcba.Update()



# For Migrating users from Windows authentication to Claim bases 

$WebAppName = “http://adapt-proj-03:1515“

#THIS SHOULD BE THE ACCOUNT THAT IS RUNNING THIS SCRIPT, WHO SHOULD ALSO BE A LOCAL ADMIN
$account = “Adaptindiaone\spadmin”

$wa = get-SPWebApplication $WebAppName

Set-SPwebApplication $wa -AuthenticationProvider (New-SPAuthenticationProvider) -Zone Default
# this will prompt about migration, CLICK YES and continue

#This step will set the admin for the site 
$wa = get-SPWebApplication $WebAppName
$account = (New-SPClaimsPrincipal -identity $account -identitytype 1).ToEncodedString()

#Once the user is added as admin, we need to set the policy so it can have the right access
$zp = $wa.ZonePolicies(“Default”)
$p = $zp.Add($account,”PSPolicy”)
$fc=$wa.PolicyRoles.GetSpecialRole(“FullControl”)
$p.PolicyRoleBindings.Add($fc)
$wa.Update()

#Final step is to trigger the user migration process
$wa = get-SPWebApplication $WebAppName
$wa.MigrateUsers($true)

No comments:

Post a Comment