Link to home
Start Free TrialLog in
Avatar of Anubis2005
Anubis2005Flag for Vanuatu

asked on

Custom role provider access to web.config settings

Hello All,

I'm in the process of creating a custom role/membership provider but I'm needing to know how I can access the settings of the provider as defined in the web.config file.

Example web.config:

<configuration>
  <connectionStrings>
    <add name="myConnectionString"
         connectionString="Data Source={DBSERVER};Initial Catalog={DBNAME};Persist Security Info=True;User ID={USERNAME};Password={PASS}"
         providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <membership defaultProvider="{NAME}MembershipProvider">
      <providers>
        <clear/>
        <add name="{NAME}MembershipProvider"
             type="AS.Security.Providers.Membership"
             connectionStringName="myConnectionString"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="true"
             applicationName="{APPLICATION_NAME}"
             requiresUniqueEmail="true"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             minRequiredPasswordLength="7"
             minRequiredNonalphanumericCharacters="1"
             passwordAttemptWindow="10"
             passwordStrengthRegularExpression=""/>
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="{NAME}RoleProvider">
      <providers>
        <clear/>
        <add name="{NAME}RoleProvider"
           type="AS.Security.Providers.Role"
           applicationName="{APPLICATION_NAME}"
           connectionStringName="myConnectionString" />
      </providers>
    </roleManager>
    <authentication mode="Forms">
      <forms slidingExpiration="true" timeout="60"  />
    </authentication>
  </system.web>
</configuration>


What I want to know, from within my custom provider, how can I find out what the connection string is that is defined in the web.config from within my custom class?

Thanks
Anubis.
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial