public static unsafe int AcquireDefaultCredential( string package, Interop.SspiCli.CredentialUse intent, out SafeFreeCredentials outCredential) { int errorCode = -1; long timeStamp; outCredential = new SafeFreeCredential_SECURITY(); errorCode = Interop.SspiCli.AcquireCredentialsHandleW( null, package, (int)intent, null, IntPtr.Zero, null, null, ref outCredential._handle, out timeStamp); if (NetEventSource.Log.IsEnabled()) { NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}"); } if (errorCode != 0) { outCredential.SetHandleAsInvalid(); } return(errorCode); }
public static unsafe int AcquireCredentialsHandle( string package, Interop.SspiCli.CredentialUse intent, Interop.SspiCli.SCH_CREDENTIALS *authdata, out SafeFreeCredentials outCredential) { long timeStamp; outCredential = new SafeFreeCredential_SECURITY(); int errorCode = Interop.SspiCli.AcquireCredentialsHandleW( null, package, (int)intent, null, authdata, null, null, ref outCredential._handle, out timeStamp); if (NetEventSource.IsEnabled) { NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}"); } if (errorCode != 0) { outCredential.SetHandleAsInvalid(); } return(errorCode); }
public static unsafe int AcquireCredentialsHandle( string package, Interop.SspiCli.CredentialUse intent, ref Interop.SspiCli.SCHANNEL_CRED authdata, out SafeFreeCredentials outCredential) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Enter(null, package, intent, authdata); } int errorCode = -1; long timeStamp; // If there is a certificate, wrap it into an array. // Not threadsafe. IntPtr copiedPtr = authdata.paCred; try { IntPtr certArrayPtr = new IntPtr(&copiedPtr); if (copiedPtr != IntPtr.Zero) { authdata.paCred = certArrayPtr; } outCredential = new SafeFreeCredential_SECURITY(); errorCode = Interop.SspiCli.AcquireCredentialsHandleW( null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out timeStamp); } finally { authdata.paCred = copiedPtr; } if (NetEventSource.Log.IsEnabled()) { NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}"); } if (errorCode != 0) { outCredential.SetHandleAsInvalid(); } return(errorCode); }