I am writing ADTempus 3.0 Client application and need the vb code to add security to a job. I want to give an AD group modify rights to the job. Can you give me a sample? Thanks.
I am writing ADTempus 3.0 Client application and need the vb code to add security to a job. I want to give an AD group modify rights to the job. Can you give me a sample? Thanks.
'This method will grant "Modify" permission on a job to a specified user. |
Public Sub AddModifyPermission(ByVal job As ijob, ByVal userName As String) |
Dim securityDescriptor As ISecurityDescriptor |
Dim ace As IADTAce |
'Get the SecurityDescriptor for the job |
securityDescriptor = CType(job, IADTSecuredObject).SecurityDescriptor |
'Get the Access Control Entry (ACE) for the specified user. |
'The userName must be a valid Windows login ID, including the domain if appropriate, |
'e.g., "domain\username". |
'GetAceForName will thrown an exception if the user cannot be found. |
'The flags argument specifies the inheritance for the ACE. In this case it's |
'irrelevant because nothing inherits security from a job. If we were modifying a |
'group or other container, we could use different AceFlagsEnum values to set |
'permissions that are inherited by objects in the container. |
ace = securityDescriptor.GetAceForName(userName, AceFlagsEnum.aceInheritNone) |
'Add Modify permission to the user's permissions. |
ace.GrantMask = ace.GrantMask Or SecurityActionsEnum.saModify |
'Must save the changes to the SecurityDescriptor |
securityDescriptor.Save() |
'And then save the job |
job.Save() |
End Sub |
It assumes you have already created a session and retrieved the job.
Replies are disabled for this topic.