/// <summary> /// Checks the given password agains the configured LDAP server. /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public override async Task <bool> CheckPasswordAsync(TUser user, string password) { using (var auth = new LdapAuthentication(_ldapOptions)) { string dn; // This gives a custom way to extract the DN from the user if it is different from the username. // It seems more like this would be a feature of the user store, but we can't get user store from userManager // and all the methods we really need for sign-in are on user manager. if (this.Store is IUserLdapStore <TUser> ) { dn = await((IUserLdapStore <TUser>) this.Store).GetDistinguishedNameAsync(user); } else { dn = await this.Store.GetNormalizedUserNameAsync(user, CancellationToken.None); } if (auth.ValidatePassword(dn, password)) { return(true); } } return(false); }
/// <summary> /// Checks the given password agains the configured LDAP server. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public bool PasswordSignIn(string username, string password) { using (var auth = new LdapAuthentication(_ldapOptions)) { if (auth.ValidatePassword(username, password)) { return(true); } } return(false); }