Exemplo n.º 1
0
        protected void SetCap(string sharePath, _SID?capId)
        {
            _ACL sacl;

            if (capId != null)
            {
                _SYSTEM_SCOPED_POLICY_ID_ACE ace = DtypUtility.CreateSystemScopedPolicyIdAce(capId.Value);
                sacl = DtypUtility.CreateAcl(false, ace);
            }
            else
            {
                sacl = DtypUtility.CreateAcl(false);
            }

            _SECURITY_DESCRIPTOR sd = DtypUtility.CreateSecurityDescriptor(
                SECURITY_DESCRIPTOR_Control.SACLAutoInherited | SECURITY_DESCRIPTOR_Control.SACLInheritanceRequired |
                SECURITY_DESCRIPTOR_Control.SACLPresent | SECURITY_DESCRIPTOR_Control.SelfRelative,
                null,
                null,
                sacl,
                null);

            if (sharePath != null)
            {
                SetSecurityDescriptor(sharePath, null, sd, SET_INFO_Request_AdditionalInformation_Values.SCOPE_SECURITY_INFORMATION);
            }
        }
        private void SetSecurityDescriptorOnShare(object ace)
        {
            _ACL acl = DtypUtility.CreateAcl(true, ace);
            _SECURITY_DESCRIPTOR sd = originalSD;
            _ACL oriAcl             = originalSD.Dacl.Value;

            DtypUtility.AddAceToAcl(ref oriAcl, true, ace);
            sd.Dacl = oriAcl;
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Set Security Descriptor on the share ({0}): {1}.",
                                 FolderPermissionTestShareUncPath, DtypUtility.ToSddlString(sd));
            SetSecurityDescriptor(FolderPermissionTestShareUncPath, null, sd, SET_INFO_Request_AdditionalInformation_Values.DACL_SECURITY_INFORMATION);
        }