public SecurityDescriptor( SecurityIdentifier owner, SecurityIdentifier group, AccessControlList dacl, AccessControlList sacl, SecurityDescriptorControl control) { // create security descriptor _pSd = CreateSecurityDescriptor( owner == null ? IntPtr.Zero : owner.Handle, group == null ? IntPtr.Zero : group.Handle, dacl == null ? IntPtr.Zero : dacl.Handle, sacl == null ? IntPtr.Zero : sacl.Handle, control); // query properties uint revision; uint controlFlags; if (!SecurityNative.GetSecurityDescriptorControl(_pSd, out controlFlags, out revision)) throw new Win32Exception(Marshal.GetLastWin32Error()); _revision = (int)revision; _control = (SecurityDescriptorControl)controlFlags; _owner = owner; _group = group; _dacl = dacl; _sacl = sacl; }
internal SecurityDescriptor(IntPtr pSd, bool copy) { // get security descriptor information IntPtr pOwner; IntPtr pGroup; IntPtr pDacl; IntPtr pSacl; SecurityDescriptorControl control; GetSecurityDescriptorInfo( pSd, out pOwner, out pGroup, out pDacl, out pSacl, out control); bool copyStructs; if (copy) { // create security descriptor _pSd = CreateSecurityDescriptor(pOwner, pGroup, pDacl, pSacl, control); copyStructs = true; } else { // store pointer _pSd = new LocalAllocHandle(pSd); copyStructs = (control & SecurityDescriptorControl.SelfRelative) != 0; } // query properties uint revision; uint controlFlags; if (!SecurityNative.GetSecurityDescriptorControl(_pSd, out controlFlags, out revision)) throw new Win32Exception(Marshal.GetLastWin32Error()); _revision = (int)revision; _control = (SecurityDescriptorControl)controlFlags; if (pOwner != IntPtr.Zero) _owner = new SecurityIdentifier(pOwner, copyStructs); if (pGroup != IntPtr.Zero) _group = new SecurityIdentifier(pGroup, copyStructs); if (pDacl != IntPtr.Zero) _dacl = new AccessControlList(pDacl, copyStructs); if (pSacl != IntPtr.Zero) _sacl = new AccessControlList(pSacl, copyStructs); }
public SecurityDescriptor(SecurityIdentifier owner, SecurityIdentifier group, AccessControlList dacl, AccessControlList sacl) : this(owner, group, dacl, sacl, 0) { }
public SecurityDescriptor(AccessControlList dacl) : this(null, null, dacl, null, 0) { }