private void UpdateWithNewSecurityDescriptor(RawSecurityDescriptor newOne, AccessControlSections includeSections)
{
Contract.Assert(newOne != null, "Must not supply a null parameter here");
if ((includeSections & AccessControlSections.Owner) != 0)
{
_ownerModified = true;
_securityDescriptor.Owner = newOne.Owner;
}
if ((includeSections & AccessControlSections.Group) != 0)
{
_groupModified = true;
_securityDescriptor.Group = newOne.Group;
}
if ((includeSections & AccessControlSections.Audit) != 0)
{
_saclModified = true;
if (newOne.SystemAcl != null)
{
_securityDescriptor.SystemAcl = new SystemAcl(IsContainer, IsDS, newOne.SystemAcl, true);
}
else
{
_securityDescriptor.SystemAcl = null;
}
// carry forward the SACL related control flags
_securityDescriptor.UpdateControlFlags(SACL_CONTROL_FLAGS, (ControlFlags)(newOne.ControlFlags & SACL_CONTROL_FLAGS));
}
if ((includeSections & AccessControlSections.Access) != 0)
{
_daclModified = true;
if (newOne.DiscretionaryAcl != null)
{
_securityDescriptor.DiscretionaryAcl = new DiscretionaryAcl(IsContainer, IsDS, newOne.DiscretionaryAcl, true);
}
else
{
_securityDescriptor.DiscretionaryAcl = null;
}
// by the following property set, the _securityDescriptor's control flags
// may contains DACL present flag. That needs to be carried forward! Therefore, we OR
// the current _securityDescriptor.s DACL present flag.
ControlFlags daclFlag = (_securityDescriptor.ControlFlags & ControlFlags.DiscretionaryAclPresent);
_securityDescriptor.UpdateControlFlags(DACL_CONTROL_FLAGS,
(ControlFlags)((newOne.ControlFlags | daclFlag) & DACL_CONTROL_FLAGS));
}
}