The methods Task.GetSecurityDescriptorSddlForm and Task.SetSecurityDescriptorSddlForm accept a parameter of type AccessControlSections. The value of this parameter is passed to [IRegisteredTask::GetSecurityDescriptor](http://msdn.microsoft.com/en-us/library/windows/desktop/aa380760(v=vs.85).aspx) and [IRegisteredTask::SetSecurityDescriptor](http://msdn.microsoft.com/en-us/library/windows/desktop/aa380769(v=vs.85).aspx) respectively. This results in incorrect behavior.
[IRegisteredTask::GetSecurityDescriptor](http://msdn.microsoft.com/en-us/library/windows/desktop/aa380760(v=vs.85).aspx) expects a [SECURITY_INFORMATION](http://msdn.microsoft.com/en-us/library/windows/desktop/aa379573(v=vs.85).aspx) data type which does not align with [AccessControlSections](http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.accesscontrolsections(v=vs.110).aspx). For example, passing AccessControlSettings.Audit to this method results in the Owner part being returned.
The documentation for [IRegisteredTask::SetSecurityDescriptor](http://msdn.microsoft.com/en-us/library/windows/desktop/aa380769(v=vs.85).aspx) indicates that the TASK_DONT_ADD_PRINCIPAL_ACE flag from the [TASK_CREATION](http://msdn.microsoft.com/en-us/library/windows/desktop/aa382538(v=vs.85).aspx) enumeration can be specified for the second parameter.
Comments: ** Comment from web user: RobV8R **
[IRegisteredTask::GetSecurityDescriptor](http://msdn.microsoft.com/en-us/library/windows/desktop/aa380760(v=vs.85).aspx) expects a [SECURITY_INFORMATION](http://msdn.microsoft.com/en-us/library/windows/desktop/aa379573(v=vs.85).aspx) data type which does not align with [AccessControlSections](http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.accesscontrolsections(v=vs.110).aspx). For example, passing AccessControlSettings.Audit to this method results in the Owner part being returned.
The documentation for [IRegisteredTask::SetSecurityDescriptor](http://msdn.microsoft.com/en-us/library/windows/desktop/aa380769(v=vs.85).aspx) indicates that the TASK_DONT_ADD_PRINCIPAL_ACE flag from the [TASK_CREATION](http://msdn.microsoft.com/en-us/library/windows/desktop/aa382538(v=vs.85).aspx) enumeration can be specified for the second parameter.
Comments: ** Comment from web user: RobV8R **
Fixing this could be accomplished with one of the following approaches:
1. Implementing Task.GetSecurityDescriptorSddlForm and Task.SetSecurityDescriptorSddlForm in a way that they work with AccessControlSections.
2. Changing the signature of the methods so that Task.GetSecurityDescriptorSddlForm accepts a SECURITY_INFORMATION instead of an AccessControlSections and Task.SetSecurityDescriptorSddlForm either omits the second parameter or accepts a TASK_CREATION and defaults it to TASK_DONT_ADD_PRINCIPAL_ACE.