Hi,
How we can get the data which has MustHaveOrganisationId including child OU, added a custom filter for OU filter, but we need to get the data only under OU and sub OU which user has permission.
Thanks.
5 Answer(s)
-
0
Hi @mujthabagroad
Instead of using OrganizationId, you can use Code field or Organization unit and do a query like below:
_repository.GetAll().Where(e=> e.Code.StartsWith(filteredOuCode))
Organization unit codes are generated according to level of OUs. So if an OU has the code 0001, its children will have 0001.0001, 0001.0002 etc... as the code.
-
0
Hi @ismcagdas,
yes we can get the children with this, but I need to get only OUs and Sub OUs which is assigned to the user or role in the permission and data filter should apply based on all permitted OUs
Thanks.
-
0
Hi,
Not sure if you need permission here (since your data is permitted via OU Id)
Nonetheless, you can get the permitted OU Ids as follows:
- get ou ids of the current user
- get role ids of current user
- get ou ids base on the role ids in (2)
The permitted OU ids should be (1) + (2)
-
0
Hi @ryancyq,
Thanks for your response, That is possible if we do a manual query and we need to do for all entities to get filtered, but my aim was to add as data filters for all entities. My scenario is:
- We have Parent OU as Business Entity Office and Sub OU as Divisions, in an office will have multiple divisions
- The user will have only one or more division access based on permission.
- In all grid, data should be filtered and shown only which user has OU permissions
- Should show all data without filtering if we are not setting any OU permissions for the user
For this, we added MustHaveOrganizationUnit for all entities and we have OU id in all tables. Now we need to add data filters for all tables to filter the data based on WHERE IN permitted OU.
Thanks.
-
0
Hi, if you want to implement it as data filter, you can refer to the doc for it. See https://aspnetboilerplate.com/Pages/Documents/Data-Filters
However, do note that evaluating current user PERMITTED OU ids might be too expensive to be calculated for every query, you might want to consider caching it.