Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Decrypting user password in business rule or script

anand_tank
Giga Contributor

Hi All,

 

There is need to decrypt user password and need to send it from ServiceNow to ITIM (IBM Tivoli identity manager) in string format.

 

I am trying to decrypt password with below code but it is not working as expected.

 

var Encrypter = new GlideEncrypter();

//var Encrypter = new Packages.com.glide.util.Encrypter();

var psw = Encrypter.decrypt(current.u_password);

 

I don't see decrypt function is working properly. Code is returning encrypted password only.

 

Any idea what's wrong here.

 

Thanks,

-Anand

7 REPLIES 7

anand_tank
Giga Contributor

Hi All,



I changed data type for "u_password" field, from password to password2, and it is working fine now.



 


var Encrypter = new GlideEncrypter();  


var encrypted = current.u_password; // current.<<your field name>>  


var decrypted = Encrypter.decrypt(encrypted);  


gs.addInfoMessage("encrypted..   " + encrypted);  


gs.addInfoMessage("decrypted..   " + decrypted);




Thanks,


-Anand


 


Hi,



I need decrypt password in .NET application.



means I get the user records from servicenow to my .net application via API/WSDL Web Service.


password (2 way encryption) field available in User Table.


Whenever I will fetch record via API/WSDL Web Service then I get encrypted password But actually I want decrypted password via API/WSDL Web Service.



Any helpful topic for this.


Please reply ASAP.


Thanks, Anand!



This worked perfectly for a solution I'd been researching.



John


I am trying above solution but facing below error message, what exactly the mistake am i doing?

 

"Invalid object in scoped script: [JavaClass com.glide.util.Encrypter]"

 

var Encrypter = new global.GlideEncrypter();
var decrypted = Encrypter.decrypt(target.password2);
gs.info("decrypted Password2 : " + decrypted);