• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# AccessControl.RawSecurityDescriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Security.AccessControl.RawSecurityDescriptor的典型用法代码示例。如果您正苦于以下问题:C# RawSecurityDescriptor类的具体用法?C# RawSecurityDescriptor怎么用?C# RawSecurityDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RawSecurityDescriptor类属于System.Security.AccessControl命名空间,在下文中一共展示了RawSecurityDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CheckBinaryConstructor

		private void CheckBinaryConstructor (string expectedSddl, byte[] binary)
		{
			RawSecurityDescriptor sd = new RawSecurityDescriptor (binary, 0);
			
			Assert.AreEqual (sd.BinaryLength, binary.Length);
			Assert.AreEqual (expectedSddl, sd.GetSddlForm (AccessControlSections.All));
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:RawSecurityDescriptorTest.cs


示例2: CommonSecurityDescriptor

 internal CommonSecurityDescriptor(bool isContainer, bool isDS, RawSecurityDescriptor rawSecurityDescriptor, bool trusted)
 {
     if (rawSecurityDescriptor == null)
     {
         throw new ArgumentNullException("rawSecurityDescriptor");
     }
     this.CreateFromParts(isContainer, isDS, rawSecurityDescriptor.ControlFlags, rawSecurityDescriptor.Owner, rawSecurityDescriptor.Group, (rawSecurityDescriptor.SystemAcl == null) ? null : new System.Security.AccessControl.SystemAcl(isContainer, isDS, rawSecurityDescriptor.SystemAcl, trusted), (rawSecurityDescriptor.DiscretionaryAcl == null) ? null : new System.Security.AccessControl.DiscretionaryAcl(isContainer, isDS, rawSecurityDescriptor.DiscretionaryAcl, trusted));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:CommonSecurityDescriptor.cs


示例3: SetProcessSecurityDescriptor

 public static void SetProcessSecurityDescriptor(IntPtr hWnd)
 {
     RawSecurityDescriptor sd = new RawSecurityDescriptor(ControlFlags.None, new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), null, null, new RawAcl(2, 0));
     sd.SetFlags(ControlFlags.DiscretionaryAclPresent | ControlFlags.DiscretionaryAclDefaulted);
     byte[] rawSd = new byte[sd.BinaryLength];
     sd.GetBinaryForm(rawSd, 0);
     if (!NativeMethods.Advapi32.SetKernelObjectSecurity(hWnd, (int)SecurityInfos.DiscretionaryAcl, rawSd))
         Console.WriteLine("Win32Exception(): {0}", new Win32Exception().Message);
 }
开发者ID:versx,项目名称:Panelbot,代码行数:9,代码来源:ProcessSecurity.cs


示例4: CheckSddlConstructor

		private void CheckSddlConstructor (string sddl, byte[] expectedBinary)
		{
			RawSecurityDescriptor sd = new RawSecurityDescriptor (sddl);
			
			Assert.GreaterOrEqual (sd.BinaryLength, 0);
			byte[] buffer = new byte[sd.BinaryLength];
			
			sd.GetBinaryForm (buffer, 0);
			Assert.AreEqual (expectedBinary, buffer);
		}
开发者ID:carrie901,项目名称:mono,代码行数:10,代码来源:RawSecurityDescriptorTest.cs


示例5: CheckRoundTrip

		private void CheckRoundTrip (string sddl)
		{
			RawSecurityDescriptor sd = new RawSecurityDescriptor (sddl);
			
			byte[] buffer = new byte[sd.BinaryLength];
			sd.GetBinaryForm (buffer, 0);
			
			sd = new RawSecurityDescriptor (buffer, 0);
			Assert.AreEqual (sddl, sd.GetSddlForm (AccessControlSections.All));
		}
开发者ID:carrie901,项目名称:mono,代码行数:10,代码来源:RawSecurityDescriptorTest.cs


示例6: ComputeAccess

        public ACCESS_MASK ComputeAccess(RawSecurityDescriptor descriptor, IdentityReference identity)
        {
            var accessGranted = ACCESS_MASK.NONE;

            // Create the Resource Manager
            using (SafeAuthzRMHandle authzRM = InitializeResourceManager())
            using (SafeAuthzContextHandle userClientCtxt = InitializeContextFromSid(authzRM, identity))
            {
                accessGranted = AccessCheck(userClientCtxt, descriptor);
            }

            return accessGranted;
        }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:13,代码来源:EffectiveAccessComputer.cs


示例7: AllowUserAccessToCurrentProcess

        public void AllowUserAccessToCurrentProcess()
        {
            if (originalACL == null)
                return;

            IntPtr hProcess = GetCurrentProcess();
            // Read the DACL
            var dacl = new RawSecurityDescriptor(originalACL, 0);
            // Insert the new ACE

            SetProcessSecurityDescriptor(hProcess, dacl);

            originalACL = null;
        }
开发者ID:millsy,项目名称:PreventShutdown,代码行数:14,代码来源:PreventShutdownComponent.cs


示例8: AccessCheck

        private ACCESS_MASK AccessCheck(SafeAuthzContextHandle userClientCtxt, RawSecurityDescriptor descriptor)
        {
            ACCESS_MASK accessGranted;

            // Prepare the Access Check request
            var request = new NativeMethods.AUTHZ_ACCESS_REQUEST();
            request.DesiredAccess = ACCESS_MASK.MAXIMUM_ALLOWED;
            request.PrincipalSelfSid = null;
            request.ObjectTypeList = IntPtr.Zero;
            request.ObjectTypeListLength = 0;
            request.OptionalArguments = IntPtr.Zero;

            using (var grantedAccessBuffer = SafeAllocation.Create<ACCESS_MASK>())
            using (var errorBuffer = SafeAllocation.Create<uint>())
            {
                // Prepare the access check reply
                var reply = new NativeMethods.AUTHZ_ACCESS_REPLY();
                reply.ResultListLength = 1;
                reply.SaclEvaluationResults = IntPtr.Zero;
                reply.GrantedAccessMask = grantedAccessBuffer.DangerousGetHandle();
                reply.Error = errorBuffer.DangerousGetHandle();

                var rawSD = new byte[descriptor.BinaryLength];
                descriptor.GetBinaryForm(rawSD, 0);

                if (!NativeMethods.AuthzAccessCheck(
                    NativeMethods.AuthzACFlags.None,
                    userClientCtxt,
                    ref request,
                    IntPtr.Zero,
                    rawSD,
                    null,
                    0,
                    ref reply,
                    IntPtr.Zero))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                accessGranted = grantedAccessBuffer.ToStructure();
            }

            return accessGranted;
        }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:44,代码来源:EffectiveAccessComputer.cs


示例9: Init

		void Init (bool isContainer, bool isDS, RawSecurityDescriptor rawSecurityDescriptor)
		{
			if (null == rawSecurityDescriptor)
				throw new ArgumentNullException ("rawSecurityDescriptor");
				
			SystemAcl sacl = null;
			if (null != rawSecurityDescriptor.SystemAcl)
				sacl = new SystemAcl (isContainer, isDS, rawSecurityDescriptor.SystemAcl);
				
			DiscretionaryAcl dacl = null;
			if (null != rawSecurityDescriptor.DiscretionaryAcl)
				dacl = new DiscretionaryAcl (isContainer, isDS, rawSecurityDescriptor.DiscretionaryAcl);
				
			Init (isContainer, isDS,
			      rawSecurityDescriptor.ControlFlags,
			      rawSecurityDescriptor.Owner,
			      rawSecurityDescriptor.Group,
			      sacl, dacl);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:19,代码来源:CommonSecurityDescriptor.cs


示例10: AclInheritance

        public void AclInheritance()
        {
            NtfsFileSystem ntfs = new FileSystemSource().NtfsFileSystem();

            RawSecurityDescriptor sd = new RawSecurityDescriptor("O:BAG:BAD:(A;OICINP;GA;;;BA)");
            ntfs.CreateDirectory("dir");
            ntfs.SetSecurity("dir", sd);

            ntfs.CreateDirectory(@"dir\subdir");
            RawSecurityDescriptor inheritedSd = ntfs.GetSecurity(@"dir\subdir");

            Assert.NotNull(inheritedSd);
            Assert.AreEqual("O:BAG:BAD:(A;ID;GA;;;BA)", inheritedSd.GetSddlForm(AccessControlSections.All));

            using (ntfs.OpenFile(@"dir\subdir\file", FileMode.Create, FileAccess.ReadWrite)) { }
            inheritedSd = ntfs.GetSecurity(@"dir\subdir\file");
            Assert.NotNull(inheritedSd);
            Assert.AreEqual("O:BAG:BAD:", inheritedSd.GetSddlForm(AccessControlSections.All));
        }
开发者ID:easymetadata,项目名称:discutils_Ewf-POC,代码行数:19,代码来源:NtfsFileSystemTest.cs


示例11: GetSecurityDescriptor

        public RawSecurityDescriptor GetSecurityDescriptor()
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("Path cannot be null or whitespace.", "path");
            }

            FileSystemSecurity security;
            if (!TryGetFileSecurity(path, AccessSectionsNeeded, out security))
            {
                if (!TryGetDirectorySecurity(path, AccessSectionsNeeded, out security))
                {
                    throw new ArgumentException("The path must be an existing file or directory.", path);
                }
            }

            var descriptorBinaryForm = security.GetSecurityDescriptorBinaryForm();
            var descriptor = new RawSecurityDescriptor(descriptorBinaryForm, 0);

            return descriptor;
        }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:21,代码来源:FileSystemSecurityDescriptorReader.cs


示例12: DecodeSsdl

 public static string DecodeSsdl(string ssdlStr, StringBuilder decodeBuffer,
     StringBuilder domainBuffer, StringBuilder usernameBuffer, ref int formatted)
 {
     try
     {
         var ssdl = new RawSecurityDescriptor(ssdlStr);
         ++formatted;
         decodeBuffer.Remove(0, decodeBuffer.Length);
         decodeBuffer.Append("ControlFlags=")
           .Append(ssdl.ControlFlags)
           .Append("; ResourceManagerControlBits=")
           .Append(ssdl.ResourceManagerControl);
         if (ssdl.Group != null)
             decodeBuffer.Append("; Group=").Append(ssdl.Group);
         if (ssdl.Owner != null)
             decodeBuffer.Append("; Owner=").Append(ssdl.Owner);
         if (ssdl.DiscretionaryAcl != null)
         {
             foreach (var acl in ssdl.DiscretionaryAcl)
             {
                 decodeBuffer.Append("; DiscretionaryAcl");
                 DecodeAcl(acl, decodeBuffer, domainBuffer, usernameBuffer);
             }
         }
         if (ssdl.SystemAcl != null)
         {
             foreach (var acl in ssdl.SystemAcl)
             {
                 decodeBuffer.Append("; SystemAcl");
                 DecodeAcl(acl, decodeBuffer, domainBuffer, usernameBuffer);
             }
         }
         return decodeBuffer.ToString();
     }
     catch
     {
         return ssdlStr;
     }
 }
开发者ID:salimci,项目名称:Legacy-Remote-Recorder,代码行数:39,代码来源:SsdlHelper.cs


示例13: Create

        public static VirtualHardDisk Create(string filename, ulong maximumSize,
            VirtualStorageDeviceTypes deviceType = VirtualStorageDeviceTypes.Vhd,
            VirtualDiskAccessMasks mask = VirtualDiskAccessMasks.All, RawSecurityDescriptor securityDescriptor = null,
            CreateVirtualDiskFlags flags = CreateVirtualDiskFlags.None, uint providerSpecificFlags = 0,
            Guid uniqueId = default(Guid), uint blockSizeInBytes = 0, uint sectorSizeInBytes = 0,
            string parentPath = null, string sourcePath = null, Overlapped overlapped = null)
        {
            if ()

            var storageType = new VirtualStorageType {DeviceId = deviceType};

            var parameters = new CreateVirtualDiskParameters
            {
                Version = CreateVirtualDiskVersions.Version1,
                Version1 = new CreateVirtualDiskParametersVersion1
                {
                    UniqueId = uniqueId,
                    MaximumSize = maximumSize,
                    BlockSizeInBytes = blockSizeInBytes,
                    SectorSizeInBytes = sectorSizeInBytes,
                    ParentPath = parentPath,
                    SourcePath = sourcePath
                }
            };

            var handle = VirtualDiskCore.CreateVirtualDisk(storageType, filename, mask, securityDescriptor, flags,
                providerSpecificFlags, parameters, overlapped);

            var vhd = new VirtualHardDisk(filename, handle);

            // ReSharper disable once InvertIf
            if (vhd.VirtualStorageType.DeviceId == VirtualStorageDeviceTypes.Iso)
            {
                vhd.Dispose();
                throw new NotSupportedException("This class does not support ISO files.");
            }

            return vhd;
        }
开发者ID:FaustoNascimento,项目名称:VirtualDiskManager,代码行数:39,代码来源:VirtualHardDisk.cs


示例14: EffectiveAccess

        public EffectiveAccess(string path,
                               string targetMachine,
                               RawSecurityDescriptor shareSD,
                               SecurityIdentifier userSid,
                               SecurityIdentifier deviceSid,
                               ClaimValueDictionary userClaims,
                               ClaimValueDictionary deviceClaims,
                               GroupsCollection userGroups,
                               GroupsCollection deviceGroups)
        {
            if (string.IsNullOrEmpty(targetMachine) && shareSD != null)
            {
                throw new ArgumentException("targetMachine must be value when shareSD is not-empty", "targetMachine");
            }

            handle = NativeMethods.CreateFile(path,
                                                NativeMethods.FileAccess.GenericRead,
                                                NativeMethods.FileShare.Read
                                              | NativeMethods.FileShare.Write
                                              | NativeMethods.FileShare.Delete,
                                              IntPtr.Zero,
                                              NativeMethods.FileMode.OpenExisting,
                                              NativeMethods.FileFlagAttrib.BackupSemantics,
                                              IntPtr.Zero);
            if (handle.IsInvalid)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            this.targetMachine = targetMachine;
            this.shareSD = shareSD;
            this.userSid = userSid;
            this.deviceSid = deviceSid;
            this.userClaims = userClaims;
            this.deviceClaims = deviceClaims;
            this.userGroups = userGroups;
            this.deviceGroups = deviceGroups;
        }
开发者ID:dhanzhang,项目名称:Windows-classic-samples,代码行数:38,代码来源:EffectiveAccess.cs


示例15: CreateFromParts

 private void CreateFromParts(bool isContainer, bool isDS, System.Security.AccessControl.ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, System.Security.AccessControl.SystemAcl systemAcl, System.Security.AccessControl.DiscretionaryAcl discretionaryAcl)
 {
     if ((systemAcl != null) && (systemAcl.IsContainer != isContainer))
     {
         throw new ArgumentException(Environment.GetResourceString(isContainer ? "AccessControl_MustSpecifyContainerAcl" : "AccessControl_MustSpecifyLeafObjectAcl"), "systemAcl");
     }
     if ((discretionaryAcl != null) && (discretionaryAcl.IsContainer != isContainer))
     {
         throw new ArgumentException(Environment.GetResourceString(isContainer ? "AccessControl_MustSpecifyContainerAcl" : "AccessControl_MustSpecifyLeafObjectAcl"), "discretionaryAcl");
     }
     this._isContainer = isContainer;
     if ((systemAcl != null) && (systemAcl.IsDS != isDS))
     {
         throw new ArgumentException(Environment.GetResourceString(isDS ? "AccessControl_MustSpecifyDirectoryObjectAcl" : "AccessControl_MustSpecifyNonDirectoryObjectAcl"), "systemAcl");
     }
     if ((discretionaryAcl != null) && (discretionaryAcl.IsDS != isDS))
     {
         throw new ArgumentException(Environment.GetResourceString(isDS ? "AccessControl_MustSpecifyDirectoryObjectAcl" : "AccessControl_MustSpecifyNonDirectoryObjectAcl"), "discretionaryAcl");
     }
     this._isDS = isDS;
     this._sacl = systemAcl;
     if (discretionaryAcl == null)
     {
         discretionaryAcl = System.Security.AccessControl.DiscretionaryAcl.CreateAllowEveryoneFullAccess(this._isDS, this._isContainer);
     }
     this._dacl = discretionaryAcl;
     System.Security.AccessControl.ControlFlags flags2 = flags | System.Security.AccessControl.ControlFlags.DiscretionaryAclPresent;
     if (systemAcl == null)
     {
         flags2 &= ~System.Security.AccessControl.ControlFlags.SystemAclPresent;
     }
     else
     {
         flags2 |= System.Security.AccessControl.ControlFlags.SystemAclPresent;
     }
     this._rawSd = new RawSecurityDescriptor(flags2, owner, group, (systemAcl == null) ? null : systemAcl.RawAcl, discretionaryAcl.RawAcl);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:CommonSecurityDescriptor.cs


示例16: GetBinaryForm

		public void GetBinaryForm ()
		{
			RawSecurityDescriptor sd = new RawSecurityDescriptor ("");
			sd.Owner = new SecurityIdentifier (WellKnownSidType.BuiltinUsersSid, null);
			sd.Group = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
			sd.DiscretionaryAcl = new RawAcl (1, 0);
			sd.SystemAcl = new RawAcl (1, 0);
			sd.SetFlags (sd.ControlFlags | ControlFlags.DiscretionaryAclPresent | ControlFlags.SystemAclPresent);
			
			// Empty ACL form
			byte[] buffer = new byte[sd.BinaryLength];
			sd.GetBinaryForm (buffer, 0);
			byte[] sdBinary = new byte[] {
				0x01, 0x00, 0x14, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
				0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00,
				0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00,
				0x00, 0x00, 0x21, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
				0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 };
			Assert.AreEqual (sdBinary, buffer);
			
			// Add an ACE to the DACL
			SecurityIdentifier builtInAdmins = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
			CommonAce ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
			sd.DiscretionaryAcl.InsertAce (0, ace);
			buffer = new byte[sd.BinaryLength];
			sd.GetBinaryForm (buffer, 0);
			sdBinary = new byte[] {
				0x01, 0x00, 0x14, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
				0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00,
				0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00,
				0x00, 0x00, 0x21, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
				0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x01, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x18, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, 0x01, 0x02, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
				0x00, 0x00 };
			Assert.AreEqual (sdBinary, buffer);
			
			// This time with an Object ACE
			ObjectAce objectAce = new ObjectAce (AceFlags.Inherited, AceQualifier.AccessAllowed, 0x12345678, builtInAdmins, ObjectAceFlags.ObjectAceTypePresent | ObjectAceFlags.InheritedObjectAceTypePresent, new Guid ("189c0dc7-b849-4dea-93a5-6d4cb8857a5c"), new Guid ("53b4a3d4-fe39-468b-bc60-b4fcba772fa5"), false, null);
			sd.DiscretionaryAcl = new RawAcl (2, 0);
			sd.DiscretionaryAcl.InsertAce (0, objectAce);
			buffer = new byte[sd.BinaryLength];
			sd.GetBinaryForm (buffer, 0);
			sdBinary = new byte[] {
				0x01, 0x00, 0x14, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
				0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00,
				0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00,
				0x00, 0x00, 0x21, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
				0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x02, 0x00, 0x44, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x10,
				0x3C, 0x00, 0x78, 0x56, 0x34, 0x12, 0x03, 0x00, 0x00, 0x00,
				0xC7, 0x0D, 0x9C, 0x18, 0x49, 0xB8, 0xEA, 0x4D, 0x93, 0xA5,
				0x6D, 0x4C, 0xB8, 0x85, 0x7A, 0x5C, 0xD4, 0xA3, 0xB4, 0x53,
				0x39, 0xFE, 0x8B, 0x46, 0xBC, 0x60, 0xB4, 0xFC, 0xBA, 0x77,
				0x2F, 0xA5, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
				0x20, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00 };
			Assert.AreEqual (sdBinary, buffer);
		}
开发者ID:carrie901,项目名称:mono,代码行数:63,代码来源:RawSecurityDescriptorTest.cs


示例17: FlagMismatch

		public void FlagMismatch ()
		{
			// Check setting DACL-present flag on empty SD
			RawSecurityDescriptor sd = new RawSecurityDescriptor ("");
			Assert.AreEqual (20, sd.BinaryLength);
			sd.SetFlags (ControlFlags.DiscretionaryAclPresent);
			Assert.AreEqual (20, sd.BinaryLength);
			byte[] buffer = new byte[sd.BinaryLength];
			sd.GetBinaryForm (buffer, 0);
			byte[] sdBinary = new byte[] {
				0x01, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
			Assert.AreEqual (sdBinary, buffer);
			
			// Check unsetting DACL-present flag on SD with DACL
			sd = new RawSecurityDescriptor ("O:BUG:BAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)");
			Assert.AreEqual (80, sd.BinaryLength);
			sd.SetFlags (sd.ControlFlags & ~ControlFlags.DiscretionaryAclPresent);
			Assert.AreEqual (ControlFlags.SelfRelative, sd.ControlFlags);
			Assert.AreEqual (52, sd.BinaryLength);
			buffer = new byte[sd.BinaryLength];
			sd.GetBinaryForm (buffer, 0);
			sdBinary = new byte[] {
				0x01, 0x00, 0x00, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
				0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
				0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00,
				0x00, 0x00, 0x21, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
				0x00, 0x00 };
			Assert.AreEqual (sdBinary, buffer);
		}
开发者ID:carrie901,项目名称:mono,代码行数:31,代码来源:RawSecurityDescriptorTest.cs


示例18: DoSetSecurity

        private void DoSetSecurity(File file, RawSecurityDescriptor securityDescriptor)
        {
            NtfsStream legacyStream = file.GetStream(AttributeType.SecurityDescriptor, null);
            if (legacyStream != null)
            {
                SecurityDescriptor sd = new SecurityDescriptor();
                sd.Descriptor = securityDescriptor;
                legacyStream.SetContent(sd);
            }
            else
            {
                uint id = _context.SecurityDescriptors.AddDescriptor(securityDescriptor);

                // Update the standard information attribute - so it reflects the actual file state
                NtfsStream stream = file.GetStream(AttributeType.StandardInformation, null);
                StandardInformation si = stream.GetContent<StandardInformation>();
                si.SecurityId = id;
                stream.SetContent(si);

                // Write attribute changes back to the Master File Table
                file.UpdateRecordInMft();
            }
        }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:23,代码来源:NtfsFileSystem.cs


示例19: SetSecurity

        /// <summary>
        /// Sets the security descriptor associated with the file or directory.
        /// </summary>
        /// <param name="path">The file or directory to change.</param>
        /// <param name="securityDescriptor">The new security descriptor.</param>
        public void SetSecurity(string path, RawSecurityDescriptor securityDescriptor)
        {
            using (new NtfsTransaction())
            {
                DirectoryEntry dirEntry = GetDirectoryEntry(path);
                if (dirEntry == null)
                {
                    throw new FileNotFoundException("File not found", path);
                }
                else
                {
                    File file = GetFile(dirEntry.Reference);
                    DoSetSecurity(file, securityDescriptor);

                    // Update the directory entry used to open the file
                    dirEntry.UpdateFrom(file);
                }
            }
        }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:24,代码来源:NtfsFileSystem.cs


示例20: CommonSecurityDescriptor

        internal CommonSecurityDescriptor(bool isContainer, bool isDS, RawSecurityDescriptor rawSecurityDescriptor, bool trusted)
        {
            if (rawSecurityDescriptor == null)
            {
                throw new ArgumentNullException(nameof(rawSecurityDescriptor));
            }
            Contract.EndContractBlock();

            CreateFromParts(
                isContainer,
                isDS,
                rawSecurityDescriptor.ControlFlags,
                rawSecurityDescriptor.Owner,
                rawSecurityDescriptor.Group,
                rawSecurityDescriptor.SystemAcl == null ? null : new SystemAcl(isContainer, isDS, rawSecurityDescriptor.SystemAcl, trusted),
                rawSecurityDescriptor.DiscretionaryAcl == null ? null : new DiscretionaryAcl(isContainer, isDS, rawSecurityDescriptor.DiscretionaryAcl, trusted));
        }
开发者ID:Corillian,项目名称:corefx,代码行数:17,代码来源:SecurityDescriptor.cs



注:本文中的System.Security.AccessControl.RawSecurityDescriptor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ExtendedProtection.ChannelBinding类代码示例发布时间:2022-05-26
下一篇:
C# AccessControl.RawAcl类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap