Search code examples
.netsql-serverauthenticationweb-configsqlmembershipprovider

SQLMembershipProvider - Adding membership to an existing database. Setting permissions


I am adding membership-related schemas to an existing database (lets call it myDatabase) following those instructions.

As a results the number of tables, views and stored procedures are being created in myDatabase.

The next step is to modify web.config for the application to use CustomizedMembershipProvider

<membership defaultProvider="CustomizedMembershipProvider">
      <providers>
         <add name="CustomizedMembershipProvider"
              type="System.Web.Security.SqlMembershipProvider"
              connectionStringName="MyDBConnectionString" />
      </providers>
    </membership>

Then we also need to specify the connection string like:

<connectionStrings>
     <add name="MyDB" MyDBConnectionString ="..." />
  </connectionStrings>

Here is my question:

  1. Should I use different connection string to the one the application uses? As is there a need to create a new user in the database with permissions related specifically to the membership objects?
  2. Once the connection string is specified with the User ID etc., do I need to grant permissions for that user for those newly created objects? Would that be for stored procedures only or also tables and views?

EDIT: I noticed that there was a set of roles created in the database along with the membership object. So it is a matter of assigning the user to the proper role(s). The roles are the likes of

aspnet_Membership_FullAccess
aspnet_Personalization_FullAccess
etc...

So the only the first part of the question remains in place. So is there a point in creating a new database user (so separate db connection)


Solution

  • I looked it up a bit,

    1. The standard connection can be used
    2. In terms of permissions it looks like it is a matter of assigning the database user to the aspnet_Membership_FullAccess role (other roles if you require privileges related to them)