Thursday, May 5, 2011

Forms Based Authentication for sharepoint 2010 step by step and Creating new ASP.NET users from sharepoint site

OK it is very easy to be able to have a Form Based Authentication site in sharepoint 2010 following those steps in that link http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/

Another link that i find helpful was http://msdn.microsoft.com/en-us/library/bb975136(v=office.12).aspx

But I'm not writing down this blog for those steps mainly I wanted to be able to create new ASP.NET membership users using my custom webpart.

so what is our mission:
1. Configure SQL for membership store
  • Create database
  • Create SQL User
  • Add SQL user to database
2. Configure Central Admin to use SQL membership store
3. Configure Secure Store Web Service to use SQL membership store
4. Create new Web Application for extranet site
5. Configure Extranet site to use SQL membership store

those steps are explained on the first link.

6. Configure Our site to enable anomynos access.
7. Create a new Sign Up WebPart.

Lets begin:
6. Configure Our site to enable anomynos access.

1- First you need to open up your Central Administration page
2- Under Application Management section click Manage Web Application and then you will find on your Ribbon Anonymous Policy click it and then choose any permission level you want but not the none choice
3- if you found that this option is disabled so you need to go to the security page on your central admin and then find under the General Security section
Specify authentication providers link click it and insure that your web application you created previously is selected , click default and then check the Enable anonymous access checkbox , and  then do step no. 2.
4- Now Open your recently created web Application (for example http://win-1eppeqik472:500/ )
5- Go to Site Actions -> Site Permissions on your ribbon you will find Anonymous Access click it and then choose entire site (Just for Example).

7. Create a new Sign Up WebPart.
OK now we want to be able to sign up to this site:

OK lets see the final Result "That helps very much"




Successfully Crearted a user (NewUser)


Sign in Page
so you don't say there is somthing sniky right there





Now how is this done :

First of all my MembershipProvider is FBAMembershipProvider
so I'll get an instance of that provider and create a user by it:


using System.Web.Security;
MembershipCreateStatus Status;

MembershipProvider FBAProvider = Membership.Providers["FBAMembershipProvider"];
MembershipUser NewUser = FBAProvider.CreateUser(this.txtUserName.Text, txtPassword.Text, txtEMail.Text, txtQuestion.Text, txtAnswer.Text, true, (object)Guid.NewGuid(), out Status);
new LiteralControl();
if (NewUser == null)
string Msg = GetErrorMessage(Status);"<h3>" + Msg + "</h3>";
else{
LtrCtr.Text =
LtrCtr.Text +=
ReIntializeControls();
}
"<h3>Congratulations Your New Login Name is : " + NewUser.UserName + " , Thank you for Signing Up</h3>";"<h3>You can now sign in by clicking the sign in link in the upper right of your screen</h3>";


LtrCtr =

{

LtrCtr.Text =
}
 



No comments:

Post a Comment