• 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?

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

2 Answers 2


Are you referencing the custom membership provider?

For example:

  • no. I'll try that!
    – Francois
    Jun 12, 2012 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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