How can I assign a user (or a user list) to a Permission set using DACS Station API?
@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 Clientimport ssldacsLogin = "<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)
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?
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)
@Jirapongse thanks a lot for your prompt reply!
Could you kindly help us to optimize the code using cycle to assign a list of users?
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)
@Jirapongse many thanks!