1 Reply Latest reply: Jun 2, 2011 10:21 AM by jose.munoz RSS

    Problem using QMS to Add Authorized Users to a QlikviewDocument

      Hi all,

       

      I'm using QMS to modify the authorizated users for a Qlikview document. The program is working fine but if the number of users is greater than 180 then the web service returns a 400 code (Bad Request) when I try to save the DocMetaData information for user USER_180. Here is the code I'm using based on Stefan Bäckstrand's code:

       

       

      //*** Get document meta data for specific document, only authorization scope
      DocumentMetaData DocMetaData = apiClient.GetDocumentMetaData(Documents.Find(it => it.Name == uFDS.QlikviewDocument), DocumentMetaDataScope.Authorization);
      
      Console.WriteLine("Cleaning previous users for document: " + uFDS.QlikviewDocument);
      DocMetaData.Authorization.Access.Clear();
      apiClient.SaveDocumentMetaData(DocMetaData);
      
      
      List<string> usersForDocument = new List<string>();
      for (int i = 1; i <= 200; i++)
      usersForDocument.Add("USER_" + i);
      
      Console.WriteLine("Adding " + usersForDocument.Count + " authorized users to document " + uFDS.QlikviewDocument);
      
      //*** Add new access - make sure to populate the week list (cannot be null)                    
      int totalAdded = 0;
      
      foreach (string user in usersForDocument)
      {
           DocumentAccessEntry authorizationEntry = new DocumentAccessEntry { UserName = user, DayOfWeekConstraints = new List<DayOfWeek>() };
           DocMetaData.Authorization.Access.Add(authorizationEntry);
           apiClient.SaveDocumentMetaData(DocMetaData);                               
      
           totalAdded++;
           Console.WriteLine("Number of users added " + totalAdded);
      }
      

       

      The funny thing is I can create more users manually if I go to the Management Console and selecting that document. I guess is something related to the web service configuration. Maybe is a limit on the number of requests, the size of the message or who knows, but unfortunately our document needs more than 180 users and this solution is not working. I would appreciate any solution or idea.

       

      This is my config file for the web service. I've increased all the parameters for <basicHttpBinding> by a factor of 10 thinking that maybe it was a configuration limit. After those changes I still get the same weird error.

       

       

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
          <system.serviceModel>
              <bindings>
                  <basicHttpBinding>
                      <binding name="BasicHttpBinding_IQMSBackend" closeTimeout="00:01:00"
                          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                          maxBufferSize="655360" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"
                          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                          useDefaultWebProxy="true">
                          <readerQuotas maxDepth="320" maxStringContentLength="81920" maxArrayLength="163840"
                              maxBytesPerRead="40960" maxNameTableCharCount="163840" />
                          <security mode="TransportCredentialOnly">
                              <transport clientCredentialType="Ntlm" proxyCredentialType="None"
                                  realm="" />
                              <message clientCredentialType="UserName" algorithmSuite="Default" />
                          </security>
                      </binding>
                  </basicHttpBinding>
              </bindings>
              <client>
                  <endpoint address="http://jose-pc:4799/QMS/Service" binding="basicHttpBinding"
                      bindingConfiguration="BasicHttpBinding_IQMSBackend" contract="QMSAPI.IQMSBackend"
                      name="BasicHttpBinding_IQMSBackend" behaviorConfiguration="ServiceKeyEndpointBehavior" />
              </client>
              <extensions>
                  <behaviorExtensions>
                      <add name="serviceKeyBehavior" type="Qlikview10UsersLoader.ServiceKeyBehaviorExtensionElement, Qlikview10UsersLoader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
                  </behaviorExtensions>
              </extensions>
              <behaviors>
                  <endpointBehaviors>
                      <behavior name="ServiceKeyEndpointBehavior">
                          <serviceKeyBehavior/>
                      </behavior>
                  </endpointBehaviors>
              </behaviors>
      
          </system.serviceModel>
      </configuration>
      

       

      Thanks in advance,

             Jose

        • Re: Problem using QMS to Add Authorized Users to a QlikviewDocument

          Apparentely is a bug/limitation of Qlikview 10. It doesn't accept more than 180 users for a document.

           

          I've managed a workaround to this problem by creating an ODBC resource. In this ODBC is defined the relationship between users that have access to a document and groups created for this purpose. Finally what is added to the document is only the name of the group, and Qlikview does the rest (you have to configure ODBC of course).

           

          The documentation on Qlikview Manual is quite poor so I will write here the hints:

           

          1) Create two tables:

           

           

               entities

                    entityid -> PK, autonumeric

                    entity_name -> varchar, the name of the user/group

                    descr -> varchar, optional description for the user/group

                    email -> varchar, optional email for the user/group

           

               groups

                    id -> PK, autonumeric

                    memberid -> int, related to the user id in table entities (don't need to be FK)

                    groupid -> int, related to the group id in table entities (don't need to be FK)

           

          So basically in table entities we define users and groups and in table groups we define the relationship between them.

           

          2) Create the ODBC

           

          I will not explain this, just Google it

           

          3) Set Qlikview 10 to use the ODBC

           

          At Qlikview Enterprise Management Console, go to System -> Directory Service Connectors -> Configurable ODBC

           

          My testing ODBC looks like:

            - Path:  ODBC://localhost

            - Username: root

            - Password: yourPassword

           

          In advanced settings:

             - Cache expiry in minutes: 15

             - Conn db name : qlikview_users <---- This is how I called my ODBC

             - Data source name: MySQL ODBC 5.1 Driver <-- This depends on your database

             - Directory label: PlaceYourLabel here. This label is used at the ticketing process. If a user is called user1 at your entities table and your label is LAB, it should be authenticated as LAB\user1. This is important

             - Entity name. This is the field used at entities table for defining user's name. In my case, is entity_name

             - Entity table db name: In my case entities

             - Groups table db name: In my case groups

             - Override connection string: I left this field empty

             - Service timeout in seconds: 30

           

          With this you should be able to add as many users as you can to a Qlikview Document by creating a group and then just adding users to that group. Then add the name of the group to the document. Programmatically is something like:

           

               // Get the list of all documents                    
               List<DocumentNode> Documents = apiClient.GetUserDocuments(qvsServices[0].ID);
          
               DocumentNode DocNode = Documents.Find(it => Path.Combine(it.RelativePath, it.Name) == qlikviewDocument);    
          
               DocumentMetaData DocMetaData = apiClient.GetDocumentMetaData(DocNode, DocumentMetaDataScope.Authorization);
          
               log.Info("Cleaning previous users and groups for QlikviewDocument: " + qlikviewDocument);
               DocMetaData.Authorization.Access.Clear();
               apiClient.SaveDocumentMetaData(DocMetaData);
          
               DocumentAccessEntry authorizationEntry = new DocumentAccessEntry { UserName = ODBC.UsersPrefix + "\\" + qlikviewDocumentGroup, DayOfWeekConstraints = new List<DayOfWeek>() };
               DocMetaData.Authorization.Access.Add(authorizationEntry);
               apiClient.SaveDocumentMetaData(DocMetaData);
               log.Info("Added Group: " + qlikviewDocumentGroup + " to QlikviewDocument: " + qlikviewDocument);
          

           

           

          By the way, it's good to restart Qlikview Directory Service Connector service, especially after adding new users to refresh cache.