Tuesday, July 17, 2012

Change Authentication classic-mode to claims-based authentication

In our environment we are using Claim base authenticating. We have one script that is provided by our Vendor to setup VM for our developers . When we run this script it create out all we application with site collection on desired port. but issue is that they all based on classic authentication and i need to change their authentication type.

To check authentication type

Open Central administrator go to application management and select manage web application.now you need to select web application which one you want to check and from ribbon select Authentication Provider and will prompt a window as below

Authentication type

So you can see this is Windows authenticate.

Now i want to change authentication  so our best friend power shell can help us :)

Perform the steps in the following procedure to convert existing Web applications to claims-based authentication

Open SharePoint management shell(powershell ) as administrator

copy below script and hit enter

$WebAppName = http://XYZ.com here you need to update with url which you want to cahnge
$wa = get-SPWebApplication $WebAppName
$wa.UseClaimsAuthentication = $true
$wa.Update()
Now 
$account = "yourDomain\yourUser" here you need to change from your service account with domain 
$account = (New-SPClaimsPrincipal -identity $account -identitytype 1).ToEncodedString()
$wa = get-SPWebApplication $WebAppName
$zp = $wa.ZonePolicies("Default")
$p = $zp.Add($account,"PSPolicy")
$fc=$wa.PolicyRoles.GetSpecialRole("FullControl")
$p.PolicyRoleBindings.Add($fc)
$wa.Update()
now migrate user
$wa.MigrateUsers($true)

now perform provision

$wa.ProvisionGlobally()
after this when you check authentication as we check above
Claim Authentication type 
Congregate you change the authentication