Simple Sample Blog – Permissions and Authorizations
Often we’re asked about having the ability to update user’s authorizations using the DI API. In the following blog I’d like to summarize the DI objects that are currently exposed and can be used for this purpose (for version 2007).
Let’s distinguish between User permissions and System Permissions.
•1) User Permissions
You can add and update User Permissions using the DI API. The equivalent form in SAP Business One GUI is:
Administration -> System initialization -> Authorizations -> Additional Authorization.
For creating and updating user authorizations, use the UserPermissionTree DI object.
UserPermissionTree is a business object that represents the User Authorization Form. This object enables to manage user authorization for new forms.
First step: Define permissions to my form. In order to do it I’ve used the code below:
SAPbobsCOM.UserPermissionTree oUPT =
oUPT.PermissionID = “MyPermission1”;
oUPT.Name = “MyPerm1”;
oUPT.Options = SAPbobsCOM.BoUPTOptions.bou_FullReadNone;
Second step: Grant user permission to my form. In order to do it I’ve used the code below:
SAPbobsCOM.Users oUsers =
oUsers.UserPermission.PermissionID = “MyPermission1”;
** For more information, please refer to the UserPermissionTree page in the SAP Business One SDK Help Center.
- 2) System Permissions
You can modify system permissions using the DI API.
The equivalent in SAP Business One GUI is:
Administration -> System initialization -> Authorizations -> General Authorization
For updating system permissions, use the following DI object method:
SBObob -> SetSystemPermission.
Public Sub SetSystemPermission( _
ByVal UserName As String, _
ByVal PermissionID As String, _
ByVal Permission As Long _
UserName = A User Code
PermissionId = Take the relevant string from the permission Id list in the help center. (For example: Business Partner = 38)
Permission = Choose the permission level you want to grant. (For example: 1= Full authorization)
One of the users (for example: “User1”) needs to have full authorization to work with “Business Partner” object.
In order to do it I need to use the SetSystemPermission method of the DI SBObob object, as shown below:
SAPbobsCOM.SBObob bobi =
bobi.SetSystemPermission(“User1”, “38”, 1);
** For more information, please refer to the SetSystemPermission page in the SAP Business One SDK Help Center.