Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following in my web.config

<connectionStrings>
   <add name="ActiveDirectoryConnection" connectionString="LDAP://ActiveDirectoryDomain1.com" providerName="System.Web.Security.ActiveDirectoryMembershipProvider"/>
</connectionStrings>

I need to add a dropdown box to my login page that allows the user to change the connectionString to a different string, e.g. "LDAP://ActiveDirectoryDomain2.com"

In C# code behind how do change the connectionString value?


More info:

The problem I am having is that there are 4 other web.config settings call that one connectionString. For example:

<activeDirectorySecurityContextSettings connectionStringName="ActiveDirectoryConnection" defaultADUserName="ReportUser" defaultADPassword="password"/>  

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
978 views
Welcome To Ask or Share your Answers For Others

1 Answer

If a user is able to change the value of the Setting, then the web.config file is the wrong place to store the setting.

You should check out a User Scoped value in a Settings file instead.

MSDN - Using Settings in C#

When using settings like this, changing the value at runtime is easy:

Properties.Settings.Default.LdapConnectionString = "New Connection String";
Properties.Settings.Default.Save();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...