Luntri
Luntri

Reputation: 620

List all users that have permission for a given table in Dynamics ax 2009

I have some custom table, that was implemented by some company years ago in our environment.

I need to list users and their permissions to this table. I found about ACCESSRIGHTSLIST table that has everything I want, like groups and therefore associated users.

Problem is that this list is incomplete, users are able to modify/view this table outside of the groups I found by ACCESSRIGHTSLIST.

I know that dicttable.rights() would do nicely, but I cannot specify user here, it only validates for the user that is executing the code.

What I basicaly need is dicttable.rights(someUserID), but since I cannot see what mechanism is dicttable using, I'm stuck.

I work in AX 2009.

Upvotes: 0

Views: 1448

Answers (2)

10p
10p

Reputation: 6706

I don't have access to AX 2009 now but as far as I remember you should be able to use system class SecurityKeySet. Check if the following works:

SecurityKeySet  securityKeySet; 
AccessType      accessType;
UserId          userId      = curUserId();
TableId         tableId     = tableNum(CustTable);
;

securityKeySet = new SecurityKeySet(); 
securityKeySet.loadUserRights(userId);

accessType = securityKeySet.tableAccess(tableId);

info(strFmt('%1', accessType));

Upvotes: 1

Alex Kwitny
Alex Kwitny

Reputation: 11544

Instead, create a static server method and use the runas command to call it, where you runas the different users you want.

See:

Or search the system for sample code.

Upvotes: 1

Related Questions