Author Topic: Restrict specific scripts based on which group a user belongs to  (Read 3138 times)

rupertkiwi

  • EA User
  • **
  • Posts: 133
  • Karma: +5/-0
    • View Profile
Is it possible to restrict specific scripts based on which group a user belongs to?

In a similar way that diagrams or packages can be locked depending on which group a user is a member of?

I can restrict the running and editing of all scripts based on a user's group via the Security Group settings but it would be good to restrict individual scripts

Thanks,
Rupert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Restrict specific scripts based on which group a user belongs to
« Reply #1 on: May 02, 2018, 03:47:07 pm »
Hi Rupert,

Not out of the box, but you can of course test the current user in your script yourself, and refuse to execute if she doesn't meet your requirements.

Geert

rupertkiwi

  • EA User
  • **
  • Posts: 133
  • Karma: +5/-0
    • View Profile
Re: Restrict specific scripts based on which group a user belongs to
« Reply #2 on: May 02, 2018, 04:05:58 pm »
OK, thanks Geert for your prompt reply.

I will have a play around and see how I go

Cheers,
Rupert

Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 340
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Re: Restrict specific scripts based on which group a user belongs to
« Reply #3 on: May 03, 2018, 04:41:12 am »
Use the following function in JScript-type script and validate it in the logic of your script:

Code: [Select]
function isUserInGroup(groupGUID) {
var userGUID = Repository.GetCurrentLoginUser(true);
var result = DBGetFieldValueArrayString("GroupID", "t_secusergroup", "UserID = '" + userGUID + "' AND GroupID = '" + groupGUID + "'");
if(result.length == 0) {
return false;
}
return true;
}