Get permissions for groups and List projects they belong to

Hello,

I am writing a script that needs to do the following:

1) Select a group and see which projects they have access to, along with what level of access

2) Select a user and see which projects they have access to, along with what level of access

I started out with the code below. But, I am getting errors with hasPermission function because I am passing it a group name and not a user name. Is there an undocumented function to look up access for groups to accomplish the above? Please assist.

Thanks in advance,

~ Hanna

Project P
Group g
Permission perm = null

for g in groupList do
{
 string groupName = g.name

 print groupName "\n"
 for P in database do
  {
 
  if (hasPermission(groupName, P, perm))
  print groupName "\n"

 }
 
}

 


hyaldo - Thu Oct 02 17:06:39 EDT 2014

Re: Get permissions for groups and List projects they belong to
llandale - Fri Oct 03 15:26:06 EDT 2014

I see that "hasPermission" asks whether the current user has certain permissions; (except for the Signature perms).

For groups: if that Group has a specific AccessRecord to the Project then use that.  If the group has no AccessRecord to the project then use the default "Everyone else" access record.

For Users: First you get a list of all your Groups and then a list of each Group's users.=; then parse that to derive the list of groups for each user.  You cannot directly get a list of Groups for each user.  For access to a Project:

  • If the user has an explicit AccessRecord then that is the access, ignore any group access this user may have.
  • If the user has NO explicit AccessRecord, then you need to accumulate access for every Group that user is in.

You will need this:

  • AccessRec ar
  • for ar in P do
  • {  Name = username(ar)
  •     if (isDefault(ar))  then this is the default "Everyone else" AccessRecord
  •     elseif (existsGroup(Name)) then this is a Group AccessRecord
  •     else    this is a User AccessRecord

Following is a function perhaps you can use to do the accumulateing.

//**********************
void UpdatePermissionWithAR(AccessRec ar, Permission &psnRMCDA)
{ // Update the Permission with AR accesses.

 Permission psnOut = psnRMCDA

 if (read(ar))    psnOut = psnOut | read
 if (modify(ar))  psnOut = psnOut | modify
 if (create(ar))  psnOut = psnOut | create
 if (delete(ar))  psnOut = psnOut | delete
 if (control(ar)) psnOut = psnOut | control
 psnRMCDA  = psnOut
} // UpdatePermissionWithAR()

Here is a function to turn a "Permission" into a string, e.g. "RMCD"

Buffer plx_psnConvert_Results = create(8) // Local buffer to the following functions.
//***********************
string fStringOfPsn(Permission psn)
{  // Convert the Permission to displayable string format,
  // e.g. 'RMCDA' or 'RM'

 if (null psn) return("none")
 plx_psnConvert_Results = ""

 if (!null (psn & read))     plx_psnConvert_Results += "R"
 if (!null (psn & modify))  plx_psnConvert_Results += "M"
 if (!null (psn & create))  plx_psnConvert_Results += "C"
 if (!null (psn & delete))  plx_psnConvert_Results += "D"
 if (!null (psn & control)) plx_psnConvert_Results += "A"

 return(stringOf(plx_psnConvert_Results))
} // end fStringOfPsn(Permis)

-Louie

Re: Get permissions for groups and List projects they belong to
Tony_Goodman - Thu Oct 16 09:44:30 EDT 2014

The attached prints out, in CSV format, all the projects in the database and their access permissions.

Copy the output and save to a *.csv file using notepad or something, then open in Excel.

 

Hope that helps

 

 


Attachments

printProjAccess2.dxl

Re: Get permissions for groups and List projects they belong to
hyaldo - Fri Oct 17 15:40:01 EDT 2014

Tony_Goodman - Thu Oct 16 09:44:30 EDT 2014

The attached prints out, in CSV format, all the projects in the database and their access permissions.

Copy the output and save to a *.csv file using notepad or something, then open in Excel.

 

Hope that helps

 

 

Thanks for the replies!!! This is very close to what I need. I can filter the CSV file by groups and get what I need that way instead of building a GUI. The one addition I need is that I 's like to get another column that parses users for each group from the groups column and include that in the excel as a seperate column so I can filter on individual users as well and see which projects thry have access to. How can I modify the attached DXL to include another column of users?

Thanks in advance!!!

~ Hanna