Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Background:

  • 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
add comment

2 Answers

up vote 0 down vote accepted

Are you referencing the custom membership provider?

For example:

spWeb.EnsureUser(i:0#.f|admembership|user)
share|improve this answer
    
no. I'll try that! –  Francois B. Jun 12 '12 at 9:36
add comment

(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.

-Thanks!

share|improve this answer
add comment

Your Answer

 
discard

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.