Converting FBA users to SharePoint 2010
With thanks to commenter Anu, I can hereby present a way to convert old FBA users to SharePoint 2010 compatible users when converting a 2007 installation to 2010.
The easy way is a simple Powershell script:
$w = Get-SPWebApplication(“url”)
$w.MigrateUsers(true)
But this script seems to have a hardcoded limit to the number of users it handles. Anu had more then 5k users in his database, which resulted in not all users being converted. When you need to convert more, Anu has provided a Powershell script which will do this:
[System.Reflection.Assembly]::LoadWithPartialName(“System.Web”) | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Administration”) | Out-Null
$spFarm = [Microsoft.SharePoint.Administration.SPfarm]::Local
$site = New-Object Microsoft.SharePoint.SPSite(“yoursitename”);
$site.RootWeb.SiteUsers | ForEach-Object {
$name = $_.LoginName
#Write-Host $name
if($name.StartsWith(“providername:”))
{ Write-Host $name
$newName = $name.Replace(“providername:”, “i:0#.f|providername|”)
Write-Host $newName
$spFarm.MigrateUserAccount($name, $newName, $False)
Write-Host “Migrated User:”
}
}
$site.Dispose()
This script uses the MigrateUserAccount command to convert a single user, and loops through all users which have not yet been converted. You can tell by the format of the username; old 2007 users will be in the format ´providername:username´, new ones will look like ´i:0#.f|providername|username´.
Again, thanks to Anu for sharing this solution and I hope it´ll help other FBA users!
Leave a Comment