Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Partner
Partner

QMS API: DocumentMetaData.Authorization.Access

Hi,

We're runnnig QlikView Server 12.10 SR7.

In QMS,

Documents > User Documents > Authorization > Users Authorized to Access Document

We can add Named Users to access documets.

QMS.JPG

I want to execute the above process using QMSAPI, but it does not work.

To that end I have used the following script.

// Connect to the QMS API and handle the Service Key

QMSClient Client;

string QMS = "http://localhost:4799/QMS/Service";

Client = new QMSClient("BasicHttpBinding_IQMS", QMS);

string key = Client.GetTimeLimitedServiceKey();

ServiceKeyClientMessageInspector.ServiceKey = key;

// Create the ServiceInfo object so we can look at the settings of the QlikView Server

ServiceInfo[] MyQVS = Client.GetServices(ServiceTypes.QlikViewServer);

DocumentNode[] allDocs = Client.GetUserDocuments(MyQVS[0].ID);

DocumentMetaData Meta;

string targetDocument = "Document01.qvw";

for (int i = 0; i < allDocs.Length; i++)

{

    Console.WriteLine("documentName=" + allDocs.Name);

    if (allDocs.Name == targetDocument)

    {

        //Get the meta data for the current document

        Meta = Client.GetDocumentMetaData(allDocs, DocumentMetaDataScope.Authorization);

        //Extract the current list of Document CALs

        List<DocumentAccessEntry> documentAccess = Meta.Authorization.Access.ToList();

        documentAccess.Add(new DocumentAccessEntry { UserName = "AddUser01" });

        Client.SaveDocumentMetaData(Meta);

        //List of CALs

        for (int j = 0; j < documentAccess.Count; j++)

        {

            Console.WriteLine("  documentAccess UserName=" + documentAccess.UserName);

        }

    }

}

Running this script will get a list of documents and users.

For example, It is like this:

documentName=Document01.qvw

  documentAccess UserName=User01

  documentAccess UserName=User02

  documentAccess UserName=AddUser01

documentName=Document02.qvw

  documentAccess UserName=User01

documentName=Document03.qvw

  documentAccess UserName=User01

  documentAccess UserName=User03

From the output of the console, the user seems to be added, but it is not actually registered.

How can I use QMSAPI to add Users Authorized to Access Document?

Or can not we do that using QMSAPI?

Tags (1)