Saturday, July 7, 2007

Moss 2007 Forms authentication

As we know that by default Share point picks the users list from the ActiveDirectory(Windows Authentication). we dont have forms authentication concept in sps3 it was introduced in Moss 2007. To enable forms authentication follow the below steps.

Create aspnetdb database to store all our roles and users. You will find this database installed at 'c:\windows\microsoft.net\framework\v2.0.50727' if you have Visual Studio 2005 installed in your machine. go there and run aspnet_regsql. To Create your roles and membership data on the sql server you need to edit web.config for the site.we need to supply the connection string details for our aspnetdb. Just outside the system.web tag put:




and inside the system.web put the following code










Once you’ve edited both web.config’s go to a command prompt and do an iisreset.
Now we need to add some users to our database. The easiest way to do this is to create an ASP.NET 2.0 website using Visual Studio 2005 (or Visual Web Dev). Add a web.config to the project and then add exactly the same connection string as you did above for your new SharePoint site. Build the project.

Back in Visual Studio, under the website menu, select the option for ASP.NET Configuration. This opens up the ASP.NET web site administration tool where we can add the users and roles we want.
Select the Security link, create a role (something like administrators), and then go and add a user.

Now go to Application Management page in Central Admin and click on Authentication Providers. select the site you wish to change the authentication provider to Forms for. Once you've selected it you'll see Windows as the MemberShipProviderName.
Set the authentication type to Forms and enter the Member Ship Provider Name to AspNetSqlMembershipProvider. If anonymous access isn't ticked, tick that now.
Goto Central Administration -> Application Management -> site collection administrators – and enter the username created by the asp.net application.

Now when you try login into the site will redirect to the login page, where you need to provide the credentials of the user that you have created.

No comments: