Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

Not applicable

MetaServiceData

Hi

We are using QV server 9.0 SR2 in DMS authorization mode. We are trying to set authorization for each document through programatically by using the QvsNetRemote. Below the sample code we used to add a user to the document. But it somehow doesn't work. So please help us by pointing out the exact problem with below code. Also it would be grateful if someone can provide the way to write a custom directory service provider(DSP) to programatically add/read custom user details to QV server.

Dim oQVClient As QvClient = New QvClient("localhost", QvClient.Mode.Admin)

Dim oXMLAnswer As New XmlDocument()



Dim oXMLRequest As New XmlDocument()



Dim oXMLResult As XmlElement

oXMLAnswer.LoadXml(oQVClient.Execute(



"<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' ident='new:films.qvw' /> "))

oXMLRequest.LoadXml(



"<update mark='' view='' kind='MetaServiceData_obj' />")

oXMLRequest.DocumentElement.SetAttribute(



"stamp", oXMLAnswer.DocumentElement.GetAttribute("stamp"))

oXMLRequest.DocumentElement.SetAttribute(



"ident", oXMLAnswer.DocumentElement.GetAttribute("ident"))

oXMLRequest.DocumentElement.SetAttribute(



"session", oXMLAnswer.DocumentElement.GetAttribute("session"))



Dim oXMLNode1 As XmlElement

oXMLNode1 = oXMLRequest.CreateElement(



"set")

oXMLNode1.SetAttribute(



"name", "AccessList.Append")

oXMLNode1.SetAttribute(



"action", "")

oXMLRequest.DocumentElement.AppendChild(oXMLNode1)

oXMLNode1 = oXMLRequest.CreateElement(



"set")

oXMLNode1.SetAttribute(



"name", "AccessList.Selected.User")

oXMLNode1.SetAttribute(



"text", "domain\user")

oXMLRequest.DocumentElement.AppendChild(oXMLNode1)

oXMLNode1 = oXMLRequest.CreateElement(



"set")

oXMLNode1.SetAttribute(



"name", "AccessList.Selected.Allow")

oXMLNode1.SetAttribute(



"text", "Always")

oXMLRequest.DocumentElement.AppendChild(oXMLNode1)



oXMLAnswer.LoadXml(oQVClient.Execute(oXMLRequest.OuterXml))



1 Solution

Accepted Solutions
Not applicable

MetaServiceData

I got it working

We have to set the following set command before executing the outerxml

oXmlNode = oXMLRequest.CreateElement(

"set")

oXmlNode.SetAttribute(



"name", ".CreateFromActiveObject")

oXmlNode.SetAttribute(



"action", "")





10 Replies
Not applicable

MetaServiceData

I got it working

We have to set the following set command before executing the outerxml

oXmlNode = oXMLRequest.CreateElement(

"set")

oXmlNode.SetAttribute(



"name", ".CreateFromActiveObject")

oXmlNode.SetAttribute(



"action", "")





Not applicable

MetaServiceData

Hello, may you gently post here complete code?
I tried to use it but always get "server error", thank you.

Not applicable

MetaServiceData

Below the .net sample code which worked for me. (QV server version 9.0, need to refer QVSNetRemote.dll to the application)

Imports QlikTech.NetClient

Imports



System.Xml

Public Function AssignDocAccess(ByVal QVServer As String, ByVal user As String, ByVal fileName As String) As Boolean



Dim oQVClient As QvClient = New QvClient(QVServer, QvClient.Mode.Admin)



Dim oXMLAnswer As New XmlDocument()

Dim oXMLRequest As New XmlDocument()

Dim oXMLResult As XmlElement

Dim oXmlNode As XmlElement

oXMLAnswer.LoadXml(oQVClient.Execute(

"<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' ident='new:" & fileName & "'/> "))

oXMLRequest.LoadXml(

"<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' /> ")

oXMLRequest.DocumentElement.SetAttribute(



"stamp", oXMLAnswer.DocumentElement.GetAttribute("stamp"))

oXMLRequest.DocumentElement.SetAttribute(







"ident", oXMLAnswer.DocumentElement.GetAttribute("ident"))

oXMLRequest.DocumentElement.SetAttribute(



"ident", oXMLAnswer.DocumentElement.GetAttribute("ident"))

oXMLRequest.DocumentElement.SetAttribute(



"session", oXMLAnswer.DocumentElement.GetAttribute("session"))

oXmlNode = oXMLRequest.CreateElement(



"set")

oXmlNode.SetAttribute(



"name", "MetaServiceData.AccessList.Append")

oXmlNode.SetAttribute(



"action", "")

oXMLRequest.DocumentElement.AppendChild(oXmlNode)

oXmlNode = oXMLRequest.CreateElement(



"set")

oXmlNode.SetAttribute(



"name", "MetaServiceData.AccessList.Selected.User")

oXmlNode.SetAttribute(



"text", user)

oXMLRequest.DocumentElement.AppendChild(oXmlNode)

oXmlNode = oXMLRequest.CreateElement(



"set")

oXmlNode.SetAttribute(



"name", "MetaServiceData.AccessList.Selected.Allow")

oXmlNode.SetAttribute(



"text", "Always")

oXMLRequest.DocumentElement.AppendChild(oXmlNode)

oXmlNode = oXMLRequest.CreateElement(



"set")

oXmlNode.SetAttribute(



"name", ".CreateFromActiveObject")

oXmlNode.SetAttribute(



"action", "")

oXMLRequest.DocumentElement.AppendChild(oXmlNode)

oXMLAnswer.LoadXml(oQVClient.Execute(oXMLRequest.OuterXml))

oXMLResult = oXMLAnswer.DocumentElement.SelectSingleNode("



message/@text")



If Not oXMLResult Is Nothing AndAlso Not oXMLResult.Equals(String.Empty)

Then

Return False



Else

Return True





End If

End Function

Not applicable

MetaServiceData

sorry for the misaligned code.:-(

Not applicable

MetaServiceData

Thank you, now it work.
Here your code converted in c# if someone else will need.
bye
corrado

using QlikTech.NetClient;
using System.Xml;

private bool AssignDocAccess(string QVServer , string user , string fileName )
{
QvClient oQVClient = new QvClient (QVServer, QvClient.Mode.Admin);
XmlDocument oXMLAnswer = new XmlDocument();
XmlDocument oXMLRequest = new XmlDocument();
XmlNode oXMLResult;
XmlElement oXmlNode;
oXMLAnswer.LoadXml(oQVClient.Execute("<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' ident='new:" + fileName + "'/> "));
oXMLRequest.LoadXml("<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' /> ");
oXMLRequest.DocumentElement.SetAttribute("stamp", oXMLAnswer.DocumentElement.GetAttribute("stamp"));
oXMLRequest.DocumentElement.SetAttribute("ident", oXMLAnswer.DocumentElement.GetAttribute("ident"));
oXMLRequest.DocumentElement.SetAttribute("ident", oXMLAnswer.DocumentElement.GetAttribute("ident"));
oXMLRequest.DocumentElement.SetAttribute("session", oXMLAnswer.DocumentElement.GetAttribute("session"));
oXmlNode = oXMLRequest.CreateElement("set");
oXmlNode.SetAttribute("name", "MetaServiceData.AccessList.Append");
oXmlNode.SetAttribute("action", "");
oXMLRequest.DocumentElement.AppendChild(oXmlNode);
oXmlNode = oXMLRequest.CreateElement("set");
oXmlNode.SetAttribute("name", "MetaServiceData.AccessList.Selected.User");
oXmlNode.SetAttribute("text", user);
oXMLRequest.DocumentElement.AppendChild(oXmlNode);
oXmlNode = oXMLRequest.CreateElement("set");
oXmlNode.SetAttribute("name", "MetaServiceData.AccessList.Selected.Allow");
oXmlNode.SetAttribute("text", "Always");
oXMLRequest.DocumentElement.AppendChild(oXmlNode);
oXmlNode = oXMLRequest.CreateElement("set");
oXmlNode.SetAttribute("name", ".CreateFromActiveObject");
oXmlNode.SetAttribute("action", "");
oXMLRequest.DocumentElement.AppendChild(oXmlNode);
oXMLAnswer.LoadXml(oQVClient.Execute(oXMLRequest.OuterXml));
oXMLResult = oXMLAnswer.DocumentElement.SelectSingleNode("message/@text");
if (oXMLResult != null && oXMLResult.InnerText != string.Empty)
{
MessageBox.Show(this, oXMLResult.InnerText, "Error");
return false;
}
else
{
MessageBox.Show(this, "Success", "Success");
return true;
}
}

Not applicable

MetaServiceData

ok now here we are facing some problem with removing the document access rights for a particular user.

Server API mentioned like below:

The following are the access data (used when access control is set to DMS mode)
AccessList (the list of control records)
AccessList.Current (the zero based index of the selected reocrd (to be manipulated through
AccessList.Selected)
<set name="MetaServiceData.AccessList.Current" text="1"/>
AccessList.Remove (remove the current record)

below the code we have developed. We are unable to get index of current user to delete the particular user if document is associated for more than 1 user.












oXmlNode = oXMLRequest.CreateElement(
"set")
oXmlNode.SetAttribute(
"name", "MetaServiceData.AccessList.Current")

oXmlNode.SetAttribute(

"text", [index needs to be mentioned here])
oXMLRequest.DocumentElement.AppendChild(oXmlNode)



oXmlNode = oXMLRequest.CreateElement("set")
oXmlNode.SetAttribute(
"name", "MetaServiceData.AccessList.Remove")
oXmlNode.SetAttribute(
"action", "")
[\code]
If anyone has worked this out, please help me up. </body>
Not applicable

MetaServiceData

We were able to get the user's index in the access list using this function (We're trying to find a more elegant way using Linq).

private int getCurrentIdForUser(string QvServer, string userName, string fileName)
{
QvClient oQVClient = new QvClient(QvServer, QvClient.Mode.Admin);
XmlDocument oXMLAnswer = new XmlDocument();
XmlDocument oXMLRequest = new XmlDocument();
oXMLAnswer.LoadXml(oQVClient.Execute("<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' ident='new:" +
fileName + "'/> "));
oXMLRequest.LoadXml("<update mark='' view='' level='0' stamp='' kind='MetaServiceData_obj' /> ");
oXMLRequest.DocumentElement.SetAttribute("stamp", oXMLAnswer.DocumentElement.GetAttribute("stamp"));
oXMLRequest.DocumentElement.SetAttribute("ident", oXMLAnswer.DocumentElement.GetAttribute("ident"));
oXMLRequest.DocumentElement.SetAttribute("session", oXMLAnswer.DocumentElement.GetAttribute("session"));
oXMLAnswer.LoadXml(oQVClient.Execute(oXMLRequest.OuterXml));
XmlNodeList metaServiceDataGroups = oXMLAnswer.SelectNodes("result")[0].SelectNodes("object")[0].SelectNodes("group");
if (metaServiceDataGroups == null)
{
throw new ApplicationException("invalid data");
}
foreach (XmlNode node in metaServiceDataGroups)
{
if (node.Attributes["name"].Value == "AccessList")
{
XmlNodeList accessListList = node.SelectNodes("value");
foreach (XmlNode valueList in accessListList)
{
if (valueList.Attributes["name"].Value == "List")
{
XmlNodeList elementList = valueList.SelectNodes("element");
for (int i = 0; i < elementList.Count; i++)
{
XmlNodeList userValues = elementListIdea.SelectNodes("value");
foreach (XmlNode userValue in userValues)
{
if (userValue.Attributes["name"].Value == "User" && userValue.Attributes["value"].Value == userName)
{
// we found our user. index is i.
return i;
}
}
}
}
}
}
}
//did not find the user

return -1;
}

Not applicable

MetaServiceData

is it possible to achive the above using JAVA API or any other way?

Not applicable

MetaServiceData

Sorry, it does not work in PC, no exception but return true.

And I have another problem when I debug it. After I assigned parameter QVServer to "192.168.3.126", the web page show me excepiton

Authentication Failed