Muralidharan BS
Mega Sage
Mega Sage

Password Setting and Generation

 

ServiceNow's San Diego version simplifies password creation for administrators. An out-of-the-box (OOB) script, included as part of the password policy, automates password generation. This eliminates the manual burden of creating secure passwords for each user.

 

var username = 'itil';

var password = SNC.PasswordPolicyEvaluator.generateUserPassword(username);
gs.print(password) // to view the password

var result = SNC.PasswordPolicyEvaluator.setUserPassword(username, password);

 

setUserPassword - This sets the password which is generated above and ticks the password needs reset field.

 

If there is any other script which is used to set the password then this additional line can help in validating if the generated pass is as per the policy. The script returns true/false

 

var isValid = SNC.PasswordPolicyEvaluator.isValidPwdPerPolicy('password string', '3054afe6737a3300616ca9843cf6a735'); // sysid of the password policy

sometimes the length of the password could be crazy. I've seen a generated pass with 77 char, In order to adjust the length of the passwords.

Go to Password Policy > Open the default > set max char to lower number (default 100)

 

find_real_file.png

 

Video Link - https://www.youtube.com/watch?v=cDIMEcA6Uuo

 

Thanks,

Murali

Comments
Ohki_Yamamoto
Tera Guru

Does "SNC.PasswordPolicyEvaluator.isValidPwdPerPolicy()" only work for global applications?

Can you tell me if there is a way to use it in a scope application?

Muralidharan BS
Mega Sage
Mega Sage

Hi @Ohki_Yamamoto , No I don't know any equivalent for the scoped app. This only works on the global app and we don't have access to PasswordPolicyEvaluator.

Ohki_Yamamoto
Tera Guru

Hi Kilo ,Thank you very much.

I understand that it is available only for global applications.

Alok Sharma
Tera Contributor

@Muralidharan BS @Ohki_Yamamoto Password generate script only working for admin user. How I can do it for non admin user?

Muralidharan BS
Mega Sage
Mega Sage

@Alok Sharma , It works for all the users, in the above script I tried for an ITIL user and it worked. 

Alok Sharma
Tera Contributor

@Muralidharan BS Thanks for your quick response. When I am trying to trigger SNC.PasswordPolicyEvaluator.generateUserPassword(userName); from non admin then it's returning as null. For admin it's working fine.

justinbaker
Tera Contributor

Is there more product documentation regarding what information can be pulled from the SNC.PasswordPolicyEvaluator API? I'm looking to manually generate valid passwords based on a minimum length provided by the password policy to make it easy to copy while also allowing for a maximum of 100+ characters in a password. I'd rather not use the automatic generator provided as it can provide wild ranges of character lengths

Version history
Last update:
‎06-26-2024 05:50 AM
Updated by:
Contributors