/// <summary> /// Delete user /// </summary> /// <param name="distinguishedName"></param> /// <returns></returns> public override async Task <IdentityResult> DeleteUserAsync(string distinguishedName) { try { LdapService.DeleteUser(distinguishedName); } catch (Exception e) { return(await Task.FromResult(IdentityResult.Failed(new IdentityError() { Code = "LdapUserDeleteFailed", Description = e.Message ?? "The user could not be deleted." }))); } return(await Task.FromResult(IdentityResult.Success)); }
/// <inheritdoc /> /// <summary> /// Create user /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public override async Task <IdentityResult> CreateAsync(TLdapUser user, string password) { try { LdapService.AddUser(user, password); } catch (Exception e) { return(await Task.FromResult(IdentityResult.Failed(new IdentityError() { Code = "LdapUserCreateFailed", Description = e.Message ?? "The user could not be created." }))); } return(await Task.FromResult(IdentityResult.Success)); }
/// <inheritdoc /> /// <summary> /// Checks the given password again the configured LDAP server. /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public override Task <bool> CheckPasswordAsync(TLdapUser user, string password) { return(Task.Run(() => LdapService.Authenticate(user.DistinguishedName, password))); }
/// <inheritdoc /> /// <summary> /// Find user by name /// </summary> /// <param name="userName"></param> /// <returns></returns> public override Task <TLdapUser> FindByNameAsync(string userName) { return(Task.FromResult(LdapService.GetUserByUserName(userName))); }
/// <summary> /// Get Administrator /// </summary> /// <returns></returns> public override LdapUser GetAdministrator() { return(LdapService.GetAdministrator()); }