4

How to give the LDAP account the default role, now the LDAP account login default role is admin

Integrated LDAP login in the abp framework

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;
    }
}
TotPeRo
  • 6,561
  • 4
  • 47
  • 60
chinasky
  • 41
  • 1

0 Answers0