TaskSetAccessControl Method

Applies access control list (ACL) entries described by a TaskSecurity object to the file described by the current Task object.

Definition

Namespace: Microsoft.Win32.TaskScheduler
Assembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.11.1
public void SetAccessControl(
	TaskSecurity taskSecurity
)

Parameters

taskSecurity  TaskSecurity
A TaskSecurity object that describes an access control list (ACL) entry to apply to the current task.

Example

Give read access to all authenticated users for a task.

C#
// Assume variable 'task' is a valid Task instance
var taskSecurity = task.GetAccessControl();
taskSecurity.AddAccessRule(new TaskAccessRule("Authenticated Users", TaskRights.Read, System.Security.AccessControl.AccessControlType.Allow));
task.SetAccessControl(taskSecurity);

See Also