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

C# AccessControl.CommonSecurityDescriptor类代码示例

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

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



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

示例1: ObjectSecurity

 protected ObjectSecurity( bool isContainer, bool isDS )
     : this()
 {
     // we will create an empty DACL, denying anyone any access as the default. 5 is the capacity.
     DiscretionaryAcl dacl = new DiscretionaryAcl(isContainer, isDS, 5);
      _securityDescriptor = new CommonSecurityDescriptor( isContainer, isDS, ControlFlags.None, null, null, null, dacl );
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:ObjectSecurity.cs


示例2: GetBinaryForm

		public void GetBinaryForm ()
		{
			CommonSecurityDescriptor csd = new CommonSecurityDescriptor
				(false, false, ControlFlags.None, null, null, null, null);

			Assert.AreEqual (20, csd.BinaryLength);
			byte[] binaryForm = new byte[csd.BinaryLength];
			csd.GetBinaryForm (binaryForm, 0);

			Assert.AreEqual (ControlFlags.DiscretionaryAclPresent | ControlFlags.SelfRelative,
			                 csd.ControlFlags);

			// The default 'Allow Everyone Full Access' serializes as NOT having a
			// DiscretionaryAcl, as the above demonstrates (byte 3 is 0 not 4).
			Assert.AreEqual (new byte[20] {
				1, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
			}, binaryForm);

			// Changing SystemAcl protection does nothing special.
			csd.SetSystemAclProtection (true, true);
			Assert.AreEqual (20, csd.BinaryLength);

			// Modifying the DiscretionaryAcl (even effective no-ops like this) causes serialization.
			csd.SetDiscretionaryAclProtection (false, true);
			Assert.AreEqual (48, csd.BinaryLength);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:26,代码来源:CommonSecurityDescriptorTest.cs


示例3: NativeObjectSecurity

		internal NativeObjectSecurity (CommonSecurityDescriptor securityDescriptor, ResourceType resourceType)
			: base (securityDescriptor)
		{
#if !MOBILE			
			resource_type = resourceType;
#endif
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:7,代码来源:NativeObjectSecurity.cs


示例4: ObjectSecurity

		internal ObjectSecurity (CommonSecurityDescriptor securityDescriptor)
		{
			if (securityDescriptor == null)
				throw new ArgumentNullException ("securityDescriptor");
				
			descriptor = securityDescriptor;
			rw_lock = new ReaderWriterLock ();
		}
开发者ID:nicolas-raoul,项目名称:mono,代码行数:8,代码来源:ObjectSecurity.cs


示例5: IpcStore

 static IpcStore()
 {
     var dacl = new DiscretionaryAcl(false, false, 1);
     dacl.AddAccess(AccessControlType.Allow, new SecurityIdentifier(WellKnownSidType.CreatorOwnerSid, null), -1, InheritanceFlags.None, PropagationFlags.None);
     dacl.AddAccess(AccessControlType.Allow, new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), -1, InheritanceFlags.None, PropagationFlags.None);
     dacl.AddAccess(AccessControlType.Allow, new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), -1, InheritanceFlags.None, PropagationFlags.None);
     IpcAcl = new CommonSecurityDescriptor(false, false, ControlFlags.GroupDefaulted | ControlFlags.OwnerDefaulted | ControlFlags.DiscretionaryAclPresent, null, null, null, dacl);
 }
开发者ID:0install,项目名称:0install-win,代码行数:8,代码来源:IpcStore.Connection.cs


示例6: ObjectSecurity

 internal ObjectSecurity(CommonSecurityDescriptor securityDescriptor) : this()
 {
     if (securityDescriptor == null)
     {
         throw new ArgumentNullException("securityDescriptor");
     }
     this._securityDescriptor = securityDescriptor;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ObjectSecurity.cs


示例7: SecurityDescriptorResolver_ComputeHash_W2016_Vector2

        public void SecurityDescriptorResolver_ComputeHash_W2016_Vector2()
        {
            byte[] binarySecurityDescriptor = "0f00000001000480300000003c000000000000001400000002001c000100000000031400ffffffff010100000000000100000000010100000000000100000000010100000000000100000000".HexToBinary();
            byte[] expectedHash = "5763e6665429964b143bb464463bf068".HexToBinary();

            var securityDescriptor = new CommonSecurityDescriptor(true, true, binarySecurityDescriptor, 0);
            byte[] hash = SecurityDescriptorRersolver.ComputeHash(securityDescriptor);
            Assert.AreEqual(true, expectedHash.SequenceEqual(hash));
        }
开发者ID:deimx42,项目名称:DSInternals,代码行数:9,代码来源:SecurityDescriptorResolverTester.cs


示例8: SecurityDescriptorResolver_ComputeHash_W2016_Vector1

        public void SecurityDescriptorResolver_ComputeHash_W2016_Vector1()
        {
            byte[] binarySecurityDescriptor = "01001480e802000004030000140000009400000004008000040000000240140020000c0001010000000000010000000002401800000100000102000000000005200000002002000002402400000100000105000000000005150000004dfc5019daac02ace33e5bc6010200000740280000010000010000005651ec457edbbb47b53fdbeb2d03c40f010100000000000100000000040054020f000000050028000001000001000000aaf63111079cd111f79f00c04fc2dcd2010100000000000509000000050028000001000001000000abf63111079cd111f79f00c04fc2dcd2010100000000000509000000050028000001000001000000acf63111079cd111f79f00c04fc2dcd201010000000000050900000005002c000001000001000000aaf63111079cd111f79f00c04fc2dcd20102000000000005200000002002000005002c000001000001000000abf63111079cd111f79f00c04fc2dcd20102000000000005200000002002000005002c000001000001000000acf63111079cd111f79f00c04fc2dcd201020000000000052000000020020000000014009400020001010000000000050b00000000022400ff010f000105000000000005150000004dfc5019daac02ace33e5bc60702000000001400ff010f00010100000000000512000000000a2400bd010f000105000000000005150000004dfc5019daac02ae33e5bc600020000050028000001000001000000adf63111079cd111f79f00c04fc2dcd2010100000000000509000000050028000001000001000000765be9894d44624c991a0facbeda640c01010000000000050900000005002c000001000001000000adf63111079cd111f79f00c04fc2dcd20102000000000005200000002002000005002c000001000001000000765be9894d44624c991a0facbeda640c01020000000000052000000020020000050038000001000001000000aaf63111079cd111f79f00c04fc2dcd20105000000000005150000004dfc5019daac02ace33e5bc6f20100000105000000000005150000004dfc5019daac02ace33e5bc6070200000105000000000005150000004dfc5019daac02ace33e5bc607020000".HexToBinary();
            byte[] expectedHash = "1d5459903a7daca3926c0c4e09b26fe8".HexToBinary();

            var securityDescriptor = new CommonSecurityDescriptor(true, false, binarySecurityDescriptor, 0);
            byte[] hash = SecurityDescriptorRersolver.ComputeHash(securityDescriptor);
            Assert.AreEqual(true, expectedHash.SequenceEqual(hash));
        }
开发者ID:deimx42,项目名称:DSInternals,代码行数:9,代码来源:SecurityDescriptorResolverTester.cs


示例9: NativeObjectSecurity

 internal NativeObjectSecurity(ResourceType resourceType, CommonSecurityDescriptor securityDescriptor, ExceptionFromErrorCode exceptionFromErrorCode) : base(securityDescriptor)
 {
     this.ProtectedDiscretionaryAcl = 0x80000000;
     this.ProtectedSystemAcl = 0x40000000;
     this.UnprotectedDiscretionaryAcl = 0x20000000;
     this.UnprotectedSystemAcl = 0x10000000;
     this._resourceType = resourceType;
     this._exceptionFromErrorCode = exceptionFromErrorCode;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:NativeObjectSecurity.cs


示例10: ConstructorLetsFalseDSThrough

		public void ConstructorLetsFalseDSThrough ()
		{
			CommonSecurityDescriptor descriptor = new CommonSecurityDescriptor
				(false, false, ControlFlags.None, null, null, null, null);

			TestSecurity security = new TestSecurity (descriptor);
			Assert.IsFalse (security.IsContainerTest);
			Assert.IsFalse (security.IsDSTest);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:9,代码来源:DirectoryObjectSecurityTest.cs


示例11: DefaultOwnerAndGroup

		public void DefaultOwnerAndGroup ()
		{
			CommonSecurityDescriptor csd = new CommonSecurityDescriptor
				(false, false, ControlFlags.None, null, null, null, null);
			Assert.IsNull (csd.Owner);
			Assert.IsNull (csd.Group);
			Assert.AreEqual (ControlFlags.DiscretionaryAclPresent
			                 | ControlFlags.SelfRelative, csd.ControlFlags);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CommonSecurityDescriptorTest.cs


示例12: IpcServerChannel

        public IpcServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider, CommonSecurityDescriptor securityDescriptor)
        {
            this._channelPriority = 20;
            this._channelName = "ipc server";
            this._bExclusiveAddressUse = true;
            this._waitForStartListening = new AutoResetEvent(false);
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch (((string) entry.Key))
                    {
                        case "name":
                            this._channelName = (string) entry.Value;
                            break;

                        case "portName":
                            this._portName = (string) entry.Value;
                            break;

                        case "priority":
                            this._channelPriority = Convert.ToInt32(entry.Value, CultureInfo.InvariantCulture);
                            break;

                        case "secure":
                            this._secure = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            break;

                        case "impersonate":
                            this._impersonate = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            this.authSet = true;
                            break;

                        case "suppressChannelData":
                            this._bSuppressChannelData = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            break;

                        case "authorizedGroup":
                            this._authorizedGroup = (string) entry.Value;
                            break;

                        case "exclusiveAddressUse":
                            this._bExclusiveAddressUse = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            break;
                    }
                }
            }
            if (this._portName == null)
            {
                throw new RemotingException(CoreChannel.GetResourceString("Remoting_Ipc_NoPortNameSpecified"));
            }
            this._sinkProvider = sinkProvider;
            this._securityDescriptor = securityDescriptor;
            this.SetupChannel();
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:55,代码来源:IpcServerChannel.cs


示例13: DirectoryObjectSecurity

        protected DirectoryObjectSecurity(CommonSecurityDescriptor securityDescriptor)
            : base(securityDescriptor)
        {
            if (securityDescriptor == null)
            {
                throw new ArgumentNullException("securityDescriptor");
            }
            Contract.EndContractBlock();

            _securityDescriptor = securityDescriptor;
        }
开发者ID:schaabs,项目名称:corefx,代码行数:11,代码来源:DirectoryObjectSecurity.cs


示例14: ObjectSecurity

        internal ObjectSecurity( CommonSecurityDescriptor securityDescriptor )
            : this()
        {
            if ( securityDescriptor == null )
            {
                throw new ArgumentNullException( "securityDescriptor" );
            }
            Contract.EndContractBlock();

             _securityDescriptor = securityDescriptor;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:ObjectSecurity.cs


示例15: GetAllowAllNodeAcl

      public override byte[] GetAllowAllNodeAcl(string repositoryName, Guid domainId, Guid rootMapId)
      {
         // Return an empty Windows node ACL.
         SecurityIdentifier farmAccountSid = SPFarm.Local.DefaultServiceAccount.SecurityIdentifier;
         CommonSecurityDescriptor securityDescriptor = new CommonSecurityDescriptor(false, false, ControlFlags.None, farmAccountSid, null, null, null);
         securityDescriptor.SetDiscretionaryAclProtection(true, false);

         byte[] itemAcl = new byte[securityDescriptor.BinaryLength];
         securityDescriptor.GetBinaryForm(itemAcl, 0);

         return itemAcl;
      }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:12,代码来源:WindowsGlymaSecurityManager.cs


示例16: ComputeHash

 public static byte[] ComputeHash(CommonSecurityDescriptor securityDescriptor)
 {
     if(securityDescriptor == null)
     {
         return null;
     }
     // Convert to binary form
     byte[] binaryForm = new byte[securityDescriptor.BinaryLength];
     securityDescriptor.GetBinaryForm(binaryForm, 0);
     using(var md5 = MD5CryptoServiceProvider.Create())
     {
         return md5.ComputeHash(binaryForm);
     }
 }
开发者ID:deimx42,项目名称:DSInternals,代码行数:14,代码来源:SecurityDescriptorResolver.cs


示例17: AefaModifiedFlagIsStoredOnDiscretionaryAcl

		public void AefaModifiedFlagIsStoredOnDiscretionaryAcl ()
		{
			CommonSecurityDescriptor csd1, csd2;

			// Incidentally this shows the DiscretionaryAcl is NOT cloned.
			csd1 = new CommonSecurityDescriptor (false, false, ControlFlags.None, null, null, null, null);
			csd2 = new CommonSecurityDescriptor (false, false, ControlFlags.None, null, null, null, csd1.DiscretionaryAcl);
			Assert.AreSame (csd1.DiscretionaryAcl, csd2.DiscretionaryAcl);

			Assert.AreEqual ("", csd1.GetSddlForm (AccessControlSections.Access));
			csd2.SetDiscretionaryAclProtection (false, true);
			Assert.AreEqual ("D:(A;;0xffffffff;;;WD)", csd1.GetSddlForm (AccessControlSections.Access));
			Assert.AreEqual ("D:(A;;0xffffffff;;;WD)", csd2.GetSddlForm (AccessControlSections.Access));
		}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:CommonSecurityDescriptorTest.cs


示例18: IpcChannel

 public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor)
 {
     this._channelPriority = 20;
     this._channelName = "ipc";
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     bool flag = false;
     if (properties != null)
     {
         foreach (DictionaryEntry entry in properties)
         {
             string key = (string) entry.Key;
             if (key == null)
             {
                 goto Label_00CC;
             }
             if (!(key == "name"))
             {
                 if (key == "priority")
                 {
                     goto Label_0098;
                 }
                 if (key == "portName")
                 {
                     goto Label_00B6;
                 }
                 goto Label_00CC;
             }
             this._channelName = (string) entry.Value;
             continue;
         Label_0098:
             this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture);
             continue;
         Label_00B6:
             hashtable2["portName"] = entry.Value;
             flag = true;
             continue;
         Label_00CC:
             hashtable[entry.Key] = entry.Value;
             hashtable2[entry.Key] = entry.Value;
         }
     }
     this._clientChannel = new IpcClientChannel(hashtable, clientSinkProvider);
     if (flag)
     {
         this._serverChannel = new IpcServerChannel(hashtable2, serverSinkProvider, securityDescriptor);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:48,代码来源:IpcChannel.cs


示例19: ObjectSecurityJustWrapsCommonSecurityDescriptor

		public void ObjectSecurityJustWrapsCommonSecurityDescriptor ()
		{
			CommonSecurityDescriptor descriptor = new CommonSecurityDescriptor
				(false, false, ControlFlags.None, null, null, null, null);

			TestSecurity security = new TestSecurity (descriptor);
			Assert.IsNull (security.GetOwner (typeof(SecurityIdentifier)));
			SecurityIdentifier sid = new SecurityIdentifier ("WD");

			descriptor.Owner = sid; // Not virtual, so the conclusion in the test's title.
			Assert.IsFalse (security.OwnerModifiedTest);
			Assert.AreSame (sid, security.GetOwner (typeof(SecurityIdentifier)));

			security.SetOwner (sid);
			Assert.IsTrue (security.OwnerModifiedTest);
			Assert.AreSame (sid, security.GetOwner (typeof(SecurityIdentifier)));
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:17,代码来源:DirectoryObjectSecurityTest.cs


示例20: Create

        internal static IpcPort Create(String portName, CommonSecurityDescriptor securityDescriptor, bool exclusive)
        {
            if (Environment.OSVersion.Platform != PlatformID.Win32NT) {
                throw new NotSupportedException(CoreChannel.GetResourceString("Remoting_Ipc_Win9x"));
            }
            PipeHandle handle = null;
            // Add the prefix to the portName
            string pipeName = prefix + portName;
            SECURITY_ATTRIBUTES attr = new SECURITY_ATTRIBUTES();
            attr.nLength = (int)Marshal.SizeOf(attr);
            byte[] sd = null;
            // If no securityDescriptor was set by the user use the default
            if (securityDescriptor == null)
            {
                securityDescriptor = s_securityDescriptor;
            }

            sd = new byte[securityDescriptor.BinaryLength];
            // Get the binary form of the descriptor
            securityDescriptor.GetBinaryForm(sd, 0);
               
            GCHandle pinningHandle = GCHandle.Alloc(sd, GCHandleType.Pinned);
            // get the address of the security descriptor
            attr.lpSecurityDescriptor = Marshal.UnsafeAddrOfPinnedArrayElement(sd, 0);

            // Create the named pipe with the appropriate name
            handle = NativePipe.CreateNamedPipe(pipeName, 
                                      NativePipe.PIPE_ACCESS_DUPLEX  | NativePipe.FILE_FLAG_OVERLAPPED 
                                            | (exclusive ? NativePipe.FILE_FLAG_FIRST_PIPE_INSTANCE : 0x0), // Or exclusive flag 
                                      NativePipe.PIPE_TYPE_BYTE | NativePipe.PIPE_READMODE_BYTE | NativePipe.PIPE_WAIT,
                                      NativePipe.PIPE_UNLIMITED_INSTANCES,
                                      8192,
                                      8192,
                                      NativePipe.NMPWAIT_WAIT_FOREVER,
                                      attr); 

            pinningHandle.Free();
            if (handle.Handle.ToInt32() == NativePipe.INVALID_HANDLE_VALUE){
                int error = Marshal.GetLastWin32Error();
                throw new RemotingException(String.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Ipc_CreateIpcFailed"), GetMessage(error)));
            }

             return new IpcPort(portName, handle);   
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:44,代码来源:IpcPort.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# AccessControl.DirectorySecurity类代码示例发布时间:2022-05-26
下一篇:
C# Security.SecurityElement类代码示例发布时间: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