static private ConvertSdToSddl ( byte binaryForm, int requestedRevision, SecurityInfos si, string &resultSddl ) : int | ||
binaryForm | byte | |
requestedRevision | int | |
si | SecurityInfos | |
resultSddl | string | |
리턴 | int |
public string GetSddlForm(AccessControlSections includeSections) { byte[] binaryForm = new byte[this.BinaryLength]; this.GetBinaryForm(binaryForm, 0); SecurityInfos securityInfos = (SecurityInfos)0; if ((includeSections & AccessControlSections.Owner) != AccessControlSections.None) { securityInfos |= SecurityInfos.Owner; } if ((includeSections & AccessControlSections.Group) != AccessControlSections.None) { securityInfos |= SecurityInfos.Group; } if ((includeSections & AccessControlSections.Audit) != AccessControlSections.None) { securityInfos |= SecurityInfos.SystemAcl; } if ((includeSections & AccessControlSections.Access) != AccessControlSections.None) { securityInfos |= SecurityInfos.DiscretionaryAcl; } string result; int num = Win32.ConvertSdToSddl(binaryForm, 1, securityInfos, out result); if (num == 87 || num == 1305) { throw new InvalidOperationException(); } if (num != 0) { throw new InvalidOperationException(); } return(result); }
// // Converts the security descriptor to its SDDL form // public string GetSddlForm(AccessControlSections includeSections) { byte[] binaryForm = new byte[BinaryLength]; string resultSddl; int error; GetBinaryForm(binaryForm, 0); SecurityInfos flags = 0; if ((includeSections & AccessControlSections.Owner) != 0) { flags |= SecurityInfos.Owner; } if ((includeSections & AccessControlSections.Group) != 0) { flags |= SecurityInfos.Group; } if ((includeSections & AccessControlSections.Audit) != 0) { flags |= SecurityInfos.SystemAcl; } if ((includeSections & AccessControlSections.Access) != 0) { flags |= SecurityInfos.DiscretionaryAcl; } error = Win32.ConvertSdToSddl(binaryForm, 1, flags, out resultSddl); if (error == Interop.Errors.ERROR_INVALID_PARAMETER || error == Interop.Errors.ERROR_UNKNOWN_REVISION) { // // Indicates that the marshaling logic in GetBinaryForm is busted // Debug.Assert(false, "binaryForm produced invalid output"); throw new InvalidOperationException(); } else if (error != Interop.Errors.ERROR_SUCCESS) { Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.ConvertSdToSddl returned {0}", error)); throw new InvalidOperationException(); } return(resultSddl); }
public string GetSddlForm(AccessControlSections includeSections) { byte[] binaryForm = new byte[this.BinaryLength]; this.GetBinaryForm(binaryForm, 0); SecurityInfos si = (SecurityInfos)0; if ((includeSections & AccessControlSections.Owner) != AccessControlSections.None) { si |= SecurityInfos.Owner; } if ((includeSections & AccessControlSections.Group) != AccessControlSections.None) { si |= SecurityInfos.Group; } if ((includeSections & AccessControlSections.Audit) != AccessControlSections.None) { si |= SecurityInfos.SystemAcl; } if ((includeSections & AccessControlSections.Access) != AccessControlSections.None) { si |= SecurityInfos.DiscretionaryAcl; } string resultSddl; switch (Win32.ConvertSdToSddl(binaryForm, 1, si, out resultSddl)) { case 87: case 1305: throw new InvalidOperationException(); case 0: return(resultSddl); default: throw new InvalidOperationException(); } }