Adding Microsoft Membership schema to an existing database using aspnet_regsql

posted in: Uncategorized | 0

BronwenWeeGo.jpg These guys have a really good article on ASP 2.0’s Membership, role and profiles. The part I found very useful was the section on adding the MS membership schema to an existing database. 

You can run the aspnet_regsql.exe tool from a command prompt and it allows you to add or remove the membership schema tables from an existing database. 

If you’re adding the schema into your own db, next you have to modify your web.config to point to your db.

Add your connection string


<CONNECTIONSTRINGS>
  <ADD name="SSTEST" connectionString="Data Source=SS;Initial 
Catalog=SSTest;Integrated Security=True" />

Then set the role and membership provider to point to your db

 


<CONFIGURATION>
    ... authentication & authorization settings ...

    <ROLEMANAGER defaultProvider="CustomizedRoleProvider" enabled="true">
      <PROVIDERS>
         <ADD name="CustomizedRoleProvider" connectionStringName="SSTest" type="System.Web.Security.SqlRoleProvider"
applicationName="MyTestApp" />
      </PROVIDERS>
    </ROLEMANAGER>

    <MEMBERSHIP defaultProvider="CustomizedMembershipProvider">
      <PROVIDERS>
         <ADD name="CustomizedMembershipProvider" connectionStringName="SSTest" 
type="System.Web.Security.SqlMembershipProvider" 
applicationName="MyTestApp"/>
      </PROVIDERS>
    </MEMBERSHIP>

  </SYSTEM.WEB>
</CONFIGURATION>