18 Replies Latest reply: Feb 8, 2013 8:16 AM by skjagades RSS

    Get Ticket in QV10 SR2, IIS7

    Yavor Atanasov

      Hi All,

      I'm trying to set up QV server in DMS mode with ticketing. OS - Windows2008, IIS7.

      But when I request the ticket using

       

      http://localhost/QvAjaxZfc/GetTicket.aspx?admin=&cmd=%3CGlobal%20method=%27GetTicket%27%3E%3CUserId%3ETest%3C/UserId%3E%3C/Global%3E

       

      I get the following result:

       

      - <result>

      <message text="Invalid call" />

      </result>

       

      Has anybody experienced the same problem?

      Thanks

      Y

        • Get Ticket in QV10 SR2, IIS7
          Erich Shiino

          Hi,

          Maybe this previous post can help you:

           

          http://community.qlik.com/message/94546#94546

          • Re: Get Ticket in QV10 SR2, IIS7
            Daniel Rozental

            This is the code I'm using with VB.NET

             

             

                    Dim request As WebRequest = WebRequest.Create("http://" + qvshost + "/QvAjaxZfc/GetTicket.aspx?admin=")

                    Dim str As String

                    str = "<Global method='GetTicket'><UserId>" + username + "</UserId></Global>"

                    request.ContentLength = str.Length

                    request.Method = "POST"

                    request.Credentials = CredentialCache.DefaultCredentials

                    Dim writer As New StreamWriter(request.GetRequestStream())

                    writer.Write(str)

                    writer.Flush()

                    Try

                        Dim reader As StreamReader

                        reader = New StreamReader(request.GetResponse().GetResponseStream())

                        Dim document As New XmlDocument

                        document.LoadXml(reader.ReadToEnd())

                        If (document.InnerText.Length <= 0) Then

                            Throw New Exception("Check QVS Host name / availability")

                        End If

                        ticket = document.InnerText

                    Catch ex As Exception

                    End Try

              • Get Ticket in QV10 SR2, IIS7
                Yavor Atanasov

                After some investigation a guy from QlikTeck came back with this:

                "Our Iis v10 uses aspx not asp. Aspx has a security feature provided by Microsoft that doesn't allow XML to be passed as parameters in the XML. In our qvws we don't have that. So use a POST call and send the XML as an entity body."

                This may be explains why the link above isn't working. So we tried to use POST call and send XML as an entity body using the following in a simple html page:

                function GetTicket() {

                var xmlHttp = new XMLHttpRequest();

                var url = 'http://localhost/QvAJAXZfc/GetTicket.aspx?admin=';

                var cmd = '<Global method="GetTicket"><UserId>' + escape(idUserName.value) + '</UserId></Global>';

                xmlHttp.open("POST", url, false);

                xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

                xmlHttp.send(cmd);

                return xmlHttp.responseXML.documentElement.text;

                }

                 

                Still same outcome - it works with QVWS and not with IIS......

                  • Get Ticket in QV10 SR2, IIS7
                    Daniel Rozental

                    It is working for me with IIS with the above code. Is IIS properly configured? Are you able to access applications through it?

                    • Get Ticket in QV10 SR2, IIS7

                      I have exactly the same problem - slightly different code but basically does the same:

                       

                      string url = “https://localhost/QvAjaxZfc/GetTicket.aspx?admin=”;

                      string ticketRequestXml = string.Format("<Global method='GetTicket'><UserId>{0}</UserId></Global>", identity);

                      WebRequest request = WebRequest.Create(url);

                      request.ContentLength = ticketRequestXml.Length;

                      request.Credentials = new NetworkCredential(_configurationProvider.QvRequestUser, _configurationProvider.QvRequestPassword, _configurationProvider.QvRequestDomain);

                      request.Method = "POST";

                      var writer = new StreamWriter(request.GetRequestStream());

                      writer.Write(ticketRequestXml);

                      writer.Flush();

                      var reader = new StreamReader(request.GetResponse().GetResponseStream());

                      var xmlDocument = new XmlDocument();

                      xmlDocument.LoadXml(reader.ReadToEnd());

                       

                      The response I get back is

                      <result><message text="Invalid call"/></result> - very unhelpful, it gives us no clue as to why this is an invalid call. can't find any useful error logs either. Chasing QV support now...

                        • Get Ticket in QV10 SR2, IIS7
                          Yavor Atanasov

                          IIS seemed to be working as it returned a result.

                          Anyway - we gave up using IIS and now use QVWS instead, so I can't do more tests on IIS unfortunately.

                           

                          There was an authorisation issue in QVWS - it was promting for username and password, but we managed to solve that using the following in the code:

                            // QlikView Server settings

                          string qvsuser = "username";   //this user MUST be in 'QlikView Administrators' group!

                          string qvspwd = "password";

                          …….

                          request.Credentials = new NetworkCredential(qvsuser, qvspwd);

                           

                          So this problem has been solved for us.

                          Thanks for you replies guys

                    • Get Ticket in QV10 SR2, IIS7
                      Daniel Rozental

                      jdallen, do you have any updates on this?

                       

                      My code was working fine with IIS 7 but doesn't work with IIS 6.

                        • Get Ticket in QV10 SR2, IIS7

                          Yes.

                           

                          QlikView support suggested we remove the '?admin=' from the end of our POST url -this made no difference.

                           

                          We now have this working, after a huge amount of trial and error with IIS Authentication settings. Our resolution involved setting the following:

                           

                          Make sure you have an application pool in IIS to use which is set to use your QlikView service account (which should be in local Admin group and QlikView Admin group)

                           

                          Set the root site in IIS to use the custom application ppol you have setup. Also make sure that the QlikView applications under the website (eg QvAjaxZfc, QvPlugin etc) are also using that app pool.

                           

                          At the root level site in IIS (we're using IIS7), try enabling anonymous authentication (set it to use the application pool identity) and windows authentication

                           

                          For QvAjaxZfc, enable Anonymous Authentication only (also set to use the app pool identity). You may also want to try enabling Basic authentication instead - I also had success with that, although our setup is quite complicated and I dont have time to explain it all.

                           

                          What we are doing in our code is first authenticating the user against AD to make sure it is a valid user, then (see code I posted earlier) making a post request to GetTicket, using NetworkCredential(username, apssword, domain) to request a ticket using the QlikView service credentials.

                           

                          Hope this helps someone!

                        • Re: Get Ticket in QV10 SR2, IIS7

                          HI All,

                           

                          GetTicket.aspx?admin= Not working................

                           

                          we are developing an asp.net service that need to be validate QlikeView user.

                          Can any one sages best approach for that.

                           

                          My approach not working:

                           

                          i am used to validate the user by getting tokens form the existing QlikeView service.

                           

                          But the results always "invalid call" XML.

                           

                          Asp.net code we using:

                           

                          private string GetTicket(string username)

                              {

                                  string qlikviewserver = "http://localhost/qvajaxzfc/GetTicket.aspx?admin=";

                                  string postData = "<Global method=\"GetTicket\"><UserId>" + username + "</UserId></Global>";

                                  byte[] buffer = System.Text.Encoding.ASCII.GetBytes(postData);

                                  System.Net.WebRequest request = System.Net.HttpWebRequest.Create(qlikviewserver);

                                  request.ContentType = "text/xml";

                                  request.Method = "POST";

                                  request.ContentLength = postData.Length;

                                  request.Credentials = new NetworkCredential("Admin UserName", "Password");

                                  System.IO.Stream st = request.GetRequestStream();

                                  st.Write(buffer, 0, buffer.Length);

                                  st.Flush();

                                  st.Close();

                                  WebResponse res = request.GetResponse();

                                  StreamReader sr = new StreamReader(res.GetResponseStream());

                                  System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                                  try

                                  {

                                      doc.LoadXml(sr.ReadToEnd());

                                      if (doc.InnerXml.Length > 0)

                                      {

                                          return doc.InnerXml.ToString();

                                      }

                                      //throw new Exception("Could not get ticket");

                                  }

                                  catch

                                  {

                                      throw new Exception("Could not get ticket, invalid response");

                                  }

                                  return "";

                              }

                           

                          Thanks in advance..............................

                            • Re: Get Ticket in QV10 SR2, IIS7

                              its because you use getticket.

                               

                              if you use getwebticket instead you wont get invalid call.. I had the same problem.

                                • Re: Get Ticket in QV10 SR2, IIS7

                                  Hi,

                                   

                                  Thanks for your help.

                                  Now i checked with getwebticket, this also throw me same invalid call.

                                  can you please share the working code if you have....

                                  Thanks in advance.

                                   

                                  Thanks,

                                  Jagadesan S

                                    • Re: Get Ticket in QV10 SR2, IIS7

                                      <html>

                                      <head>

                                      </head>

                                      <body>

                                       

                                       

                                      <form runat="Server" id="MainForm">

                                                          <H2>QlikView WebTicket Example</H2>

                                                          Username:  <asp:TextBox runat="server" id="txtUser">MyTestUser</asp:TextBox> <br />

                                              Password:  <asp:TextBox runat="server" id="txtPassword">MyPassword</asp:TextBox> <br />

                                              Groups:  <asp:TextBox runat="server" id="txtGroups">Sales,Finance</asp:TextBox> <br />

                                              <asp:Button ID="GO" runat="server" Text="Login..." onclick="GO_Button_Click" />

                                      </form>

                                       

                                       

                                      </body>

                                      </html>

                                       

                                       

                                       

                                       

                                      <script language="c#" runat="server">

                                             

                                                          //Firsly Set up a few properties

                                              static string QlikViewServerURL = @"http://localhost/QVAJAXZFC/getwebticket.aspx";  //address of the QlikView server

                                              static string ticketinguser = "qvadmin";  //Service account used to ask for a ticket (QV Administrator), this is not the end user

                                              static string ticketingpassword = "qvadmin1234";

                                              static string document = "Sales compass.qvw";  // specify a single QVW or leave blank for access point

                                             

                                                          protected void GO_Button_Click(object sender, EventArgs e)

                                                          {

                                                  //Grab the details the user provides

                                                  string username = txtUser.Text;

                                                  string password = txtPassword.Text;

                                                  string groups = txtGroups.Text;

                                       

                                       

                                                  // Test if the user is valid

                                                  bool loginOK = ValidateUser(username, password);

                                       

                                       

                                                  //If the user is valid get a ticket and log them in

                                                                    string ticket = "";

                                                  if (loginOK)

                                                  {

                                                                              //Get the Ticket

                                                          ticket = getTicket(username, groups, ticketinguser, ticketingpassword); // add groups into the empty string if required

                                                     

                                                                              //Build a redirect link to either access point or to a single document

                                                                                        string RedirectLink = "";

                                       

                                       

                                                                                        if (document.Length > 0)

                                                                                        {//Send to a single document

                                                                                                  RedirectLink = "/qvajaxzfc/authenticate.aspx?type=html&try=/qvajaxzfc/opendoc.htm?document=" + document + "&back=/LoginPage.htm&webticket=" + ticket;

                                                                                        }

                                                                                        else

                                                                                        {//Send to a Access Point

                                                                                                  RedirectLink = "/qvajaxzfc/authenticate.aspx?type=html&try=/qlikview&back=/LoginPage.htm&webticket=" + ticket;

                                                                                        }

                                                                              //Redirect the user

                                                                                        Response.Redirect(RedirectLink);

                                       

                                                  }

                                              }

                                                 

                                             

                                              // This function is a place holder for code to test the user id and password against a database or LDAP

                                              // For the purpose of this example we are not going to test it at all, just return "true" for logged in

                                              // Of course this means anyone would be let in, so this needs to be added

                                              private bool ValidateUser(string User, string pass)

                                              {

                                                  //here you would have some logic to test the user id and password against a data base.

                                                                              return true;

                                              }

                                                    

                                       

                                       

                                             

                                                          // This function is going to take the username and groups and return a web ticket from QV

                                                          // User and groups relate to the user you want to reuqest a ticket for

                                                          // ticketinguser and password are the credentials used to ask for the ticket and needs to be a QV admin

                                              private string getTicket(string user,string usergroups,string ticketinguser, string ticketingpassword)

                                              {

                                       

                                       

                                                  StringBuilder groups = new StringBuilder();

                                                  if (!string.IsNullOrWhiteSpace(usergroups))

                                                  {

                                                      groups.Append("<GroupList>");

                                                      foreach (string group in usergroups.Split(new char[] { ',' }))

                                                      {

                                                          groups.Append("<string>");

                                                          groups.Append(group);

                                                          groups.Append("</string>");

                                                      }

                                                      groups.Append("</GroupList>");

                                                      groups.Append("<GroupsIsNames>");

                                                      groups.Append("true");

                                                      groups.Append("</GroupsIsNames>");

                                                  }

                                                  string webTicketXml = string.Format("<Global method=\"GetWebTicket\"><UserId>{0}</UserId></Global>", user);

                                       

                                       

                                                  HttpWebRequest client = (HttpWebRequest)WebRequest.Create(new Uri(QlikViewServerURL));

                                                  client.PreAuthenticate = true;

                                                  client.Method = "POST";

                                                  client.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

                                       

                                       

                                                  client.Credentials = new NetworkCredential(ticketinguser,ticketingpassword);

                                       

                                       

                                                  using (StreamWriter sw = new StreamWriter(client.GetRequestStream()))

                                                      sw.WriteLine(webTicketXml);

                                                  StreamReader sr = new StreamReader(client.GetResponse().GetResponseStream());

                                                  string result = sr.ReadToEnd();

                                       

                                       

                                                  XDocument doc = XDocument.Parse(result);

                                                  return doc.Root.Element("_retval_").Value;

                                              }

                                       

                                       

                                       

                                       

                                      </script>