public static unsafe int AcquireCredentialsHandle(SecurDll dll, string package, CredentialUse intent, ref SecureCredential authdata, out SafeFreeCredentials outCredential) { int num = -1; IntPtr certContextArray = authdata.certContextArray; try { long num2; IntPtr ptr2 = new IntPtr((void *)&certContextArray); if (certContextArray != IntPtr.Zero) { authdata.certContextArray = ptr2; } switch (dll) { case SecurDll.SECURITY: outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_00C5; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW(null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } break; case SecurDll.SCHANNEL: break; default: goto Label_0093; } outCredential = new SafeFreeCredential_SCHANNEL(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_00C5; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SCHANNEL.AcquireCredentialsHandleA(null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } Label_0093 :; throw new ArgumentException(SR.GetString("net_invalid_enum", new object[] { "SecurDll" }), "Dll"); } finally { authdata.certContextArray = certContextArray; } Label_00C5: if (num != 0) { outCredential.SetHandleAsInvalid(); } return(num); }
public static unsafe int AcquireCredentialsHandle(SecurDll dll, string package, CredentialUse intent, ref SecureCredential authdata, out SafeFreeCredentials outCredential) { int num = -1; IntPtr certContextArray = authdata.certContextArray; try { long num2; IntPtr ptr2 = new IntPtr((void*) &certContextArray); if (certContextArray != IntPtr.Zero) { authdata.certContextArray = ptr2; } switch (dll) { case SecurDll.SECURITY: outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_00C5; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW(null, package, (int) intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } break; case SecurDll.SCHANNEL: break; default: goto Label_0093; } outCredential = new SafeFreeCredential_SCHANNEL(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_00C5; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SCHANNEL.AcquireCredentialsHandleA(null, package, (int) intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } Label_0093:; throw new ArgumentException(SR.GetString("net_invalid_enum", new object[] { "SecurDll" }), "Dll"); } finally { authdata.certContextArray = certContextArray; } Label_00C5: if (num != 0) { outCredential.SetHandleAsInvalid(); } return num; }
public static int AcquireCredentialsHandle(SecurDll dll, string package, CredentialUse intent, ref AuthIdentity authdata, out SafeFreeCredentials outCredential) { long num2; int num = -1; switch (dll) { case SecurDll.SECURITY: outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_008D; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW(null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } break; case SecurDll.SECUR32: break; default: goto Label_0068; } outCredential = new SafeFreeCredential_SECUR32(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_008D; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SECUR32.AcquireCredentialsHandleA(null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } Label_0068 :; throw new ArgumentException(SR.GetString("net_invalid_enum", new object[] { "SecurDll" }), "Dll"); Label_008D: if (num != 0) { outCredential.SetHandleAsInvalid(); } return(num); }
public static int AcquireCredentialsHandle(SecurDll dll, string package, CredentialUse intent, ref AuthIdentity authdata, out SafeFreeCredentials outCredential) { long num2; int num = -1; switch (dll) { case SecurDll.SECURITY: outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_008D; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW(null, package, (int) intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } break; case SecurDll.SECUR32: break; default: goto Label_0068; } outCredential = new SafeFreeCredential_SECUR32(); RuntimeHelpers.PrepareConstrainedRegions(); try { goto Label_008D; } finally { num = UnsafeNclNativeMethods.SafeNetHandles_SECUR32.AcquireCredentialsHandleA(null, package, (int) intent, null, ref authdata, null, null, ref outCredential._handle, out num2); } Label_0068:; throw new ArgumentException(SR.GetString("net_invalid_enum", new object[] { "SecurDll" }), "Dll"); Label_008D: if (num != 0) { outCredential.SetHandleAsInvalid(); } return num; }
public unsafe static int AcquireCredentialsHandle( SecurDll dll, string package, CredentialUse intent, ref SecureCredential authdata, out SafeFreeCredentials outCredential ) { GlobalLog.Print("SafeFreeCredentials::AcquireCredentialsHandle#2(" + dll + "," + package + ", " + intent + ", " + authdata + ")" ); int errorCode = -1; long timeStamp; // If there is a certificate, wrap it into an array. // Not threadsafe. IntPtr copiedPtr = authdata.certContextArray; try { IntPtr certArrayPtr = new IntPtr(&copiedPtr); if (copiedPtr != IntPtr.Zero) { authdata.certContextArray = certArrayPtr; } switch (dll) { case SecurDll.SECURITY: outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { errorCode = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW( null, package, (int)intent, null, ref authdata, null, null, ref outCredential._handle, out timeStamp ); } break; default: throw new ArgumentException(SR.GetString(SR.net_invalid_enum, "SecurDll"), "Dll"); } } finally { authdata.certContextArray = copiedPtr; } #if TRAVE GlobalLog.Print("Unmanaged::AcquireCredentialsHandle() returns 0x" + errorCode.ToString("x") + ", handle = " + outCredential.ToString() ); #endif if (errorCode != 0) { outCredential.SetHandleAsInvalid(); } return errorCode; }
// This overload is only called on Win7+ where SspiEncodeStringsAsAuthIdentity() was used to // create the authData blob. public unsafe static int AcquireCredentialsHandle( string package, CredentialUse intent, ref SafeSspiAuthDataHandle authdata, out SafeFreeCredentials outCredential ) { int errorCode = -1; long timeStamp; outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { errorCode = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW( null, package, (int)intent, null, authdata, null, null, ref outCredential._handle, out timeStamp ); } if (errorCode != 0) { outCredential.SetHandleAsInvalid(); } return errorCode; }
public unsafe static int AcquireDefaultCredential( SecurDll dll, string package, CredentialUse intent, out SafeFreeCredentials outCredential ) { GlobalLog.Print("SafeFreeCredentials::AcquireDefaultCredential(" + dll + "," + package + ", " + intent + ")" ); int errorCode = -1; long timeStamp; switch (dll) { case SecurDll.SECURITY: outCredential = new SafeFreeCredential_SECURITY(); RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { errorCode = UnsafeNclNativeMethods.SafeNetHandles_SECURITY.AcquireCredentialsHandleW( null, package, (int)intent, null, IntPtr.Zero, null, null, ref outCredential._handle, out timeStamp ); } break; default: throw new ArgumentException(SR.GetString(SR.net_invalid_enum, "SecurDll"), "Dll"); } #if TRAVE GlobalLog.Print("Unmanaged::AcquireCredentialsHandle() returns 0x" + errorCode.ToString("x") + ", handle = " + outCredential.ToString() ); #endif if (errorCode != 0) { outCredential.SetHandleAsInvalid(); } return errorCode; }