I have implemented FBA (Claim based Authentication) on Sharepoint 2010. Following are implemented.
But now the code throws as exception saying "The function is not implemented". I am wondering; I am not using any custom database for which I had to create a Custom Membership Provider. Then why I am getting this error. Let me know if anyone has any clue or faced similar problem. Thanks.
Regards,
Paddy
When FBA is configured for SharePoint 2010, two membership providers are defined in the web.config
file - Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider
(usually named i) and System.Web.Security.SqlMembershipProvider
(named FBAMembership in this case). Default membership provider must be set to the former (i.e. SharePoint claims one) in order for FBA authentication to work properly.
When the line containing Membership.GetUserNameByEmail(...)
is executed, the default membership provider is used and as a result SPClaimsAuthMembershipProvider.GetUserNameByEmail
is called. MSDN says that this method is reserved for internal use and is not intended to be used directly from your code and according to the comment in the Community Content section it throws NotImplementedException
.
You need to retrieve an instance of the SqlMembershipProvider
provider from the Membership.Providers
collection and then call the GetUserNameByEmail
method using this instance.
I use prefixes when configuring providers in the web.config
file and the retrieve them like this:
string applicationNamePrefix = "fbaProvider_";
MembershipProvider fbaProvider;
foreach (MembershipProvider provider in Membership.Providers)
{
if (provider.ApplicationName.StartsWith(applicationNamePrefix, StringComparison.InvariantCultureIgnoreCase))
{
fbaProvider = provider;
}
}
throw new InvalidOperationException("Appropriate provider was not found.");