Take the 2-minute tour ×

I have backup-restored a site collection. In the new site collection we use Claims based authentcation.

Now it looks like all the users from the old web is also restored on the new site (which probably is a 'feature', not a bug).

The problem is that in the new site/farm, the users exists but with claims based accounts, so the usernames will have i:0#.w| in front of the username.

What's a bigger issue is that SharePoint now creates two user objects in the site, one with username like DOMAIN\Username, and one with i:0#.w|DOMAIN\Username. Because of this, the users will have different ids in the same site.

So I have a list with a user lookup field. When I issue a CAML Query on this list based on the current user, I could get no results if the id for the user in the list is not the same as for the current user.

How can I fix this? Remove all users which doesn't use claims auth from the site through powershell?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

I ended up removing all the non-claims users in the new site, and replaced references to the old user with the new user where applicable.

I created this PS-function to remove all non claims users from the rootweb (since webs inherit users by default)

function RemoveOldUsers([Microsoft.SharePoint.SPWeb]$web) 
    $oldUsers = @()

    $web.AllUsers | ? {!$_.UserLogin.Contains("i:0#.w") -and !$_.UserLogin.Contains("SHAREPOINT") -and !$_.UserLogin.Contains("NT AUTHORITY")} | % {$oldUsers += $_.UserLogin}

    $oldUsers | % {
        $loginName = $_
        $user = $web.SiteUsers | ? {$_.UserLogin -eq $loginName}
        Write-host Removing $user from the web $web.Url -NoNewLine
        Write-Host Removed.
share|improve this answer
add comment

Try running the MigrateUsers() command on the web application to convert windows account references to claims.

Add-PSSnapin Microsoft.SharePoint.PowerShell 
$webApp = Get-SPWebApplication 'http://site'
share|improve this answer
I'm afraid it didn't do any difference –  tarjeieo May 23 '11 at 6:54
add comment

Your Answer


