Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
maxgro
MVP
MVP

QMS API, add/remove AD user to Publisher task

Is there a way to add/remove Recipients (user in Windows AD) to an already defined task (on a source document) using the QMS API (not from QMC console)?

crf.png

1 Solution

Accepted Solutions
AlexByrd_TCG
Contributor
Contributor

I know this post is ancient but it helped me get to my end goal. Using powershell the script is a bit different and I wanted to add what worked for me. Put this code into a .ps1 file and run it.

$Hostname = '<QlikHost>'
$Version = 'IQMS6' #Change this to the version of QlikView you use. 6 = 12.6

#Import the Module
Import-module QlikView-CLI

#Establish the connection
$Connection = Connect-QlikView -Hostname $Hostname -Version $Version #-Passthru
$Connection
$QlikApp = '<task name as found in qmc>'
$QlikUser = '<Domain>\<User>'

$guid = Find-QVTask -Name $QlikApp
$task = Get-QVDocumentTask -Documenttaskid $guid.ID -Scope Distribute

# List users before adding the new user
#Write-Output $task.Distribute.Static.DistributionEntries[0].Recipients

# Adding the user
$User = @{
    Type = "Named"
    Name = $QlikUser
    OtherProperty = $QlikUser
}
$UserObject = New-Object -Type psobject -Property $User
$task.Distribute.Static.DistributionEntries[0].Recipients += $UserObject

# List users after adding the new user
#$taskRecipients = $task.Distribute.Static.DistributionEntries[0].Recipients
#$taskRecipients

# Saving the new user list
Save-QVDocumentTask -Documenttask $task

# Run a reload
# #Write-Host $guid.ID
Start-QVTask -Taskid $guid.ID

View solution in original post

8 Replies
ashfaq_haseeb
Champion III
Champion III

Hi,

Check if this helps

Qlikview Server CAL Manager

Regards

ASHFAQ

Anonymous
Not applicable

Massimo, have you figured out a way to do that? I have the same question

Not applicable

To add:

DocumentTask task = qms.GetDocumentTask(theTaskGuid, DocumentTaskScope.All); \\theTaskGuid needs to be assigned
DirectoryServiceObject item = new DirectoryServiceObject();
item.Type = DirectoryServiceObjectType.Named;
item.Name = @"DOMAIN\USER"; \\Change to the user
item.OtherProperty = @"DOMAIN\USER"; \\Change to the user
task.Distribute.Static.DistributionEntries[0].Recipients.Add(item); \\Just taking Index 0 here for this sample
qms.SaveDocumentTask(task);

To remove:
DocumentTask task = qms.GetDocumentTask(theTaskGuid, DocumentTaskScope.All); \\theTaskGuid needs to be assigned
task.Distribute.Static.DistributionEntries[0].Recipients.RemoveAt(0);  \\Just taking Index 0 and 0 here for this sample
qms.SaveDocumentTask(task);

Anonymous
Not applicable

thanks, Magnus! and I still need to republish the document after users are added this way, right?

Not applicable

Correct. This is just the defintion of the task. You then need to run the task to give the added user access.

Anonymous
Not applicable

makes sense, thanks Magnus!

sorin
Contributor II
Contributor II

hi ,

did you try to use windows rights ?

AlexByrd_TCG
Contributor
Contributor

I know this post is ancient but it helped me get to my end goal. Using powershell the script is a bit different and I wanted to add what worked for me. Put this code into a .ps1 file and run it.

$Hostname = '<QlikHost>'
$Version = 'IQMS6' #Change this to the version of QlikView you use. 6 = 12.6

#Import the Module
Import-module QlikView-CLI

#Establish the connection
$Connection = Connect-QlikView -Hostname $Hostname -Version $Version #-Passthru
$Connection
$QlikApp = '<task name as found in qmc>'
$QlikUser = '<Domain>\<User>'

$guid = Find-QVTask -Name $QlikApp
$task = Get-QVDocumentTask -Documenttaskid $guid.ID -Scope Distribute

# List users before adding the new user
#Write-Output $task.Distribute.Static.DistributionEntries[0].Recipients

# Adding the user
$User = @{
    Type = "Named"
    Name = $QlikUser
    OtherProperty = $QlikUser
}
$UserObject = New-Object -Type psobject -Property $User
$task.Distribute.Static.DistributionEntries[0].Recipients += $UserObject

# List users after adding the new user
#$taskRecipients = $task.Distribute.Static.DistributionEntries[0].Recipients
#$taskRecipients

# Saving the new user list
Save-QVDocumentTask -Documenttask $task

# Run a reload
# #Write-Host $guid.ID
Start-QVTask -Taskid $guid.ID