Пример #1
0
        internal static int CreateSidFromString(string stringSid, out byte[] resultSid)
        {
            IntPtr ByteArray = IntPtr.Zero;
            int    lastWin32Error;

            try
            {
                if (1 != Win32Native.ConvertStringSidToSid(stringSid, out ByteArray))
                {
                    lastWin32Error = Marshal.GetLastWin32Error();
                    goto label_6;
                }
                else
                {
                    resultSid = System.Security.Principal.Win32.ConvertIntPtrSidToByteArraySid(ByteArray);
                }
            }
            finally
            {
                Win32Native.LocalFree(ByteArray);
            }
            return(0);

label_6:
            resultSid = (byte[])null;
            return(lastWin32Error);
        }
Пример #2
0
        internal static int CreateSidFromString(string stringSid, out byte[] resultSid)
        {
            IntPtr zero = IntPtr.Zero;

            try
            {
                if (1 != Win32Native.ConvertStringSidToSid(stringSid, out zero))
                {
                    int num = Marshal.GetLastWin32Error();
                    resultSid = null;
                    return(num);
                }
                resultSid = ConvertIntPtrSidToByteArraySid(zero);
            }
            finally
            {
                Win32Native.LocalFree(zero);
            }
            return(0);
        }
Пример #3
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static int CreateSidFromString(
            string stringSid,
            out byte[] resultSid
            )
        {
            int    ErrorCode;
            IntPtr ByteArray = IntPtr.Zero;

            try
            {
                if (TRUE != Win32Native.ConvertStringSidToSid(stringSid, out ByteArray))
                {
                    ErrorCode = Marshal.GetLastWin32Error();
                    goto Error;
                }

                resultSid = ConvertIntPtrSidToByteArraySid(ByteArray);
            }
            finally
            {
                //
                // Now is a good time to get rid of the returned pointer
                //

                Win32Native.LocalFree(ByteArray);
            }

            //
            // Now invoke the SecurityIdentifier factory method to create the result
            //

            return(Win32Native.ERROR_SUCCESS);

Error:

            resultSid = null;
            return(ErrorCode);
        }