private async Task CreateUser(LoginViewModel model) { LDAP ldap = new LDAP(); LDAP_result ldapResult = ldap.SearchUser(model.UserName, model.Password); LDAP_user ldapUser = ldap.GetUserData(ldapResult.Result); User user = new User() { UserName = model.UserName, FirstName = ldapUser.FirstName, LastName = ldapUser.LastName, Email = ldapUser.mail, LockoutEnabled = false, PhoneNumber = ldapUser.mobile }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, DefRoles.USER); } else { AddErrors(result); } }
private bool IsAuthenticatedByLdap(LoginViewModel model) { LDAP ldap = new LDAP(); LDAP_result ldapResult = ldap.SearchUser(model.UserName, model.Password); return(ldapResult.Status == LDAP_ResponseStatus.Authenticated); }