I'm trying to create user in SharePoint 2010 using FBA (Forms Based Authentication). I followed the steps in this article to configure FBA: http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/
Then I uploaded the FBA package http://sharepoint2010fba.codeplex.com/. Web part loaded normally, but the user is not created. If you try to create a user it gives an unknown error.
After that I tried to create authorization form by myself. The code below handles the registration event:
MembershipCreateStatus mcs = new MembershipCreateStatus();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://makovkasp:30763/"))
using (SPWeb spWeb = site.OpenWeb())
{
try
{
MembershipUser membershipUser =
Membership.Providers["FBAMembershipProvider"].CreateUser(txtLogin.Text,
txtPassword.Text,
txtEmail.Text,
txtSecretQuestion.Text,
txtAnswer.Text, true, null, out mcs);
spWeb.AllowUnsafeUpdates = true;
SPUser spUser = spWeb.EnsureUser(txtLogin.Text);
SPGroup spGroup = spWeb.Groups[2];
spGroup.AddUser(spUser);
spGroup.Update();
}
catch (Exception ex)
{
System.Console.WriteLine(ex.ToString());
}
}
});
After this code is executed, the user creates in SharePoint (I can see it in FBA UserManagement). But it isn't created in FBA database. So, I can't sign in under it's account. Anyone knows how to do it?
Thanks.
The unknown error when registering a user generally means there was an error sending the email. You can check the SharePoint ULS logs for more details. I would check your SharePoint outgoing mail settings.
If you can see the user in FBA UserManagement - then it has been created in the membership database. Have you checked the aspnetdb database to see if the user exists?
Can you login with another FBA user's account? If not it's likely there's a problem with your FBA setup. Make sure the membership entries are in your STS and Central Admin web configs.