Author Topic: Security groups that the current user belongs to (scripting)  (Read 4851 times)

adepreter

  • EA User
  • **
  • Posts: 187
  • Karma: +10/-9
    • View Profile
Security groups that the current user belongs to (scripting)
« on: April 21, 2016, 06:48:32 pm »
Is there a way to create, by script, a dictionary object that contains the Security groups that the current user belongs to?

Cheers,

Alain
« Last Edit: April 21, 2016, 06:58:33 pm by adepreter »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Security groups that the current user belongs to (scripting)
« Reply #1 on: April 21, 2016, 07:00:32 pm »
Sort of. You can query the tables t_secuser, t_secgroup, t_secusergroup and t_secgrouppermission to get the information you need.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Security groups that the current user belongs to (scripting)
« Reply #2 on: April 21, 2016, 07:01:15 pm »
There's not really an API object for security users or groups, but you can certainly get the info from the database using Repository.SQLQuery

You can use Repository.GetCurrentLoginUser (boolean GetGuid) to get the current user and use that to select the groups

Code: [Select]
select g.GroupName from t_secusergroup ug
inner join t_secgroup g on g.GroupID = ug.GroupID
where ug.UserID = '<userGUID>'

Geert

adepreter

  • EA User
  • **
  • Posts: 187
  • Karma: +10/-9
    • View Profile
Re: Security groups that the current user belongs to (scripting)
« Reply #3 on: April 21, 2016, 10:41:46 pm »
Thank you. Very good idea.