Saturday, April 26, 2014

Access denied errors and Code permissions

Sometimes users with limited privileges stumble upon errors like below.

 Microsoft.Dynamics.Ax.Xpp.ErrorException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.ErrorException' was thrown.  
   at Dynamics.Ax.Application.SysOperationController.Checkaccess() in SysOperationController.checkAccess.xpp:line 6  
   at Dynamics.Ax.Application.SysOperationServiceController.Checkaccess() in SysOperationServiceController.checkAccess.xpp:line 24  
   at Dynamics.Ax.Application.SysOperationServiceController.Unpack(Object[] packedState) in   
 SysOperationServiceController.unpack.xpp:line 13  
   at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 32  
   at BatchRun::runJobStatic(Object[] )  
   at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)  
   at BatchIL.taskThreadEntry(Object threadArg)  

Along with one line like Access denied to %1 class. Clearly these are permissions issues owing to limited privileges added to the user's roles in security. One crude way to resolve the issue would be to simply elevate the access rights for the user, but that's not always practical. Second, more preferred way would be to give granular level access to that particular method where exception occurs. These methods are ususally run on Server and have attribute [SysEntryPointAttribute]. Here we can use Code permissions. Name suggests the purpose itself. Permission to code. See the example below. We have a custom code permission with one server method added. Not the property EffectiveAccess set as Invoke.


And this code permission is bound to the menu item that starts the logic.


No comments:

Post a Comment