on 11-18-2008 5:35 AM
Hi Experts,
I want to implement authorization on Customize forms by code... i am using .NET Framework with C# for development.... please guides me...
thanks
deepak
Dear Deepak Gaur,
Here the sample code from SDK help:
Adding a PermissionTree - parent object (Visual Basic)
[Visual Basic]
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUserPermission As SAPbobsCOM.UserPermissionTree
Set mUserPermission = oCompany.GetBusinessObject(oUserPermissionTree)
'//Mandatory field, which is the key of the object.
'//The partner namespace must be included as a prefix followed by _
mUserPermission.PermissionId = "SM_MathClass"
'//The Name value that will be displayed in the General Authorization Tree
mUserPermission.Name = "SM_MathClass"
'//The permission that this object can get
mUserPermission.Options = bou_FullReadNone
'//In case the level is one, there Is no need to set the FatherID parameter.
mUserPermission.Levels = 1
RetVal = UserPermission.Add
oCompany.GetLastError RetVal, ErrMsg
'//In case this permission object has a son permission object
Adding a PermissionTree - child object (Visual Basic)
[Visual Basic]
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUserPermission As SAPbobsCOM.UserPermissionTree
Set mUserPermission = oCompany.GetBusinessObject(oUserPermissionTree)
mUserPermission.PermissionId = "SM_MathClassSon"
mUserPermission.Name = "SM_MathClassExam"
mUserPermission.Options = bou_FullNone
'//For level 2 and up you must set the object's father unique ID
mUserPermission.Levels = 2
mUserPermission.FatherID = "SM_MathClass"
'//this object manages forms
mUserPermission.UserPermissionForm.FormType = "GL_MathClass"
RetVal = mUserPermission.Add
oCompany.GetLastError RetVal, ErrMsg
[Visual Basic]
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUser As SAPbobsCOM.Users
Set mUser = oCompany.GetBusinessObject(oUsers)
'//The user unique ID is 2
RetVal = mUser.GetByKey(2)
'//Setting a new sub object for the User that hold the user permission for the user permission object
mUser.UserPermission.PermissionId = "SM_MathClassSon"
'//Seting full permission for User 2 to manage SM_MathClassSon sub object
mUsers.UserPermission.Permission = boper_Full
RetVal = mUsers.Update
oCompany.GetLastError RetVal, ErrMsg
Setting user permission (Visual Basic) Copy Code
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim mUser As SAPbobsCOM.Users
Set mUser = oCompany.GetBusinessObject(oUsers)
'//The user unique ID is 2
RetVal = mUser.GetByKey(2)
'//Setting a new sub object for the User that hold the user permission for the user permission object
mUser.UserPermission.PermissionId = "SM_MathClassSon"
'//Seting full permission for User 2 to manage SM_MathClassSon sub object
mUsers.UserPermission.Permission = boper_Full
RetVal = mUsers.Update
oCompany.GetLastError RetVal, ErrMsg
Best Regards
Jane Jing
SAP Business One Forums team
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deepak,
You can use the UserPermissionTree object to manage the user authorization tree, (in application, it corresponds to Select Administration --> System Initialization --> Authorization --> User Authorization Form), and then use UserPermission object to manage the users' permissions.
Best regards,
Lin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.