4 Replies Latest reply: Mar 18, 2011 5:04 AM by rebecca RSS

    .NET workbench page and passing a user token

    IainCattanach

      Hi,

      I'm new here and have done a search, and Googled, but no joy. So apologies if the answer to this is already out there.

      I have a qvw file which is secured via DMS and section access, and set to perform data reduction based on the user. I have a forms authentication page for our web app, and code that will retrieve a user token for the logged in user from QVS. The user is also configured under section access. This all works nicely when I have the qvw file opened up via QVS in an iFrame.

      What I now want to do is connect to the same qvw file as a datasource for a .NET workbench page. Is it possible to pass the user id or token from the workbench, and have the same data reduction being performed on the underlying qvw?

      Hope someone can help! Cheers,

      Iain

       

        • .NET workbench page and passing a user token
          Thijs de Bruijn

          I'm having the exact same questions here...

          • .NET workbench page and passing a user token

            In our solution we achieve this by first generating a ticket for the user. The ticket is created using a simple asp-page that looks like this:

            <%@ language="JScript" %>
            <--
            Tickethantering för Coins Analys, Qlikview version 9
            2009-11-19 Ändrad av Rebecca Isaksson

            Parametrar: user
            Användarnamn
            Returnerar: ticket
            Ticket för tillgång till Coins Analys
            -->

            <%
            // Build $BuildVersion$

            Response.Clear();
            var host = 'localhost';

            if (typeof QvsHost == 'string') host = QvsHost;
            if (typeof QvsPort == 'number') host += ":" + QvsPort;

            function MakeXmlSafe (value)
            {
            var val = '' + value;
            val = val.replace (/&/g, '&amp;');
            val = val.replace (/</g, '&lt;');
            val = val.replace (/>/g, '&gt;');
            val = val.replace (/"/g, '&quot;');
            return val;
            }

            var user = "" + Request("user");
            Response.Expires = -1;
            Response.ContentType = "text/xml; charset=utf-8";
            var client = Server.CreateObject("QvsRemote.Client");
            client.AdminConnect(host);
            var request = "<Global method='GetTicket'><UserId>" + MakeXmlSafe(user) + "</UserId></Global>";
            var response = client.Execute(request);

            //var ticket = Left(response, 58);
            //var ticket = Right(ticket, 40);


            Response.Write (response);

            function Left(str, n){
            if (n <= 0)
            return "";
            else if (n > String(str).length)
            return str;
            else
            return String(str).substring(0,n);
            }
            function Right(str, n){
            if (n <= 0)
            return "";
            else if (n > String(str).length)
            return str;
            else {
            var iLen = String(str).length;
            return String(str).substring(iLen, iLen - n);
            }
            }

            %>

            To generate a ticket we simply call this page using a http GET request in code behind with the user as parameter. We then pull the ticket from the response and add it to the querystring on each page (using masterpages). Data reduction based on section access is then handled automatically.

            Eg)

            http://myurl/mypage.aspx?ticket=252SGSGSSDE356666

            (We actually use the parameter "userid" instead of "ticket", but from what I understand it is better to use "ticket". We use the "ticket"-parameter in our authentication process which complicates things a bit in our project.)

             

            Let me know if you need any further information or code examples.