Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 305101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:20:31+00:00 2026-05-12T07:20:31+00:00

I have an asp.net web application that is using a MembershipProvider and RolesProvider that

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:20:32+00:00Added an answer on May 12, 2026 at 7:20 am

    I put something in place that I’m happy with:

    I created this configuration class:

        public class LdapConfiguration : ConfigurationSection
        {
            [ConfigurationProperty("PrimaryServer", IsRequired = true)]
            public string PrimaryServer
            {
                get { return (string)base["PrimaryServer"]; }
                set { base["PrimaryServer"] = value; }
            }
    
            [ConfigurationProperty("SecondaryServer", IsRequired = true)]
            public string SecondaryServer
            {
                get { return (string)base["SecondaryServer"]; }
                set { base["SecondaryServer"] = value; }
            }
    
            // more properties that I need
            ...
        }
    

    Then I registered a new config section and stored the configuration in an ldapConfiguration element:

        <configSections>
          ...
          <section name="ldapConfiguration" type="LdapConfiguration"/>
        </configSections>
        <ldapConfiguration PrimaryServer="1.2.3.4" SecondaryServer="5.6.7.8" Port="1234" CertPath="d:\mycert.cert" />
    
        <system.web>
        ...
        <!--Oh, my God, this is so awesome! In your face!-->
        <membership defaultProvider="EDirectoryMembershipProvider">
          <providers>
            <clear/>
            <add name="EDirectoryMembershipProvider" type="EDirectoryMembershipProvider" />
          </providers>
        </membership>
    
        <roleManager enabled="true" defaultProvider="GtccLdapRoleProvider" cacheRolesInCookie="true" cookieRequireSSL="true">
           <providers>
              <clear/>
              <add name="GtccLdapRoleProvider" type="EDirectoryRoleProvider" />
           </providers>
        </roleManager>
      ...
      </system.web>
    

    Then in each of my provider classes, I initialized them using my new configuration object:

        public EDirectoryMembershipProvider()
        {
            var ldapConfig = (LdapConfiguration)WebConfigurationManager.OpenWebConfiguration("/").GetSection("ldapConfiguration");
            this.PrimaryLdapServer = ldapConfig.PrimaryServer;
            this.SecondaryLdapServer = ldapConfig.SecondaryServer;
            // initialize the rest here
            ...
        }
    
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);
            // not initializing here anymore
        }
    

    And now I am storing those configuration settings in one spot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET web application that is using forms authentication. Everything is configured
I have an ASP.net web service that I'm using for a web application which
I have an ASP.NET Web Application project that I am using to host a
I have a asp.net(c#) web application in that i am using Tabbed interface to
I have an ASP .NET Web Forms application that makes use of the 'WebMethod'
I have a custom MembershipProvider that I'm using in an ASP.NET 2.0 application. Inside
I have just re-implemented an ASP.NET web application that uses NHibernate to use a
I have an ASP.NET / C# web application that is using a lot of
I have a asp.net web application that is using Linq to NHibernate in NHibernate
I have an ASP.NET web application that, for whatever reason, when it is deployed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.