Hi,
I am trying to bulk update the weblogin and password for imisusers. The only way that is mentioned in the forums, is using the MembershipWebService.asmx/RegisterWebUser webservice. We have about 400000 rows and going the webservice way would involve lot of traffic on the server. Is there any way we can directly update the database using stored procedures instead of webservice?
Thanks
Nandhini
Yes and no. You can update
Yes and no. You can update the password using the aspnet_Membership_SetPassword stored procedure, however you will need a way to encrypt the password (the sproc doesn't do it for you). (See sample code at the end of this comment.)
There is no sproc that allows username changes (the ASP.Net Membership Provider does not support username changes), but you may be able to just update the UserName and LoweredUserName values in aspnet_Profile; I have not tested this and do not know if it will have adverse effects.
You will also need to update the usernames in Name_Security, UserMain, and Users; the passwords do not need to be updated, as none of them are used anymore. Finally, delete the name of any user whose username/password you change from the UserLegacyInfo table.
Sample code for encrypting a user's password (C#):
private static string GetSalt() { byte[] buf = new byte[16]; (new RNGCryptoServiceProvider()).GetBytes(buf); return Convert.ToBase64String(buf); } private static string EncodePassword(string pass, string salt) { byte[] bIn = Encoding.Unicode.GetBytes(pass); byte[] bSalt = Convert.FromBase64String(salt); byte[] bAll = new byte[bSalt.Length + bIn.Length]; byte[] bRet; Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length); Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length); HashAlgorithm s = HashAlgorithm.Create("SHA1"); bRet = s.ComputeHash(bAll); return Convert.ToBase64String(bRet); } Usage: string password = "theuser'snewpassword"; string salt = GetSalt(); password = EncodePassword(password, salt); // Call the aspnet_Membership_SetUserPassword stored procedure, passing 1 (Encrypted) for the @PasswordFormat field.