Category: Membership And Roles

Oct 10 2009

Creating and configuring the application services database for sql server

Asp.net provides many asp.net built-in application services such as membership, roles, profiles, and personalization.

For example, the ASP.NET personalization service uses a personalization provider to save personalized user settings on Web pages.

Each application service uses one provider to persist the service’s data in a particular kind of data store. For each service, a SQL provider is included and configured as the default provider to persist the data in a Microsoft SQL Server database.

Membership API for managing usernames/passwords and secure credential management

Roles API that supports mapping users into logical groups.

Profile API for storing arbitrary properties about both authenticated and anonymous users visiting a web site (for example: their zip code, gender, theme preference, etc).

Personalization API for storing control customization preferences (this is most often used with the WebPart features in ASP.NET 2.0)

Health monitoring API that can track and collect information about the running state and any errors that occur within a web application

Site navigation API for defining hierarchy within an application and constructing navigation UI (menus, treeviews, bread-crumbs) that can be context specific based on where the current incoming user is in the site.

Role Managed Providers

Role management services use the provider model to separate the functionality of role management — the API — from the data store that contains role information. The .NET Framework includes the following providers that maintain role information in different data stores:

  • SQL Server. Role information is stored in a SQL Server database. The SQL provider is suitable for medium to large Internet applications. This is the default provider.
  • Windows (WindowsToken). Role information is based on Windows accounts (users and groups). The Windows provider is useful only if your application runs on a network where all users have domain accounts.
  • Authorization Manager (AzMan). Role information is managed using an Authorization Manager XML file or a directory-based policy store.

create asp.net membership provider database

Step 1: First create Database name “Customer” in sqlserver

create storedProcedures

create storedProcedures

Step2: Then expand Programmability folder in customer database right click in stored procedure then click new stored Procedure…

Enable User Instance:

To enable user instance, execute below 8 command lines one by one in sql server stored procedure editor (explained in step 2 how to open sqlserver stored procedure)  or sql server command prompt

exec sp_configure ’show advanced option’, ‘1′

reconfigure

exec sp_configure ‘xp_cmdshell’, ‘1′

reconfigure

exec sp_configure ‘Ole Automation Procedures’, ‘1′

reconfigure
exec sp_configure ‘user instances enabled’, 1.

reconfigure

Create Membership and Roles tables to DataBase File


Step3: using windows Authentication in sqlserver

Windows Authentication

Windows Authentication

aspnet_regsql.exe -S -E -d -A all

So Enter command for windows Authentication

Start - programs – Microsoft Sql server 2005 – Configuration Tools – Notification Services Command Prompt then type below command

aspnet_regsql.exe -S RAJU -E -d Customer -A all

Sqlserver commandPrompt

Sqlserver commandPrompt

raju is my system name

Note: for some sytems sometimes it look servername (local)\SQLEXpress

Consider my (local) name is DEVELOPER-15\SQLEXpress so write below

aspnet_regsql.exe -S DEVELOPER-15\SQLEXpress -E -d Customer -A all

After executing the command, Then goto Database Customer refresh this database, then u can observe all memberships and roles

Change Web.config file for Windows Authentication when using Login controls in asp.net

<connectionStrings>

<remove name=”myDb“/>

<add name=”myDb

connectionString=”Data Source=DEVELOPER-15\SQLEXPRESS;

Initial Catalog=Customer;

Integrated Security=True”

providerName=”System.Data.SqlClient”/>

connectionStrings>

Note: name=”myDb

<membership defaultProvider=”CustomizedProvider”>

<providers>

<add name=”CustomizedProvider”

type=”System.Web.Security.SqlMembershipProvider”

connectionStringName=”MyDb

applicationName=”Example1″

minRequiredPasswordLength=”5″

minRequiredNonalphanumericCharacters=”0″ />

providers>

membership>

step4: Using SqlServer Authentication in sqlserver

Use step1 and step2 process but in this I am using database loginDB in sqlserver authentication

sqlserver Authentication

sqlserver Authentication

To use SQL Server credentials (a UserID and Password), use:
aspnet_regsql.exe -S -U -P -d -A all

Start - programs – Microsoft Sql server 2005 – Configuration Tools – Notification Services Command Prompt then type below command

Aspnet_regsql.exe –S RAJU –U sa –P xyz –d loginDB –A all

Raju – server name (Instead of server name user can use Server IP address 192.168.1.23)

Sa – Username

Xyz – Password

loginDB – Database name

sqlserver command Prompt

sqlserver command Prompt

After executing the command, Then goto Database Customer refresh this database, then u can observe all memberships and roles with tables and Stored Procedures

Change Web.config file for Sqlserver Authentication when using Login controls in asp.net

<connectionStrings>

<remove name=”myDb“/>

<add name=”myDb” connectionString=”Data Source=RAJU;Initial Catalog=loginDB;User ID=sa;Password=xyz”

/>

</connectionStrings>

<system.web>

<membership defaultProvider=”CustomizedProvider”>

<providers>

<add name=”CustomizedProvider”

type=”System.Web.Security.SqlMembershipProvider”

connectionStringName=”MyDb

applicationName=”Example1″

minRequiredPasswordLength=”5″

minRequiredNonalphanumericCharacters=”0″ />

</providers>

</membership>

</system.web>


Alibi3col theme by Themocracy