SharePoint: The user does not exist or is not unique (FBA)


We faced this error during the last days and couldn’t find (quickly) a solution for it. The solution in our case was very simple and stupid 🙂

Most of the time, getting this errors will result in a long search on the internet finding out that you are not the only one with that error message (sometimes it is the case :-)) The message itself is very general and can occor in lots of different configurations (so not only SharePoint). I will first elaborate on our configuration and the things we checked and then finally mention the cause of our problem…

The error occured on the moment we wanted that add a new extranet user (FBA-user) to SharePoint via the SPWeb.EnsureUser() method. Adding Active Directory-accounts was not a problem! And last but not least, the code worked in the past and on the same systems!

Our setup and configuration:

  • a SharePoint 2010 Server intranet + extended extranet.
  • all web.config’s were nicely checked (3 in total: Intranet, Extranet, SecurityToken)
    • a custom MembershipProvider was created en in-place(partially re-use of code from other projects).
    • We checked that the name of that provider was not misspelled in all config files and code blocks)
  • the superuseraccount and superreaderacount was defined (keeping in mind that you use the claims-prefix (“i:0#.w|domain\account”)
    • this setting is actually not required for the actually solution. We have an environment without these settings and everything was working well…

 

Cause:

  • When using the SPWeb.EnsureUser() method, SharePoint is loading your Membershipprovider assembly and executes the GetUser() methods. Since the user was not present in our internal user database, SharePoint throwed that exception.
  • But why did it worked in the past? => the responsible code of creating the records in the DB was moved by mistake and put after the SPWeb.EnsureUser() statement.

Afterwards it’s easy to say: look at the message! “I cannot  find a user!” but in a lot of case error messages are not always straight-forward and the cause is often something else…but not in this case 🙂 …so exceptions on exceptions do occur.

Advertisements
This entry was posted in Sharepoint and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s