Configuring ActiveDirectoryMembershipProvider

Discussion in 'ASP .Net Security' started by anbaesivam, Feb 17, 2009.

  1. anbaesivam

    anbaesivam Guest


    I am new to ASP.NET. I am developing a web application using ASP.NET and I
    want to use ActiveDirectoryMemberhipProvider in my form authentication. In
    this provider, I need to specify the <connectionstring> and <membership>
    information to be hardcoded with the domain name, user name and password in
    the Web.config file. But in the production, my application can be installed
    in any domain. So, is it possible to configure
    ActiveDirectoryMembershipProvider at runtime?. If any tutorial/sample
    provided is highly appreciated.

    Thanks in advance.
    anbaesivam, Feb 17, 2009
    1. Advertisements

  2. Hi,

    My name is Allen Chen. It's my pleasure to work with you on this issue.

    As to this problem, the general way we'll do is to edit the settings in the
    web.config after publishing the site. It's easy to do so and we only have
    to do that once.

    If you want to create UI for the administrator to edit the web.config file
    you can try the following code:

    Configuration config =
    //Edit ConnectionStringsSection
    ConnectionStringsSection css =
    if (css != null &&
    !css.SectionInformation.IsProtected) {
    //Here ADConnectionString is the connection string. It
    may vary in your case.

    css.ConnectionStrings["ADConnectionString"].ConnectionString =
    @"LDAP://your connection string";
    //Edit MembershipSection:
    MembershipSection section =
    if (section != null &&
    //Here section.Providers[1] is
    ActiveDirectoryMembershipProvider. It may vary in your case.
    section.Providers[1].Parameters["attributeMapUsername"] =


    If you have additional questions please feel free to ask.

    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:

    Get notification to my posts through email? Please refer to

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Allen Chen [MSFT], Feb 17, 2009
    1. Advertisements

  3. Hi,

    Have you solved this issue?

    Allen Chen
    Microsoft Online Community Support
    Allen Chen [MSFT], Feb 20, 2009
  4. anbaesivam

    anbaesivam Guest

    Thanks. I solved the issue.
    anbaesivam, Feb 20, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.