Archives

Setting a Default Domain with QlikView Web Form Authentication

This article will demonstrate a simple code change that you can implement to automatically prepend a domain name to a username during a web form authentication logon!

I'm a big fan of using form login authentication whenever possible. In today's modern world, when most users access business intelligence reports at least occasionally from mobile devices, an HTML web form is much more attractive than a pop-up credential prompt. The advantages of web forms range from aesthetic (you can brand them with your corporate colors and logo!) to functional (users are prompted to re-login when their token expires in a much more stable way). However, in most enterprise environments, presenting a web form requires users to enter credentials in domain\username format, which is often cumbersome, especially when typing on your phone or tablet's keyboard. The following is a simple "hack" to automatically prepend the domain\ portion, leaving users free to just enter their username.
 
Only a single file needs to be modified. Navigate to your Web folder (default path: C:\Program Files\QlikView\Web). Open the file FormLogin.htm in a text editor (create a backup of this file prior to modifying it). Prior to the closing tag, add the following lines of code:

 
Next, locate the line that begins with the opening form tag <form and replace that entire line with the following:

 
Change the domain variable value in the above code to the actual domain that you want to prepend and then save and close the file. When the user enters his/her credentials and presses the Submit button

the code that we just added with automatically prepend the appropriate domain, if it has not already been entered:

 
A final note: the solution in this article is applicable only to forms-based authentication and cannot be applied with automatic browser authentication used in combination with Windows Authentication (i.e. QlikView's default login scheme). The technical reason behind that is that browser-based authentication occurs between the client and the domain controller (when the browser retrieves the Kerberos token or NTLM hash string), not between the client and the web server.
 
As always, happy Qliking!
This entry was posted in QlikView Server, Tips & Tricks and tagged , , , . Bookmark the permalink.

6 Responses to Setting a Default Domain with QlikView Web Form Authentication

  1. Matt Nunn says:

    Thanks for this Vlad. I found that the FormLogin.html is in the directory C:\Program Files\QlikView\Web and not the Js directory on QVS 11.2 SR10.

    Is there any way to show a failure message when they enter their password incorrectly?

    • Thanks, Matt, I’ve corrected it now! Unfortunately I don’t know of a way to present an “incorrect password” error to users. If you ever figure it out though, please do let me know!

      Vlad

  2. Matt Nunn says:

    Hi Vlad,

    I’ve the solution. Follow these steps:
    1. In FormLogin.html look for the following
    action=”/QvAJAXZfc/Authenticate.aspx?back=/qlikview/FormLogin.htm”
    change to
    action=”/QvAJAXZfc/Authenticate.aspx?back=/qlikview/FormLoginFail.htm”
    1. Take a copy of the existing FormLogin.html and rename it FormLoginFail.html
    2. Change the html in the FormLoginFail.html to include a message such as “Incorrect username or password”.

    Easy when you know …

  3. chinna katiki says:

    Hi Vlad,

    Many thanks for the solution. I have little different case. I have 2 domains(ex: Ma and Ja). all user names in ma starts with Alphabets and all user names in ja start with numbers.
    Kindly help me to provide a code change in fromLogin.htm to dynamically prepend domain name(Ma or Ja) based on username starting character.

    best regards,
    chinna

  4. chinna katiki says:

    Hi Vlad,

    I figured out and modified the script as follows:

    function PrependDomain(){
    var user = document.loginform.username.value;
    if(!isNaN(user.charAt(0)))
    {
    var domain = “ja”;
    }
    else
    {
    var domain = “ma”;

    }
    if (user.toUpperCase().indexOf(domain) > -1){ //domain has already been entered manually (don’t append it again)
    return true;
    } else { //domain name has not been entered, append it
    document.loginform.username.value = domain + “\\” + user;
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify via email when new comments are added