public static unsafe int AcquireCredentialsHandle(string package, CredentialUse intent, ref SecureCredential authdata, out SafeFreeCredentials outCredential)
 {
     int num = -1;
     IntPtr certContextArray = authdata.certContextArray;
     try
     {
         IntPtr ptr2 = new IntPtr((void*) &certContextArray);
         if (certContextArray != IntPtr.Zero)
         {
             authdata.certContextArray = ptr2;
         }
         outCredential = new SafeFreeCredentials();
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
         }
         finally
         {
             long num2;
             num = AcquireCredentialsHandleW(null, package, (int) intent, null, ref authdata, null, null, ref outCredential._handle, out num2);
             if (num != 0)
             {
                 outCredential.SetHandleAsInvalid();
             }
         }
     }
     finally
     {
         authdata.certContextArray = certContextArray;
     }
     return num;
 }
Exemple #2
0
        public static unsafe int AcquireCredentialsHandle(string package, CredentialUse intent, ref SecureCredential authdata, out SafeFreeCredentials outCredential)
        {
            int    num = -1;
            IntPtr certContextArray = authdata.certContextArray;

            try
            {
                IntPtr ptr2 = new IntPtr((void *)&certContextArray);
                if (certContextArray != IntPtr.Zero)
                {
                    authdata.certContextArray = ptr2;
                }
                outCredential = new SafeFreeCredentials();
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                }
                finally
                {
                    long num2;
                    num = AcquireCredentialsHandleW(null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out num2);
                    if (num != 0)
                    {
                        outCredential.SetHandleAsInvalid();
                    }
                }
            }
            finally
            {
                authdata.certContextArray = certContextArray;
            }
            return(num);
        }
 public static int AcquireCredentialsHandle(string package, CredentialUse intent, ref IntPtr ppAuthIdentity, out SafeFreeCredentials outCredential)
 {
     int num = -1;
     outCredential = new SafeFreeCredentials();
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
     }
     finally
     {
         long num2;
         num = AcquireCredentialsHandleW(null, package, (int) intent, null, ppAuthIdentity, null, null, ref outCredential._handle, out num2);
         if (num != 0)
         {
             outCredential.SetHandleAsInvalid();
         }
     }
     return num;
 }
Exemple #4
0
        public static int AcquireCredentialsHandle(string package, CredentialUse intent, ref IntPtr ppAuthIdentity, out SafeFreeCredentials outCredential)
        {
            int num = -1;

            outCredential = new SafeFreeCredentials();
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                long num2;
                num = AcquireCredentialsHandleW(null, package, (int)intent, null, ppAuthIdentity, null, null, ref outCredential._handle, out num2);
                if (num != 0)
                {
                    outCredential.SetHandleAsInvalid();
                }
            }
            return(num);
        }
        //This method should never be called for this type
        //public new IntPtr DangerousGetHandle()
        //{
        //    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException());
        //}

        public static unsafe int AcquireCredentialsHandle(
            string package,
            CredentialUse intent,
            ref AuthIdentityEx authdata,
            out SafeFreeCredentials outCredential)
        {
            int errorCode = -1;
            long timeStamp;

            outCredential = new SafeFreeCredentials();
            RuntimeHelpers.PrepareConstrainedRegions();
            try { }
            finally
            {
                // PreSharp Bug: Call 'Marshal.GetLastWin32Error' or 'Marshal.GetHRForLastWin32Error' before any other interop call. 
#pragma warning suppress 56523 // The API does not set Win32 Last Error. It returns a error code.
                errorCode = AcquireCredentialsHandleW(
                    null,
                    package,
                    (int)intent,
                    null,
                    ref authdata,
                    null,
                    null,
                    ref outCredential._handle,
                    out timeStamp
                    );
                if (errorCode != 0)
                {
                    outCredential.SetHandleAsInvalid();
                }
            }
            return errorCode;
        }
        public static unsafe int AcquireCredentialsHandle(
            string package,
            CredentialUse intent,
            ref SecureCredential authdata,
            out SafeFreeCredentials outCredential)
        {
            int errorCode = -1;
            long timeStamp;

            // If there is a certificate, wrap it into an array
            IntPtr copiedPtr = authdata.certContextArray;
            try
            {
                IntPtr certArrayPtr = new IntPtr(&copiedPtr);
                if (copiedPtr != IntPtr.Zero)
                {
                    authdata.certContextArray = certArrayPtr;
                }

                outCredential = new SafeFreeCredentials();
                RuntimeHelpers.PrepareConstrainedRegions();
                try { }
                finally
                {
                    // PreSharp Bug: Call 'Marshal.GetLastWin32Error' or 'Marshal.GetHRForLastWin32Error' before any other interop call. 
#pragma warning suppress 56523 // The API does not set Win32 Last Error. It returns a error code.
                    errorCode = AcquireCredentialsHandleW(
                                    null,
                                    package,
                                    (int)intent,
                                    null,
                                    ref authdata,
                                    null,
                                    null,
                                    ref outCredential._handle,
                                    out timeStamp
                                    );
                    if (errorCode != 0)
                    {
                        outCredential.SetHandleAsInvalid();
                    }
                }
            }
            finally
            {
                authdata.certContextArray = copiedPtr;
            }

            return errorCode;
        }