Open Closed

How to prevent assigning a user to multiple Organization Units #1977

bozkan created
  • ABP Framework version: v4.4.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

We have a requirement to prevent assigning a user to multiple OU's. A user should only be a member of single group. Is there a way to achieve this?

1 Answer(s)
  • 1
    EngincanV created
    Support Team

    Hi @bozkan, you can override the AddToOrganizationUnitAsync method of IdentityUserManager class and inside of the method simply check the user is in any organization unit or not.

    • You can implement something similar with the following code.
    public async override Task AddToOrganizationUnitAsync(IdentityUser user, OrganizationUnit ou)
        if (user.OrganizationUnits.Any())
        base.AddToOrganizationUnitAsync(user, ou);
    • To overriding IdentityUserManager, see