I have an asp.net web application that is using a MembershipProvider and RolesProvider that I wrote to use our eDirectory ldap servers.
Here are my providers now:
<membership defaultProvider="EDirectoryMembershipProvider">
<providers>
<clear/>
<add name="EDirectoryMembershipProvider" type="EDirectoryMembershipProvider"
PrimaryLdapServer="1.2.3.4"
SecondaryLdapServer="5.6.7.8"
LdapPort="1234"
CertPath="d:\mycert.crt" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="EDirectoryRoleProvider" cacheRolesInCookie="true" cookieRequireSSL="true">
<providers>
<clear/>
<add name="EDirectoryRoleProvider" type="EDirectoryRoleProvider"
PrimaryLdapServer="1.2.3.4"
SecondaryLdapServer="5.6.7.8"
LdapPort="1234"
CertPath="d:\mycert.crt" />
</providers>
</roleManager>
These two providers are configured in web.config and the settings for both are the same. Is there a way to store the settings in another section (preferably appsettings) and reference that section for the providers’ configuration?
I put something in place that I’m happy with:
I created this configuration class:
Then I registered a new config section and stored the configuration in an ldapConfiguration element:
Then in each of my provider classes, I initialized them using my new configuration object:
And now I am storing those configuration settings in one spot.