API
Version 7.x > API > Using SetPassword to change password isn't working View modes: 
User avatar
Member
Member
dsnapp-13datacenter - 6/26/2013 5:41:24 PM
   
Using SetPassword to change password isn't working
I am using version v7.0.21. I have a custom app that calls kentico apis to manager/administer users within our kentico site. I can create users just fine but when I use SetPassword to update an existing users password i can see that the hash on db changes in the CMS_User.UserPassword column and it looks like the user password has been updated. When I try and login with the updated credentials the server cache stills thinks the password is the old one. I can only get it to work if I clear server cache (manually through Site Mgr) after I run SetPassword. Is there a way to add the new user password to server cache after I call SetPassword?

Here is the basic code. username is a variable passed in:
UserInfo userInfo = UserInfoProvider.GetUserInfo(username.Trim()) 
CMS.SiteProvider.UserInfoProvider.SetPassword(userInfo, "secretpassword");

// i've also tried call SetPassword w/ username
CMS.SiteProvider.UserInfoProvider.SetPassword(username, "secretpassword");

// i've also tried calling SetUserInfo after SetPassword to see if it made a difference. UserInfoProvider.SetUserInfo(userInfo);

Anyone have any tricks to override the server cache when i update password through the api from an outside application?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/27/2013 1:09:32 AM
   
RE:Using SetPassword to change password isn't working
Hi,

could you please apply the latest hotfix? regrettably, there were some bugs in given method and also with passwords. We are sorry for this inconvenience.

Best regards,
Juraj Ondrus

User avatar
Member
Member
dsnapp-13datacenter - 7/8/2013 5:09:41 PM
   
RE:Using SetPassword to change password isn't working
I applied the latest hotfix (7.0.41) and it didn't seem to help. I'm seeing the same behavior.

To be clear, my api calls are being made from within a custom web forms app. Other api calls like SetUserInfo, AddUserToSite, AddUserToRole, CheckPasswordPolicy all complete successfully. When I call SetPassword the database is updated but the current server cache is not. When I login using the old password Kentico updates the database back to the old password value.

Is there a way to clear cache for a paticular user after calling SetPassword?

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/9/2013 12:42:52 AM
   
RE:Using SetPassword to change password isn't working
dsnapp-13datacenter wrote: Is there a way to clear cache for a paticular user after calling SetPassword?
Use the CacheHelper.TouchKey("dummyKeyName") method [url=CacheHelper.TouchKey("touchthis");]described here[/url]. If you don't know what the dummy key is, you will need to enable debugging on your Kentico site and review the cache keys for the user info.