예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
 /// <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)));
 }
예제 #4
0
 /// <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)));
 }
예제 #5
0
 /// <summary>
 /// Get Administrator
 /// </summary>
 /// <returns></returns>
 public override LdapUser GetAdministrator()
 {
     return(LdapService.GetAdministrator());
 }