The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Redirection to CMS site depending on the type of user

Abhinandan Pati
Giga Guru

Hello Everyone,

We have couple of sites in our instance & its SAML 2.0 configured.Which is the best method to redirect the user depending on the employee type?

Thanks,

Abhinandan

1 ACCEPTED SOLUTION

Create an UI Script with the following:


addLoadEvent(function() {  


        if (g_user.hasRole('admin')) {  


                  // Do nothing if user is admin, this is to allow testing of the script without risk  


        }  


        // If user has no roles and they are on a non ess page  


        else if (!g_user.hasRoles() && document.URL.indexOf('ess') == -1 && document.URL.indexOf('login_locate_sso') == -1) {  


                  // Redirect to ServiceDesk


                  window.location = 'https://your-instance.com/ess/';  


        }  




        // If user has roles, they are on a non ess page and they were not referred from the ess site  


        else if (g_user.hasRoles() && document.URL.indexOf('ess') == -1 && top.document.referrer.indexOf('ess') == -1) {  


                  // Redirect to ServiceDesk


                  window.location = 'https://your-instance.com/ess/';


}


});      



This should help you out...


Something I use for redirection.


View solution in original post

9 REPLIES 9

rajmasurkar
Giga Guru

Hi,



I think, Login rules can be a solution to your requirement.


Legacy:Configuring the Login - ServiceNow Wiki




Raj


Hi Rajmasurkar,



Thanks for the response. Login rules can't be the solution here.Because our instance is SAML 2.0 configured. And Login Rules are not supported with SAML 2.0.


You can refer the link which you have provided.



Thanks,


Abhinandan


Create an UI Script with the following:


addLoadEvent(function() {  


        if (g_user.hasRole('admin')) {  


                  // Do nothing if user is admin, this is to allow testing of the script without risk  


        }  


        // If user has no roles and they are on a non ess page  


        else if (!g_user.hasRoles() && document.URL.indexOf('ess') == -1 && document.URL.indexOf('login_locate_sso') == -1) {  


                  // Redirect to ServiceDesk


                  window.location = 'https://your-instance.com/ess/';  


        }  




        // If user has roles, they are on a non ess page and they were not referred from the ess site  


        else if (g_user.hasRoles() && document.URL.indexOf('ess') == -1 && top.document.referrer.indexOf('ess') == -1) {  


                  // Redirect to ServiceDesk


                  window.location = 'https://your-instance.com/ess/';


}


});      



This should help you out...


Something I use for redirection.


Did it work?