Thursday, December 18, 2008

Berechtigungen eines Benutzer mit X++ Code abfragen Permissions a user with X + + Code

. Microsoft Dynamics AX, all user permissions on SecurityKeys controlled. SecurityKeys may Forms, Form Controls, Tables, Table Fields, MenuItems, etc. in their properties will be deposited. 
Classes for this is through a MenuItems and the implementation of the method "static void Main (Args _ARG)" also possible, but it may be for a single method SecurityKey not be awarded. 
However, there are situations where the code execution, depending on the specific authorization of the user, should be / needs. In such a case, the X + + code, a review of the privileges of the user are carried out. 

If you want to check whether a user access to a SecurityKey, can this with the method hasSecurityAccess done. 

if ( hasSecurityKeyAccess(securitykeyNum(CustSetup), AccessType::View) ) 
 ( 
// Execute code, if appropriate authorization exists. 
 ) 
If you want to check whether a user access to a table we go with this method hasTableAccess. 

if ( hasTableAccess(tablenum(CustTable), AccessType::Edit) ) 
 { 
// Execute code, if appropriate authorization exists. 
}  
Not only must the table, but a single box to be checked can be changed using the method hasFieldAccess made. 

if ( hasFieldAccess(tablenum(CustTable), fieldnum(CustTable, AccountNum), AccessType::Delete) ) 
{
// Execute code, if appropriate authorization exists. 
}  
AccessType determines the parameters on which this permission each element is gepĆ¼rft (No access, view, edit, create, complete control). 
All methods (hasSecurityAccess, hasTableAccess, hasFieldAccess) are global methods, in the global class is defined.. Thus, these methods at any point in the source code can be used. It does not matter whether it is a form of the method, DataSource, class or table. 

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...