protected override void ExecuteOnShare(string share)
        {
            Log(Level.Info, Resources.RemoveAccessRuleRemoving, NTAccount, share);
            Activeds.IADsSecurityUtility secUtility = new Activeds.ADsSecurityUtilityClass();
            Activeds.IADsSecurityDescriptor secDescriptor = (Activeds.IADsSecurityDescriptor)secUtility.GetSecurityDescriptor(share, (int)Activeds.ADS_PATHTYPE_ENUM.ADS_PATH_FILESHARE, (int)Activeds.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
            Activeds.IADsAccessControlList dacl = (Activeds.IADsAccessControlList)secDescriptor.DiscretionaryAcl;

            List<Activeds.IADsAccessControlEntry> acesToRemove = new List<Activeds.IADsAccessControlEntry>();
            foreach (Activeds.IADsAccessControlEntry ace in dacl)
            {
                if (ace.Trustee.Equals(NTAccount, StringComparison.InvariantCultureIgnoreCase))
                {
                    acesToRemove.Add(ace);
                }
            }

            foreach (Activeds.IADsAccessControlEntry ace in acesToRemove)
            {
                dacl.RemoveAce(ace);
            }

            secDescriptor.DiscretionaryAcl = dacl;
            secUtility.SetSecurityDescriptor(share, (int)Activeds.ADS_PATHTYPE_ENUM.ADS_PATH_FILESHARE, secDescriptor, (int)Activeds.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
        }
示例#2
0
        protected override void ExecuteOnShare(string share)
        {
            Log(Level.Info, Resources.AddAccessRuleAdding, AccessMask, NTAccount, share);
            Activeds.IADsSecurityUtility secUtility = new Activeds.ADsSecurityUtilityClass();
            Activeds.IADsSecurityDescriptor secDescriptor = (Activeds.IADsSecurityDescriptor)secUtility.GetSecurityDescriptor(share, (int)Activeds.ADS_PATHTYPE_ENUM.ADS_PATH_FILESHARE, (int)Activeds.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
            Activeds.IADsAccessControlList dacl = (Activeds.IADsAccessControlList)secDescriptor.DiscretionaryAcl;

            Activeds.IADsAccessControlEntry ace = new Activeds.AccessControlEntry();
            ace.Trustee = NTAccount;
            ace.AceType = (int)Activeds.ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED;
            ace.AceFlags = (int)Activeds.ADS_ACEFLAG_ENUM.ADS_ACEFLAG_INHERIT_ACE;
            ace.AccessMask = (int)AccessMask;
            dacl.AddAce(ace);
            secDescriptor.DiscretionaryAcl = dacl;
            secUtility.SetSecurityDescriptor(share, (int)Activeds.ADS_PATHTYPE_ENUM.ADS_PATH_FILESHARE, secDescriptor, (int)Activeds.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
        }