question

Upvotes
Accepted
28 1 2 8

Permission Set entitlement Python code for DACS SOAP

Hi @Jirapongse

Please can you kindly help us with an example of Permission Set entitlement Python code?

#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.

Hi @dgstudio ,

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?
If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,
AHS

Upvotes
Accepted
79.2k 251 52 74

@dgstudio

deleteDacsUserDefinition is a method so it should not be called like this:

_deleteDacsUserDefinition = client.factory.create('deleteDacsUserDefinition')
_deleteDacsUserDefinition.mDacsUser = <’Username>
_deleteDacsUserDefinition.mLogin = <’Username>

Please remove it.

For the code below, the third parameter of the deleteDacsUserDefinition method is dacsUser so you need to pass dacsUser.

_result = client.service.deleteDacsUserDefinition(_dl, _ds, _user.mDacsUser)

You have created a dacsUser with the following code.

_du = client.factory.create('dacsUser')
_du.mDacsUser = dacsNewUser

Therefore, you can pass it as the third parameter to the deleteDacsUserDefinition method.

Please modfy the code to:

_result = client.service.deleteDacsUserDefinition(_dl, _ds, _du)
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
79.2k 251 52 74

@dgstudio

Thank you for reaching out to us.

Please check the document that shows how to use the API.

It should be the setDacsPermissionSetEntitlements method.

1696560881754.png

You can use the client.factory.create('<data type>') to create data types (DacsAdministratorLogin, SiteName, DacsPermissionSet, and DacsPermissionSetEntitlements). Then, use these datatypes to call the method: client.service.<method name>(...).

The code looks like this:

from suds.client import Client
import ssl

####
# dacs URL and creds
dacsLogin  = "<username>"
dacsPasswd = "<password>"

dacsWSurl  = "http://<dacs server>:8080/DacsWS/DacsWebServiceService?wsdl"


client = Client(dacsWSurl)

#Create dacsAdministratorLogin data type
_dl = client.factory.create('dacsAdministratorLogin')
_dl.aAdministratorName.mAdministratorName         = dacsLogin
_dl.aAdministratorPassword.mAdministratorPassword = dacsPasswd

#Create siteName data type
_siteName = client.factory.create('siteName')
_siteName.mSiteName = "<site name>"

#Create dacsPermissionSet data type
_permissionSet = client.factory.create('dacsPermissionSet')
_permissionSet.mDacsPermissionSet = "<permission set name>"


#List of product and exchange sub services
_productList = ['WWAANZNRP','WWAAPRUFNEWS','WWABSEMBARGO']
_exchangeList = ['AAB','ABD','ABJ']


_productSubServiceEntitlementList = []
_exchangeSubServiceEntitlementList = []


#create a list of dacsSubserviceEntitlements that contains product subservices
for _product in _productList:
   _productSubServiceEntitlement = client.factory.create('dacsSubserviceEntitlements')
   _productSubServiceEntitlement.mAllowed = True
   _productSubServiceEntitlement.mName = _product
   _productSubServiceEntitlementList.append(_productSubServiceEntitlement)

#create a list of dacsSubserviceEntitlements that contains exchange subservices
for _exchange in _exchangeList:
   _exchangeSubServiceEntitlement = client.factory.create('dacsSubserviceEntitlements')
   _exchangeSubServiceEntitlement.mAllowed = True
   _exchangeSubServiceEntitlement.mName = _exchange
   _exchangeSubServiceEntitlementList.append(_exchangeSubServiceEntitlement)

#Create dacsServiceEntitlements data type and then assign the product subservice list and the exchange subservice list
_serviceEntitlements = client.factory.create('dacsServiceEntitlements')
_serviceEntitlements.mAllowed = True
_serviceEntitlements.mName = '<Vendor name>'
_serviceEntitlements.mDacsProductEntitlements = [_productSubServiceEntitlementList]
_serviceEntitlements.mDacsExchangeEntitlements = [_exchangeSubServiceEntitlementList]
_serviceEntitlements.mDacsSpecialistEntitlements = None
_serviceEntitlements.mDacsQoSEntitlements = None


#Create dacsPermissionSetEntitlements data type
_permissionSetEntitlements = client.factory.create('dacsPermissionSetEntitlements')
_permissionSetEntitlements.mDacsServiceEntitlements = _serviceEntitlements
_permissionSetEntitlements.mDacsApplicationSubscriptions = None

#Call the setDacsPermissionSetEntitlements with the created data types
_setDacsPermissionSetEntitlements = client.service.setDacsPermissionSetEntitlements(_dl, _siteName, _permissionSet, _permissionSetEntitlements)

print(_setDacsPermissionSetEntitlements)



1696560881754.png (120.4 KiB)
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 2 8

@Jirapongse thanks a lot for the code provided.

Please could you also advise on how to delete users and permission sets?

Grateful if you kindly provide the code example.

We are asking you because it's not so obvious from the Dev Guide.

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
79.2k 251 52 74

@dgstudio

The developer guide is informative which lists all methods and data types.

My team is upgrading a DACS server to a newer version so I can't test the code right now. However, you can use the following methods.

1. Use the deleteDacsPermissionSetDefinition method to delete a permission set. It requires the following data types:

  • _dl = client.factory.create('dacsAdministratorLogin')
  • _siteName = client.factory.create('siteName')
  • _permissionSet = client.factory.create('dacsPermissionSet')

1696586059202.png

2. Use the deleteDacsUserDefinition to delete a user. It requires the following data types:

  • _dl = client.factory.create('dacsAdministratorLogin')
  • _siteName = client.factory.create('siteName')
  • _user = client.factory.create('dacsUser')

1696586322022.png

If it doesn't work, please share the code. I will check it for you.


1696586059202.png (98.9 KiB)
1696586322022.png (66.7 KiB)
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 2 8

@Jirapongse could you kindly take a look at the error below?

from suds.client import Client

dacsLogin = <'AdminLogin>

dacsPasswd = < 'AdminPaassword'>

dacsNewUser = <’Username’>

_dl = client.factory.create('dacsAdministratorLogin')

_dl.aAdministratorName.mAdministratorName = dacsLogin

_dl.aAdministratorPassword.mAdministratorPassword = dacsPasswd

_ds = client.factory.create('siteName')

_ds.mSiteName = dacsSite

_du = client.factory.create('dacsUser')

_du.mDacsUser = dacsNewUser

_dud = client.factory.create('dacsUserDefinition')

_dud.mLogin = dacsNewUser

_dud.mName = dacsNewUser

_dud.mAllowedSimultaneousLogins = 1

_dud.mAllowedSimultaneousLoginsSet = True

_result = client.service.createDacsUserDefinition(_dl, _ds, _dud)

_deleteDacsUserDefinition = client.factory.create('deleteDacsUserDefinition')

_deleteDacsUserDefinition.mDacsUser = <’Username>

_deleteDacsUserDefinition.mLogin = <’Username>

_result = client.service.deleteDacsUserDefinition(_dl, _ds, _user.mDacsUser)

print(_result)

(dacsUserDefinitionDeleteResult){

aResult =

(operationResult){

mResultText = "FAILURE"

mResultCode = 2008

mErrorText = "User name supplied is invalid"

}

}

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.