The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How can i authenticate service now user credentials using a third party application?

vishnu_r
Kilo Explorer

In my application i have username and password field and a login button. In the OnClick event of button, im trying to authenticate the credentials from servicenow sys_user table,   Is there any way to do that?

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

pasting here again



It was difficult to search and find your thread back to reply  



Not sure if you have found the answer already. if not try below appraoch and see if it works for you ...



Create a scripted web service from where you will authenticate user.. And make your of the below script .. guess it should fit your case .. let me now if it works for you



try


{


      var userName = request.user_name;


      var userPassword = request.user_password;


      var user = GlideUser;


      var authed = user.authenticate(userName,userPassword);


      if(authed)


              {


              response.isValid = 'Valid User';


      }


      else


              {


              response.isValid = 'Invalid User';


      }


}


catch(e)


{


      response.isValid = "Error While Authenticating:"+e;


}



I was able to do it successfully on demo.. So works atleast on demo


View solution in original post

3 REPLIES 3

Kalaiarasan Pus
Giga Sage

pasting here again



It was difficult to search and find your thread back to reply  



Not sure if you have found the answer already. if not try below appraoch and see if it works for you ...



Create a scripted web service from where you will authenticate user.. And make your of the below script .. guess it should fit your case .. let me now if it works for you



try


{


      var userName = request.user_name;


      var userPassword = request.user_password;


      var user = GlideUser;


      var authed = user.authenticate(userName,userPassword);


      if(authed)


              {


              response.isValid = 'Valid User';


      }


      else


              {


              response.isValid = 'Invalid User';


      }


}


catch(e)


{


      response.isValid = "Error While Authenticating:"+e;


}



I was able to do it successfully on demo.. So works atleast on demo


create the input and output parameters for web service as below



Input:


user_name


user_password



Output:


isValid


Hai Kalaiarasan,




Perfect Answer



Thanks,
Vishnu Raj