SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


  • sharepoint 2010
  • custom membership provider
  • custom job to create users

Job is deployed by code and executed first time from some WinForms exe, executed by local Administrator. Users are created using spWeb.EnsureUser(login).

When job is initiated by timer, spWeb.EnsureUser(login) works fine for existing users. But it fails for non existing users in web.

What can be wrong?

share|improve this question
Did you try under an elevated privilege block ? – Steve B Jun 12 '12 at 8:00
yes I tried. May be the custom membership provider is not loaded? – Francois B. Jun 12 '12 at 8:18
when you say "it fails", can you descrive what is the exact behavior (messages, errors, logs, etc.) – Steve B Jun 12 '12 at 8:22
An exception is thrown: User does not exists (I don't have exact message right now) – Francois B. Jun 12 '12 at 8:23
up vote 0 down vote accepted

Are you referencing the custom membership provider?

For example:

share|improve this answer
no. I'll try that! – Francois B. Jun 12 '12 at 9:36

(i:0#.f|admembership|user) This was the correct answer for me. We had a FBA Ldap provider and custom login page working in our SharePoint 2007 enviroment. We upgraded to SharePoint 2010 and had to make to conversion from Windows to Claims based authentication. Claims adds the prefix of i:0#.f|admembership to all our FBA Ldap member usernames, I just had to modify my codebehind to concat that string in front of the username retrieved from the LDAP provider and that did the trick. EnsureUser is now correctly validating and/or adding the usernames.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.