internal override int BindSasl(SafeHandle ld, Native.LdapAuthType authType, LdapCredential ldapCredential) { LdapConnect(ld); var cred = ToNative(ldapCredential); return(NativeMethodsWindows.ldap_bind_s(ld, null, cred, Native.LdapAuthMechanism.ToBindMethod(authType))); }
internal override int BindSasl(SafeHandle ld, Native.LdapAuthType authType, LdapCredential ldapCredential) { var mech = Native.LdapAuthMechanism.FromAuthType(authType); var cred = ToNative(ld, mech, ldapCredential); var rc = NativeMethodsOsx.ldap_sasl_interactive_bind_s(ld, null, mech, IntPtr.Zero, IntPtr.Zero, (uint) Native.LdapInteractionFlags.LDAP_SASL_QUIET, UnixSaslMethods.SaslInteractionProcedure, cred); Marshal.FreeHGlobal(cred); return rc; }
internal override async Task <IntPtr> BindSaslAsync(SafeHandle ld, Native.LdapAuthType authType, LdapCredential ldapCredential) { LdapConnect(ld); var cred = ToNative(ldapCredential); var task = Task.Factory.StartNew(() => { ThrowIfError(NativeMethodsWindows.ldap_bind_s(ld, null, cred, Native.LdapAuthMechanism.ToBindMethod(authType)), nameof(NativeMethodsWindows.ldap_bind_s)); return(IntPtr.Zero); }); return(await task.ConfigureAwait(false)); }
internal override async Task <IntPtr> BindSaslAsync(SafeHandle ld, Native.LdapAuthType authType, LdapCredential ldapCredential, LDAP_TIMEVAL timeout) { var task = Task.Factory.StartNew(() => { int rc; var msgid = 0; var result = IntPtr.Zero; var rmech = IntPtr.Zero; var mech = Native.LdapAuthMechanism.FromAuthType(authType); var cred = ToNative(ld, mech, ldapCredential); var saslDefaults = Marshal.PtrToStructure <Native.LdapSaslDefaults>(cred); do { rc = NativeMethodsLinux.ldap_sasl_interactive_bind(ld, null, mech, IntPtr.Zero, IntPtr.Zero, (uint)Native.LdapInteractionFlags.LDAP_SASL_QUIET, UnixSaslMethods.SaslInteractionProcedure, cred, result, ref rmech, ref msgid); if (rc != (int)Native.ResultCode.SaslBindInProgress) { break; } ldap_msgfree(result); if (ldap_result(ld, msgid, 0, timeout, ref result) == Native.LdapResultType.LDAP_ERROR) { ThrowIfError(rc, nameof(NativeMethodsLinux.ldap_sasl_interactive_bind)); } if (result == IntPtr.Zero) { throw new LdapException(new LdapExceptionData("Result is not initialized", nameof(NativeMethodsLinux.ldap_sasl_interactive_bind), 1)); } } while (rc == (int)Native.ResultCode.SaslBindInProgress); Marshal.FreeHGlobal(cred); ThrowIfError(ld, rc, nameof(NativeMethodsLinux.ldap_sasl_interactive_bind), new Dictionary <string, string> { [nameof(saslDefaults)] = saslDefaults.ToString() }); return(result); }); return(await task.ConfigureAwait(false)); }
private static SEC_WINNT_AUTH_IDENTITY_EX GetCredentials(Native.LdapAuthType authType, LdapCredential ldapCredential) => authType == Native.LdapAuthType.External ? null : ToNative(ldapCredential);