/// <summary> /// Convert an SDDL SID string to a Sid /// </summary> /// <param name="sddl">The SDDL SID string</param> /// <returns>The converted Sid</returns> /// <exception cref="NtException">Thrown if cannot convert from a SDDL string.</exception> public static Sid SidFromSddl(string sddl) { if (!Win32NativeMethods.ConvertStringSidToSid(sddl, out SafeLocalAllocHandle handle)) { throw new NtException(NtObjectUtils.MapDosErrorToStatus()); } using (handle) { return(new Sid(handle.DangerousGetHandle())); } }
/// <summary> /// Convert an SDDL SID string to a Sid /// </summary> /// <param name="sddl">The SDDL SID string</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The converted Sid</returns> /// <exception cref="NtException">Thrown if cannot convert from a SDDL string.</exception> public static NtResult <Sid> SidFromSddl(string sddl, bool throw_on_error) { if (!Win32NativeMethods.ConvertStringSidToSid(sddl, out SafeLocalAllocHandle handle)) { return(NtObjectUtils.MapDosErrorToStatus().CreateResultFromError <Sid>(throw_on_error)); } using (handle) { return(new Sid(handle.DangerousGetHandle()).CreateResult()); } }
/// <summary> /// Convert an SDDL SID string to a Sid /// </summary> /// <param name="sddl">The SDDL SID string</param> /// <returns>The converted Sid</returns> /// <exception cref="NtException">Thrown if cannot convert from a SDDL string.</exception> public static Sid SidFromSddl(string sddl) { if (!Win32NativeMethods.ConvertStringSidToSid(sddl, out SafeLocalAllocHandle handle)) { throw new NtException(NtStatus.STATUS_INVALID_SID); } using (handle) { return(new Sid(handle.DangerousGetHandle())); } }