0 Replies Latest reply: Sep 14, 2017 7:18 AM by Michal Pinka RSS

    LicenseAccessDenied after 5 refreshes of web page

    Michal Pinka

      Hi,

       

      I have a web page connecting to Qlik Sense using NTLM Authentication (please see the code snippet attached below). When the user refreshes/posts the page the new session is created as I understand. After 5 refreshes I get LicenseAccessDenied exception due to limit of 5 sessions. I guess ILocastion.Dispose does not kill the session. I also tried to add REST call to logout (as you can see in the snippet) but with no success. I'm wondering how to terminate the session after each page load or eventually to keep the session live so the new one is not created each time.

       

      public async Task<List<QlikApp>> GetApps()

              {

                  List<QlikApp> apps = new List<QlikApp>();

       

                  try

                  {

                      // Open location

                      using (ILocation location = Qlik.Engine.Location.FromUri(qlikConfig.QlikEngineUri))

                      {

                          // Define the location as a connection to Qlik Sense using NTLM Authentication

                          await location.AsNtlmUserViaProxyAsync();

       

                          // Add all available apps to the list                              

                          foreach (IAppIdentifier appIdentifier in await location.GetAppIdentifiersAsync())

                          {

                              apps.Add(new QlikApp() { Id = appIdentifier.AppId, Name = appIdentifier.AppName });

                          }

       

                          /* LOGOUT REST TEST */

                          var proxyPath = "";

                          if (!string.IsNullOrEmpty(location.VirtualProxyPath))

                          {

                              proxyPath += location.VirtualProxyPath + "/";

                          }

       

                          var serverPath = $"{location.ServerUri.AbsoluteUri}{proxyPath}";

                          var request = (HttpWebRequest)HttpWebRequest.Create($"{serverPath}qps/user");

       

                          //var request = (HttpWebRequest) HttpWebRequest.Create($"{location.ServerUri}qps/{proxyPath}session/{sessCookie[1]}");

                          //var reques = (HttpWebRequest)HttpWebRequest.Create(serverPat + "/user");

       

                          request.CookieContainer = new CookieContainer();

                          foreach (var cookie in location.CustomUserCookies)

                          {

                              request.CookieContainer.Add(new Uri(serverPath), new Cookie(cookie.Key, cookie.Value));

                          }

       

                          var sc = location.SessionCookie.Split('=');

                          request.CookieContainer.Add(new Uri(serverPath), new Cookie(sc[0], sc[1]));

                          request.Method = "DELETE";

                          var res = request.GetResponse();

                      }

                  }

                  catch (Exception e)

                  {

                      //// Set alert

                      //showAlert = true;

                      //alertType = AlertType.Error;

                      //alertMessage += e.Message;

                      ////alertMessage += "There was a problem retrieving applications from the Qlick Sense.";

                      //alertMessage += Environment.NewLine;

                      throw;

                  }

       

                  return apps;

              }

       

      Many thanks!

      Michal