P
Parag Mahajan
Hi,
I am using the membership provider class, "System.Web.Security.ActiveDirectoryMembershipProvider".
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("attributeMapUsername", "sAMAccountName");
configNameValueCollection.Add("connectionStringName", "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..
Thanks,
Parag.
I am using the membership provider class, "System.Web.Security.ActiveDirectoryMembershipProvider".
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("attributeMapUsername", "sAMAccountName");
configNameValueCollection.Add("connectionStringName", "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..
Thanks,
Parag.