Friday, September 21, 2012

Activating users using a script

This is usually a problem with a lot of sites where due to a security password policy, users are deactivated after a certain number of unsuccessful attempts in trying to log in. It could be frustrating for support folks to manually activate the users.

A cron job can be created with a script to activate users deactivated in the last day. There is 2 things required one to run the script below and second to refresh the customer profile cache registry.


update userreg
set status=1,passwordinvalid=null
where trunc(passwordinvalid) >= sysdate-1 and status=0;

Refresh Customer profile Cache Registry


  1. This is only for the development environment. There might be users in deactivated status because of some other valid reasons. This process will activate all the users.

  2. It's a good point that the deactivated users will be activated and it is good to be cognizant but it should work in production for server environment if you a business process that requires activating the users and also i have a correction in server environment, it does not require registry refresh.