Professional Documents
Culture Documents
Create Database
To create database, Microsoft has provided a tool/utility called aspnet_regsql.exe that
creates a database for us. This utility can be found in %windir
%\Microsoft.NET\Framework\v2.0.50727 folder. Please see the image below:
Executing aspnet_regsql.exe file will open ASP.Net SQL Setup wizard that will walk through
creating the ASP.Net 2.0 database. I have added the database name as SPSFormAuth and
configured it for windows authentication. Please see the image below:
Click on Next button. Please see the image below:
Select Configure SQL Server for application services option and click Next button.
Please see the image below:
It will show the summary screen and click the Next button. Please see the image below:
Click Next button. Now the database SPSFormAuth is created successfully. Please see the
image below:
Configure Membership and Role Providers
In the previous section, database is created successfully. Now we need to add a user in to
database. Using ASP.Net Configuration Wizard, users can be added the database. This can
be achieved by creating web site that will allow us to add the users and roles and also
ensure the database connection strings, membership and role providers are correctly
configured before we bring SharePoint in to equation.
Below steps explains creating web site and configuring membership and role providers and
executing ASP.Net Configuration Wizard.
1) Open Visual Studio 2005 and select File New Web Site. In the New Web Site
dialog, select the ASP.Net Web Site template and enter the location to store the web
site files. Please see the image below:
2) Add a new web.config file to web site project. Please see the image below:
3) By default, you will see a <connectionStrings/> node within <configuration> node.
Specify the connection string to the database which has been created in the previous
section. Please use the example given below:
<connectionStrings>
<add name="FBA_SqlConnectionString" connectionString="Data
Source=MOSS2007\OFFICESERVERS;Integrated Security=SSPI;Initial
Catalog=SPSFormAuth;" />
</connectionStrings>
4) After setting up the connection string, we need to specify the membership and role
providers in the web.config file. In this article, I am using ASP.Net SQL Membership and
Role providers. So specify the provider's information within the <system.web> tag.
Please use the example given below:
<membership defaultProvider="FBA_MembershipProvider">
<providers>
<add connectionStringName="FBA_SqlConnectionString" applicationName="/"
enablePasswordRetrieval="false" enablePasswordReset="true"
requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10"
name="FBA_MembershipProvider"
type="System.Web.Security.SqlMembershipProvider" />
</providers>
</membership>
<!-- Role Provider -->
5) Save web.config file and launch the ASP.Net Configuration Wizard by clicking
on Website ASP.Net Configuration. Please see the image below:
6) Set the authentication type in the above wizard. To do this, click Security link. In
the Security tab, under Users section, click Select authentication type link.
Select From the internet option and press Done button which is available in the
bottom right corner. By selecting this option, which means that site will use form
authentication to identify users. Please see the image below
7) To test the membership and role providers, click on Provider tab. In the Provider tab,
click on Select a different provider for each feature (advanced) link. Select right /
correct membership and role provider and click Test link to ensure that providers are
communicating to right database.
At this point, we configured web.config file with connection string and providers
information. Also we tested the providers with the database. Next section will explain
adding users to database.
Create a User
1) To add users, click on Security tab. In Security tab, under Users section, click Create
user link. Here I am adding user as testFBA and password as password which will be
used for testing form authentication later. Please see the image below:
This section explains extend our web application to another internet site which has been
created in the previous sections. This site is for anonymous or internet users.
Open the browser and test both the site by typing the URL. But these two sites are asking
about windows authentication because these sites are not yet configured to form
authentication.
Below section explains configuration of web.config file of each site with connection string
and providers information.
1) Open the web.config file and follow the same step specified in the Section 4.1
2) Here we need to very careful while specifying defaultProvider information for Role
Provider. In the Role Manager attribute, add AspNetWindowsTokenRoleProvider as
defaultProvider. This is necessary because Central Administration still uses Windows
Authentication for the role provider. Please see the image below:
3) Save the web.config file.