469,890 Members | 1,443 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

updating ActiveDirectoryMembershipProvider settings at runtime


I am using the membership provider class, "System.Web.Security.ActiveDirectoryMembershipProv ider".
I am using Login Server control and attaching the already configured "ActiveDirectoryMembershipProvider" in the web.config file. But my restriction is that I do not want to give the "connectionUsername" and "connectionPassword" in the web.config file.

I want to update this 2 attributes at runtime in the Login1_LoggingIn event handler, so that the user will be able to authenticated with his login credentials only, provided the user inputs a valid & correct domain user name & password.

I see that when I set the MembershipProvider property of the Login1 server control, it picks up the settings only from the web.config file and not the runtime-updated values.

How could I achive this?

Below is the code snippet, where I am stucked..

ad = new ActiveDirectoryMembershipProvider();
NameValueCollection configNameValueCollection = new NameValueCollection();
string sDomainUserName = WebConfigurationManager.AppSettings["DomainName"] + "\\" + Login1.UserName;
// "DomainName" is one app setting which stores the actual domain name.
configNameValueCollection.Add("connectionUsername" , sDomainUserName);
configNameValueCollection.Add("connectionPassword" , Login1.Password);
configNameValueCollection.Add("attributeMapUsernam e", "sAMAccountName");
configNameValueCollection.Add("connectionStringNam e", "DomainConnectionString");

ad.Initialize("DomainADMembershipProvider", configNameValueCollection);
// Here "DomainADMembershipProvider" is the same name as specified in web.config file.
Login1.MembershipProvider = ad.Name;


Let me know if this is possible..
May 12 '06 #1
0 1731

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Natan Vivo | last post: by
18 posts views Thread by Glenn Eastlack | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.