Base solution for your next web application
Open Closed

Assigning users to Organisational Units (OU) #6207


User avatar
0
kimoerum created

Hello,

I am trying to use OU (Organisational Units) to control the results from an entity lists. (Ex. "See only Tennants assigned to your OU" )

Here I realize, that when I want need to add a user to an OU (by clicking the checkbox), ALL OU checkboxes on the levels above to OU that I want to assig, is also beeing checked automatically... And if I uncheck those above, all OU's below i also unchecked.

I don't think the current default behaviour is the "best chooice" in this case for the OU's. I would for this usecase prefere, that only the one OU I do select is beeing checked.

Is there a way that I can get this configured to reach my goal?

Thanks in advance.


9 Answer(s)
  • User Avatar
    1
    maliming created
    Support Team

    What version? MVC or Angular, Core or .NET Framework?

  • User Avatar
    0
    kimoerum created

    Sorry,

    6.4.01 (Latest) CORE, MVC

  • User Avatar
    0
    ismcagdas created
    Support Team

    Here I realize, that when I want need to add a user to an OU (by clicking the checkbox), ALL OU checkboxes on the levels above to OU that I want to assig, is also beeing checked automatically... And if I uncheck those above, all OU's below i also unchecked.

    @kimoerum could you share a screenshot of this ?

    Thanks.

  • User Avatar
    0
    kimoerum created

    Sure,

    My objective is that a user that belongs to "Company B" can ONLY see entities that is marked with that OU id. A user that is in the "Norway" can see all entities from "Company A, B and C"

    And as a animation:

  • User Avatar
    0
    ismcagdas created
    Support Team

    My objective is that a user that belongs to "Company B" can ONLY see entities that is marked with that OU id

    Filtering by OU is not implemented in ABP an AspNet Zero. So, you need to implement it yourself.

    OU tree doesn't work like that way. If you want to use OUs for this purpuse, you need to modify the code according to your needs.

    After doing that, you can either filter the records manually by using the current user's OuId or you can create a custom data filter, see https://aspnetboilerplate.com/Pages/Documents/Data-Filters

    But, this is not documented for EF Core, so you need to invetigate the source code ABP Framework. You can check the definition and usage of IMayHaveTenant filter.

  • User Avatar
    0
    kimoerum created

    @ismcagdas

    Thanks for your clearification - and hints it's very helpfull. And I am aware about most of what you try to explain.

    But this was not the question - sorry to say. My question was aiming at the point where you create a user and assign him to the OU. If you here has a multilevel OU structure (as in my example posted) and you assign the user to the bottom level - ASP.NET Zero will per default "assign" him to all levels above also. And I do question the functionality at this point, as this seems for me to be wrong when we look at OU's! So my question was: Is there a way that the user may only be included in the OU I select - and nothing else?

    By the way, if you enter the OU admin you may this way add a user to a specefic OU only.. so that is my current workaround - but that is not the best way of manageing this.

    I am sorry that we have to take this "de tour" on this question - but please try to read my initial post once more and focus only on what I am asking for here - the assignments of a user to an OU nothing more nothing else - thanks in advance.

  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, OU is designed in that way.

    e.g an employee that is in charge of pay roll should be under HR department.

    Your case sounds like you should be looking atRole instead.

    However, if you still want to proceed with OU without having all the higher level OU being checked, you can modify the UI code to do so. Currently there isn't any logic that do the checking in the app service.

  • User Avatar
    0
    kimoerum created

    Hi @ryancyq

    Thanks for your reply and explanation, but I am not sure that I agree with your point of view.

    Please have a look here Common Use Cases

    For the described use case to make sense, you sould only assign the user to one level in the OU tree - at least in my application that makes sense, and I agree that it may differ depending on your use case.

    And no - a ROLE is not what solves my usecase - please again refere to the link and use case above.

    But however I sorted out what I need to do in the UI code to obtain the behaviour that I was asking for:

    In the script _OrganizationTree.js I just needed to uncomment the line in the eventhandler section: selectNodeAndAllParents(...);

    Thanks for all the input.

  • User Avatar
    0
    GSOFT created

    Hi @kimoerum You should try to modify your database, create new column (Department ID/ Company ID) in your User Table and pass Department ID like a param to your search method. Originally I also think like you, try to relate OU and branch (in my project) and It did not go anywhere.