當前位置: 首頁>>代碼示例>>C#>>正文


C# FileSecurity.GetSecurityDescriptorBinaryForm方法代碼示例

本文整理匯總了C#中System.Security.AccessControl.FileSecurity.GetSecurityDescriptorBinaryForm方法的典型用法代碼示例。如果您正苦於以下問題:C# FileSecurity.GetSecurityDescriptorBinaryForm方法的具體用法?C# FileSecurity.GetSecurityDescriptorBinaryForm怎麽用?C# FileSecurity.GetSecurityDescriptorBinaryForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Security.AccessControl.FileSecurity的用法示例。


在下文中一共展示了FileSecurity.GetSecurityDescriptorBinaryForm方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetSecAttrs

 private static unsafe Win32Native.SECURITY_ATTRIBUTES GetSecAttrs(FileShare share, FileSecurity fileSecurity, out object pinningHandle)
 {
     pinningHandle = null;
     Win32Native.SECURITY_ATTRIBUTES structure = null;
     if (((share & FileShare.Inheritable) != FileShare.None) || (fileSecurity != null))
     {
         structure = new Win32Native.SECURITY_ATTRIBUTES {
             nLength = Marshal.SizeOf(structure)
         };
         if ((share & FileShare.Inheritable) != FileShare.None)
         {
             structure.bInheritHandle = 1;
         }
         if (fileSecurity == null)
         {
             return structure;
         }
         byte[] securityDescriptorBinaryForm = fileSecurity.GetSecurityDescriptorBinaryForm();
         pinningHandle = GCHandle.Alloc(securityDescriptorBinaryForm, GCHandleType.Pinned);
         fixed (byte* numRef = securityDescriptorBinaryForm)
         {
             structure.pSecurityDescriptor = numRef;
         }
     }
     return structure;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:26,代碼來源:FileStream.cs

示例2: GetSecAttrs

        // If pinningHandle is not null, caller must free it AFTER the call to
        // CreateFile has returned.
        //
        // [....]: Copied this from System.IO.FileStream
        //
        private static unsafe SECURITY_ATTRIBUTES GetSecAttrs(
            FileShare share,
            FileSecurity fileSecurity,
            out object pinningHandle)
        {
            pinningHandle = null;
            SECURITY_ATTRIBUTES secAttrs = null;
            if ((share & FileShare.Inheritable) != 0 || fileSecurity != null)
            {
                secAttrs = new SECURITY_ATTRIBUTES();
                secAttrs.nLength = (int)Marshal.SizeOf(secAttrs);

                if ((share & FileShare.Inheritable) != 0)
                {
                    secAttrs.bInheritHandle = 1;
                }

                // For ACLs, get the security descriptor from the FileSecurity.
                if (fileSecurity != null)
                {
                    byte[] sd = fileSecurity.GetSecurityDescriptorBinaryForm();
                    pinningHandle = GCHandle.Alloc(sd, GCHandleType.Pinned);
                    fixed (byte* pSecDescriptor = sd)
                        secAttrs.pSecurityDescriptor = pSecDescriptor;
                }
            }
            return secAttrs;
        }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:33,代碼來源:LogStore.cs


注:本文中的System.Security.AccessControl.FileSecurity.GetSecurityDescriptorBinaryForm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。