[Me] filter not working

I have a SharePoint list that I populate everyday using C# code. In short I step through Active Directory to get all active users and then populate a SharePoint list. One of the fields is a Person column and I use the command below to get the user account:

userprofile = userProfileMgr.GetUserProfile(user.UserName);

However when I try and use a list filter with the [Me] property it DOES NOT show my record entry. On further investigation I found the following:

  • When you hold your mouse over the user’s name in the column you see something like this https://[yoursite]/apps/_layouts/15/userdisp.aspx?ID=26
  • When I edit the row and manually add the user through SharePoint I see a different ID

This led me to the UserInfo table for the site’s content database. I queried the table using the to_login field:

SELECT * FROM [Content_DB].[dbo].[UserInfo] where tp_login like ‘%[Account]%’ and tp_IsActive=1 and tp_Deleted=0

If you see more than one account you have found the issue. This can typically be caused by migrations from previous versions or if you have changed Active Directory domains and needed to migrate user accounts.

To fix you need to remove the INVALID accounts. You can determine this by selecting the user via SharePoint as per above until the [Me] filter works. Then you run the following for the other users via SharePoint Management Shell:

$user = Get-SPUser -Identity ‘[tp_login] column’ -Web ‘http://[yoursite]’
Remove-SPUser $user -Web ‘[yoursite]’


Leave a Reply

Your email address will not be published. Required fields are marked *