// // Constructs a SecurityIdentifier object from its string representation // Returns 'null' if string passed in is not a valid SID // NOTE: although there is a P/Invoke call involved in the implementation of this method, // there is no security risk involved, so no security demand is being made. // public SecurityIdentifier(string sddlForm) { ArgumentNullException.ThrowIfNull(sddlForm); // // Call into the underlying O/S conversion routine // int error = Win32.CreateSidFromString(sddlForm, out byte[]? resultSid); if (error == Interop.Errors.ERROR_INVALID_SID) { throw new ArgumentException(SR.Argument_InvalidValue, nameof(sddlForm)); } else if (error == Interop.Errors.ERROR_NOT_ENOUGH_MEMORY) { throw new OutOfMemoryException(); } else if (error != Interop.Errors.ERROR_SUCCESS) { Debug.Fail($"Win32.CreateSidFromString returned unrecognized error {error}"); throw new Win32Exception(error); } CreateFromBinaryForm(resultSid !, 0); }
// // Constructs a SecurityIdentifier object from its string representation // Returns 'null' if string passed in is not a valid SID // NOTE: although there is a P/Invoke call involved in the implementation of this method, // there is no security risk involved, so no security demand is being made. // public SecurityIdentifier(string sddlForm) { byte[] resultSid; // // Give us something to work with // if (sddlForm == null) { throw new ArgumentNullException(nameof(sddlForm)); } // // Call into the underlying O/S conversion routine // int Error = Win32.CreateSidFromString(sddlForm, out resultSid); if (Error == Interop.Errors.ERROR_INVALID_SID) { throw new ArgumentException(SR.Argument_InvalidValue, nameof(sddlForm)); } else if (Error == Interop.Errors.ERROR_NOT_ENOUGH_MEMORY) { throw new OutOfMemoryException(); } else if (Error != Interop.Errors.ERROR_SUCCESS) { Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.CreateSidFromString returned unrecognized error {0}", Error)); throw new SecurityException(string.Format(CultureInfo.InvariantCulture, "Win32.CreateSidFromString returned unrecognized error {0}", Error)); } CreateFromBinaryForm(resultSid, 0); }
public SecurityIdentifier(string sddlForm) { byte[] buffer; if (sddlForm == null) { throw new ArgumentNullException("sddlForm"); } int errorCode = Win32.CreateSidFromString(sddlForm, out buffer); switch (errorCode) { case 0x539: throw new ArgumentException(Environment.GetResourceString("Argument_InvalidValue"), "sddlForm"); case 8: throw new OutOfMemoryException(); } if (errorCode != 0) { throw new SystemException(Win32Native.GetMessage(errorCode)); } this.CreateFromBinaryForm(buffer, 0); }
public SecurityIdentifier(string sddlForm) { if (sddlForm == null) { throw new ArgumentNullException("sddlForm"); } byte[] binaryForm; int num = Win32.CreateSidFromString(sddlForm, out binaryForm); if (num == 1337) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidValue"), "sddlForm"); } if (num == 8) { throw new OutOfMemoryException(); } if (num != 0) { throw new SystemException(Win32Native.GetMessage(num)); } this.CreateFromBinaryForm(binaryForm, 0); }
[System.Security.SecuritySafeCritical] // auto-generated public SecurityIdentifier(string sddlForm) { byte[] resultSid; // // Give us something to work with // if (sddlForm == null) { throw new ArgumentNullException("sddlForm"); } Contract.EndContractBlock(); // // Call into the underlying O/S conversion routine // int Error = Win32.CreateSidFromString(sddlForm, out resultSid); if (Error == Win32Native.ERROR_INVALID_SID) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidValue"), "sddlForm"); } else if (Error == Win32Native.ERROR_NOT_ENOUGH_MEMORY) { throw new OutOfMemoryException(); } else if (Error != Win32Native.ERROR_SUCCESS) { Contract.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.CreateSidFromString returned unrecognized error {0}", Error)); throw new SystemException(Win32Native.GetMessage(Error)); } CreateFromBinaryForm(resultSid, 0); }