Skip to Content
author's profile photo Former Member
Former Member

How to Define a User in SAP Business One 6.5 SP1 E7 using DI API

hi,

I am was unable to add a user to Sap Business One 6.5 with service pack1 using DI aPI . following is the code.

i am getting an errocode =-5002 which is your OUSR.Password should be greater than 4 . but i have 8 character.

please help me . i am in desparate need.

Private Sub CreateUser()

Dim oUser As SAPbobsCOM.Users

Dim a As Long

Dim errMsg As String

' Set connection properties

oCompany.Server = "vishal"

oCompany.DbUserName = "sa"

oCompany.DbPassword = "pass"

oCompany.CompanyDB = "SBODemo_US"

oCompany.UserName = "manager"

oCompany.Password = "manager"

'Try to connect

lRetCode = oCompany.Connect()

If lRetCode <> 0 Then ' if the connection failed

oCompany.GetLastError(lErrCode, sErrMsg)

MsgBox("Connection Failed - " & sErrMsg, MsgBoxStyle.Exclamation, "Default Connection Failed")

End If

If oCompany.Connected Then ' if connected

Me.Text = Me.Text & " - Connected to " & oCompany.CompanyDB

End If

oUser = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUsers)

oUser.UserName = "abc1"

oUser.UserCode = "amx_ctx2"

oUser.UserPassword = "1234"

a = oUser.Add()

Call oCompany.GetLastError(a, errMsg)

If (0 <> a) Then

MsgBox("Found error:" + Str(a) + "," + errMsg)

End If

End Sub

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Feb 02, 2005 at 01:50 PM

    Hi Raj,

    besides the fact that your password IS only 4 characters in the code you posted (user code is 8 chars...), your code works properly ⚠️ with SAP Business One / DI API 2004 build 186, PL 09.

    I would heavily recommend to create a message on SAP Service Marketplace to get support check this - and maybe provide a bugfix...

    Are you sure you are using DI API 6.5 (remember the side-by-side model for DI API)?

    Maybe you should remove all copies of ObserverDLL.DLL etc. (I think besides some posts here there's also a note on Service Marketplace available.)?

    But still, SAP Service Marketplace should be first choice!

    Regards,

    Frank

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.