maybe, I am wrong, but I am trying get only passwordFormat (nothing else) from web.confing to my created CustomMembershipProvider nothing happen
public override void Initialize(string name, NameValueCollection config)
{
base.Initialize(name, config);
string passwordformat = config["passwordFormat"];
switch (passwordformat)
{
case "Hashed":
pPasswordFormat = MembershipPasswordFormat.Hashed;
break;
case "Encrypted":
pPasswordFormat = MembershipPasswordFormat.Encrypted;
break;
case "Clear":
pPasswordFormat = MembershipPasswordFormat.Clear;
break;
default:
throw new ProviderException("Password format not supported.");
}
Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");
if (machineKey.ValidationKey.Contains("AutoGenerate"))
if (PasswordFormat != MembershipPasswordFormat.Clear)
throw new ProviderException("Hashed or Encrypted passwords are not supported with auto-generated keys.");
}
kszymaniak
Member
205 Points
112 Posts
initialization dosen't get value from web.config (CustomMembershipProvider)
Jan 30, 2013 06:14 AM|LINK
Dear All
maybe, I am wrong, but I am trying get only passwordFormat (nothing else) from web.confing to my created CustomMembershipProvider nothing happen
public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); string passwordformat = config["passwordFormat"]; switch (passwordformat) { case "Hashed": pPasswordFormat = MembershipPasswordFormat.Hashed; break; case "Encrypted": pPasswordFormat = MembershipPasswordFormat.Encrypted; break; case "Clear": pPasswordFormat = MembershipPasswordFormat.Clear; break; default: throw new ProviderException("Password format not supported."); } Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey"); if (machineKey.ValidationKey.Contains("AutoGenerate")) if (PasswordFormat != MembershipPasswordFormat.Clear) throw new ProviderException("Hashed or Encrypted passwords are not supported with auto-generated keys."); }and part of web.config
<membership defaultProvider = "CustomMembershipProvider"> <providers> <clear /> <add name="CustomMembershipProvider" type="CustomMembershipProvider" connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\KrzysztofSzymaniak\Moje dokumenty\szymon.mdb';" passwordFormat="Encrypted" /> </providers> </membership>I have written simple code to insert user to database, but password is inserting as plaintext, not encrypt. Why?
What should I do for get value from web.config?
Thank you
kszymaniak
Member
205 Points
112 Posts
Re: initialization dosen't get value from web.config (CustomMembershipProvider)
Jan 30, 2013 06:57 PM|LINK
I solved problem. I apologize for incomprehensible post. I forgot write that I created own form for register new user
Below is code (in button register event) which works ok.
Chen Yu - MS...
All-Star
21584 Points
2493 Posts
Microsoft
Re: initialization dosen't get value from web.config (CustomMembershipProvider)
Jan 31, 2013 01:36 AM|LINK
Hi,
Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions.
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store