question

Upvotes
Accepted
28 1 0 7

How can I assign a user (or a user list) to a Permission set using DACS Station API?

How can I assign a user (or a user list) to a Permission set using DACS Station API?

#technologypython apiDACS
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
76.8k 239 52 72

@dgstudio

Thank you for reaching out to us.

It should be the setDacsPermissionSetUsers method, an mentioned in the DACS WEB SERVICES PROGRAMMER’S GUIDE.

The setDacsPermissionSetUsers method updates the list of users assigned to the supplied Data Access Control System permission set.

The Python code looks like this.

from suds.client import Client
import ssl

dacsLogin  = "<DACS username>"
dacsPasswd = "<DACS password>"
dacsWSurl  = "http://<DACS_SERVER>:8080/DacsWS/DacsWebServiceService?wsdl"

client = Client(dacsWSurl)
_dl = client.factory.create('dacsAdministratorLogin')
_dl.aAdministratorName.mAdministratorName         = dacsLogin
_dl.aAdministratorPassword.mAdministratorPassword = dacsPasswd

_siteName = client.factory.create('siteName')
_siteName.mSiteName = "<DACS SiteName>"

_permissionSet = client.factory.create('dacsPermissionSet')
_permissionSet.mDacsPermissionSet = "<DACS Permission SET>"

_dacsPermissionSetUserSubscriptions = client.factory.create('dacsPermissionSetUserSubscriptions')
_dacsPermissionSetUserSubscriptions.mAllowed = True
_dacsPermissionSetUserSubscriptions.mName = '<DACS User>'

_setDacsPermissionSetUsers = client.service.setDacsPermissionSetUsers(_dl, _siteName, _permissionSet, [_dacsPermissionSetUserSubscriptions])
print(_setDacsPermissionSetUsers.aResult)


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
28 1 0 7

Hi @Jirapongse

It works well thank you. Could you please advise how to adjust the Python code if we want to set PermSet for a list of users?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
76.8k 239 52 72

@dgstudio

The code looks like this:

_permissionSet = client.factory.create('dacsPermissionSet')
_permissionSet.mDacsPermissionSet = "<DACS Permission Set>"


_dacsPermissionSetUserSubscriptions = client.factory.create('dacsPermissionSetUserSubscriptions')


_dacsPermissionSetUserSubscriptions.mAllowed = True
_dacsPermissionSetUserSubscriptions.mName = '<DACS User1>'


_dacsPermissionSetUserSubscriptions1 = client.factory.create('dacsPermissionSetUserSubscriptions')


_dacsPermissionSetUserSubscriptions1.mAllowed = True
_dacsPermissionSetUserSubscriptions1.mName = '<DACS User2>'


_setDacsPermissionSetUsers = client.service.setDacsPermissionSetUsers(_dl, _siteName, _permissionSet, [_dacsPermissionSetUserSubscriptions,_dacsPermissionSetUserSubscriptions1])
print(_setDacsPermissionSetUsers.aResult)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
28 1 0 7

@Jirapongse thanks a lot for your prompt reply!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
28 1 0 7

Could you kindly help us to optimize the code using cycle to assign a list of users?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
76.8k 239 52 72

@dgstudio

Do you mean this code?

_siteName = client.factory.create('siteName')
_siteName.mSiteName = "<DACS SITE>"

_permissionSet = client.factory.create('dacsPermissionSet')
_permissionSet.mDacsPermissionSet = "<Permissoin Set>"

_userList = ['<user1>','<user2>']
_setUserSubcriptionList = []


for _user in _userList:
   _dacsPermissionSetUserSubscriptions = client.factory.create('dacsPermissionSetUserSubscriptions')
   _dacsPermissionSetUserSubscriptions.mAllowed = True
   _dacsPermissionSetUserSubscriptions.mName = _user
   _setUserSubcriptionList.append(_dacsPermissionSetUserSubscriptions)


_setDacsPermissionSetUsers = client.service.setDacsPermissionSetUsers(_dl, _siteName, _permissionSet, _setUserSubcriptionList)
print(_setDacsPermissionSetUsers.aResult)


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
28 1 0 7

@Jirapongse many thanks!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.