Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW

QMS API remove a Named CAL

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Sonja_Bauernfeind
Digital Support
Digital Support

QMS API remove a Named CAL

Last Update:

Jul 6, 2021 8:43:12 AM

Updated By:

Sonja_Bauernfeind

Created date:

Mar 31, 2016 7:16:00 AM

Attachments

The below is an example on how to use the QMS API to remove Named CALs. 
 

Modifying the QlikView CAL assignments outside of the license agreement is considered a license breach. Ensure that modifications are done within the agreed license terms and conditions.
The examples are provided AS IS and no support or customization can be provided by Qlik Support.

 Environment:

QlikView 

 

Resolution:

 

For Named User CAL:
{
ServiceInfo[] QVS = apiClient.GetServices(ServiceTypes.QlikViewServer);
CALConfiguration CALConfig = apiClient.GetCALConfiguration(QVS[0].ID, CALConfigurationScope.NamedCALs);
CALConfig.NamedCALs.RemovedAssignedCALs.Add(NamedCalToBeRemoved)

CALConfig.NamedCALs.AssignedCALs = CALConfig.NamedCALs.AssignedCALs(AllCalsExceptNamedCalToBeRemoved)
apiClient.SaveCALConfiguration(CALConfig);
}
 
For Named Doc CAL:
{
metaData.Licensing.RemovedAssignedCALs.Add(c);
metaData.Licensing.AssignedCALs.Remove(c)

backendClient.SaveDocumentMetaData(metaData);
}
catch (Exception ex)
{
Console.WriteLine("Removal failed. Reason: {0}",ex.Message);
}


Attached is an example VBS file, and an example C# solution. To access the attachments, log on to the Qlik Support portal. This is provided as-is as an example, and should not be used in Production environments.

With PowerShell

A Powershell script to remove a named User CAL:

$url = "http://qlikserver1.domain.local:4799/QMS/Service"
 
function GetServiceKey
{
   param(
     [string]$url
   ) 
    $service = New-WebServiceProxy -Uri $url -Namespace QlikViewServer -UseDefaultCredential
    $serviceKey = $service.GetTimeLimitedServiceKey()
    return $serviceKey
}

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/GetServices")
$hdrs.Add("Content-Type", "text/xml;charset=utf-8")
$hdrs.Add('X-Service-Key',$(GetServiceKey -url $url))

$body = @{}
$body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://ws.qliktech.com/QMS/12/2/">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:GetServices>
         <ns:serviceTypes>QlikViewServer</ns:serviceTypes>
      </ns:GetServices>
   </soapenv:Body>
</soapenv:Envelope>'

Write-host "Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $($hdrs.Values)"
$res = Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $hdrs

#
[xml]$myXml = $res.Content
$QVSServerID = $myXml.Envelope.Body.GetServicesResponse.GetServicesResult.ServiceInfo.ID
$QVSServerID

$body = @{}
$body = '<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <SaveCALConfiguration
            xmlns="http://ws.qliktech.com/QMS/12/2/">
            <calConfiguration
                xmlns:a="http://schemas.datacontract.org/2004/07/PIX.QMSAPI.DataObjects.CALs"
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <a:DocumentCALs
                    i:nil="true"/>
                <a:NamedCALs>
                    <a:AllowDynamicAssignment>
                        true
                        </a:AllowDynamicAssignment>
                    <a:AllowLicenseLease>
                        true
                        </a:AllowLicenseLease>
                    <a:Assigned>
                        2
                        </a:Assigned>
                    <a:AssignedCALs>
                        <a:AssignedNamedCAL>
                            <a:UserName>DOMAIN\ADMINISTRATOR</a:UserName>
                            </a:AssignedNamedCAL>
                        <a:AssignedNamedCAL>
                            <a:UserName>DOMAIN\USER2</a:UserName>
                            </a:AssignedNamedCAL>
                        </a:AssignedCALs>
                        <a:IdentificationMode>UserName</a:IdentificationMode>
                    <a:InLicense>
                        5
                        </a:InLicense>
                    <a:LeasedCALs>
                        <a:LeasedNamedCAL>
                            </a:LeasedNamedCAL>
                        </a:LeasedCALs>
                    <a:Limit>
                        5
                        </a:Limit>
                    <a:RemovedAssignedCALs>
                    <a:AssignedNamedCAL>
                            <a:UserName>DOMAIN\USER1</a:UserName>
                            </a:AssignedNamedCAL>
                        </a:RemovedAssignedCALs>
                    </a:NamedCALs>
                <a:QVSID>'
            $body = $body + $QVSServerID
            $body = $body + '</a:QVSID>
            <a:Scope>NamedCALs</a:Scope>
          </calConfiguration>
      </SaveCALConfiguration>
   </s:Body>
</s:Envelope>'

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/SaveCALConfiguration")
$hdrs.Add("Content-Type", "text/xml;charset=utf-8")
$hdrs.Add('X-Service-Key',$(GetServiceKey -url $url))
$res = Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $hdrs

#
$res.content
[xml]$myXml = $res.Content 

 

Both Named User CALs that you want to keep and the ones you want to remove must be specified.

If you are unsure of the full list of Named User CALs currently assigned, you can request it with the GetCALConfiguration API call, see below:

$url = "http://qlikserver1.domain.local:4799/QMS/Service"
 
function GetServiceKey
{
   param(
     [string]$url
   ) 
    $service = New-WebServiceProxy -Uri $url -Namespace QlikViewServer -UseDefaultCredential
    $serviceKey = $service.GetTimeLimitedServiceKey()
    return $serviceKey
}

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/GetServices")
$hdrs.Add("Content-Type", "text/xml;charset=utf-8")
$hdrs.Add('X-Service-Key',$(GetServiceKey -url $url))

$body = @{}
$body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://ws.qliktech.com/QMS/12/2/">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:GetServices>
         <ns:serviceTypes>QlikViewServer</ns:serviceTypes>
      </ns:GetServices>
   </soapenv:Body>
</soapenv:Envelope>'

Write-host "Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $($hdrs.Values)"
$res = Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $hdrs

#
[xml]$myXml = $res.Content
$QVSServerID = $myXml.Envelope.Body.GetServicesResponse.GetServicesResult.ServiceInfo.ID
$QVSServerID

$body = @{}
$body = '<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <GetCALConfiguration
            xmlns="http://ws.qliktech.com/QMS/12/2/">
            <qvsID>'
            $body = $body + $QVSServerID
            $body = $body + '</qvsID>
            <scope>NamedCALs</scope>
            </GetCALConfiguration>
        </s:Body>
    </s:Envelope>'

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/GetCALConfiguration")
$hdrs.Add("Content-Type", "text/xml;charset=utf-8")
$hdrs.Add('X-Service-Key',$(GetServiceKey -url $url))
$res = Invoke-WebRequest -Uri $url -Method Post -Body $body -UseDefaultCredential -Headers $hdrs

#
$res.content
[xml]$myXml = $res.Content
Labels (1)
Contributors
Version history
Last update:
‎2021-07-06 08:43 AM
Updated by: