Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a Form Based Authentication login name login_name

how to get an SPUser object for that login name.

I have tried the

Web.EnsureUser(string.Format("c:0-.f|role|{0}", name));

but it gives me that the name was not found exception.

share|improve this question
change 'role' for the name of your membership provider. – James Love Jan 5 at 13:27
1  
My comment above will probably resolve your immediate requirement, but I also have a similar requirement for getting an SPUser for a username from a claim that can be from any issuer (forms, windows, trusted IP), so if someone has a more complete answer, I'd be grateful, too :) – James Love Jan 5 at 13:28

1 Answer

Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site.

    SPUser newUser = SPContext.Current.Web.EnsureUser(@"domain\logonname");
share|improve this answer

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.