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

My SP web application use FBA authentication (AD and aspnetSQLmembership providers). I want log in to SP site from custom SP login page. In code-behind page (my class inherit FormsSignInPage(ns:Microsoft.SharePoint.IdentityModel.Pages)I wrote

MembershipUserCollection msc = Membership.FindUsersByEmail(someEmailString);
if (msc != null && msc.Count == 1)
{
foreach (MembershipUser user in msc)
{
userName = user.UserName;
}
FormsAuthentication.RedirectFromLoginPage(userName, false);
}

Problem: When debugger come to "MembershipUserCollection msc = Membership.FindUsersByEmail(someEmailString);" it breaks and I get message "Exception Details: System.NotImplementedException: The method or operation is not implemented.". Should I somewhere in code need to specify which membership provider should be used (AD od SQL) or what?!?

Please, any suggestion will be appreciated.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

If you use multiple membershipproviders, check in your web.config which one is the default one (under the <membership> tag). If the SqlMembershipProvider isn't the default one, you could get the provider by using:

MembershipProvider oProv = Membership.Providers["<Providername>"];
oProv.FindUsersByEmail(someEmailString);
//and so on....

I've encountered this problem when using claims-based authentication, the default one was set on the claimsprovider, and if you use reflector to open up the dll that claims use, you'll see that most of the methods aren't implemented.

share|improve this answer
    
Thank you Ruben, i have claims provider setted as default, but when I use above code, i can get user from SqlMsProvider but can't get from default provider. I noticed that SqlMSProvider object has property _Initialized=true but ClaimProvider object has _Initialized=false. Does isn't clear for me because both providers should be active because i should be able to login with AD accounts same as sqlmembership accounts. Any idea? Any suggestion? –  trip Jun 20 '11 at 10:07
add comment

This is probably because you call the abstract class Membership instead of the specific implementation (SqlMembershipProvider).

Try using SqlMembershipProvider.FindUsersByEmail class instead.

share|improve this answer
    
Hi Anders, I managed to get provider in a way like Ruben explained. But i got another problem. –  trip Jun 20 '11 at 10:08
    
Well you should then flag his answer as correct and open a new question then –  Anders Rask Jun 20 '11 at 17:37
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.