ACLs / Security rules should not have GlideRecord/GlideAggregate in script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2019 12:58 AM
Hi,
I want to avoid database lookups in Access Control rules. Please check the below script. Can we update the code differently (without GlideRecord queries)?
see below script:
var check=false;
var gr=new GlideRecord("sys_user_group");
gr.addEncodedQuery("name=test1^ORparent=123xxxxx789^ORname=test2");
gr.query();
while(gr.next())
{
if(gs.getUser().isMemberOf(gr.sys_id))
{
check=true;
break;
}
}
answer=check;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2019 01:03 AM
Hi
The script is going to check if the logged in user is member of the queried groups, instead you can put the name there somthing like this -
gs.getUser().isMemberOf("test1"); or condition in if like this.
Hope this helps.
Regards
Omkar Mone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2019 01:13 AM
Hi Omkar,
How can I search group name using group Parent without using GlideRecord??
For example,
Parent group - P1
Associated child group - C1,C2,C3
is this possible??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2019 01:19 AM
Hi
You can get all the groups that current logged in user with this-
var groups = gs.getUser().getMyGroups();
The if you want you can check with the sys_id of the parent if user belongs to that group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2019 02:12 AM
Hi Omkar,
my require here is that i have the sysID of parent group. Now I want the all child group under that parent group without using gliderecord. is this possible??