本文整理匯總了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;
}
示例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;
}