ABP框架中的集成LDAP登录

时间:2019-07-08 06:24:10

标签: ldap abp

如何赋予LDAP帐户默认角色,现在LDAP帐户登录默认角色是admin

apb框架中的集成LDAP登录

public async override Task<User> CreateUserAsync(string userNameOrEmailAddress, Tenant tenant)
{
    await CheckIsEnabled(tenant);

    var user = await base.CreateUserAsync(userNameOrEmailAddress, tenant);

    using (var principalContext = await CreatePrincipalContext(tenant))
    {
        var userPrincipal = UserPrincipal.FindByIdentity(principalContext, userNameOrEmailAddress);

        if (userPrincipal == null)
        {
            throw new AbpException("Unknown LDAP user: " + userNameOrEmailAddress);
        }

        UpdateUserFromPrincipal(user, userPrincipal);

        user.IsEmailConfirmed = true;
        user.IsActive = true;


        return user;
    }
}

0 个答案:

没有答案