Thursday, August 4, 2011

Resetting the Password of wcsadmin



A frequent problem I encounter working with WC projects is that I get a new virtual machine for a project and the password for user wcsadmin is set to a value that I don't know. It is often easier to just reset the password then find someone who actually knows the password. Plus, the password reset methods can be used in different situations where you want to change the password of any user to a value you know.

1. Use the wcs_password script
If you know the merchant key of the environment where you are changing the password, you can simply pick the password you want, a random salt value and call the wcs_password script to find the encrypted password:
wcs_password new_password new_salt merchant_key

for example:
wcs_password passw0rd qwertyasdfgh 1a1a1a1a1a1a1a1a

Once you get the encrypted value you need to update the userreg entry for your user with these password and salt values.

If the account you are changing password is already locked, you will also need to unlock it by updating the following values:
USERREG.STATUS=1
USERREG.PASSWORDEXPIRED=0
USERREG.TIMEOUT=-1
USERREG.PASSWORDRETRIES=0
USERREG.PASSWORDINVALID=null

This is also detailed in the following IBM infocenter page:
http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.admin.doc/tasks/tseresetwcsadminaccountruntime.htm

2. Reset the password to wcsadmin if you are using the default merchant key
This will work only if you are using the default merchant key. Use the queries for your DB type in the following IBM infocenter page to reset your password to wcsadmin:
http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.admin.doc/tasks/tseresetwcsadminaccount.htm

3. If your environment is not using the default merchant key and if you don't know the merchant key in use, you cannot use the above methods. One workaround in this case is to have a user user2 whose password you know, and copy user2's password to the problem user user1.

If there is no user whose password in the environment, you can go to the storefront and register a new user. Store customers and admin users have their passwords encrypted the same way.

Query to do this update between problem user (user1) and user whose password you know (user2) is below:

update USERREG set LOGONPASSWORD=(select LOGONPASSWORD from USERREG where LOGONID='user2'), SALT=(select SALT from USERREG where LOGONID='user2') WHERE LOGONID='user1';

After this update, you can sign in as user1 using user2's password.