Set job security

yr2yr (5 posts)
April 21, 2009 10:11 PM
Accepted Answer

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.

 

 

Bill Staff (599 posts)
April 22, 2009 07:10 AM
Accepted Answer
Here is the code to add "Modify" rights for a user or group. For userName specify the group name, such as "domain\adTempus Operators".

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

yr2yr (5 posts)
April 22, 2009 09:05 AM
Accepted Answer
Thanks Bill

Replies are disabled for this topic.