January 12, 2012

Switching from Claims to Not Claims with SharePoint 2010

Working with a client the other day, I had the need to take a web application from one SP install to another. Normally, no big deal. This time, however, client has two different kinds of environments. One was using claims mode. The other wasn’t. In this instance, we needed a short a sweet script that could ‘migrate’ the users to non claims. There is actually a method here that is supposed to do this at SPWebApplication.MigrateUsers. Right there in the docs – set to false to move users from claims to regular. Problem – reflect into that method: if false, throw error. Nice. Here’s an alternative using PowerShell:

$webApp =
$farm = get-SPFarm
$wa = get-SPWebApplication $webApp
$site = get-SPSite $webApp
$web = $site.OpenWeb()
foreach ($user in $web.AllUsers) {
$newuser = $user
$newuserLoginName = “”
if ($newuser.LoginName.StartsWith(“i:0#.w|”))
! $newuserLoginName = $user.LoginName.Substring(7)
$user = $newuser
$farm.MigrateUserAccount($user.LoginName, $newuserLoginName, $false)

Modified from SharePointEgg. Neat!