コード例 #1
0
        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);
            }
        }