SandraDiehl
6th August 2007, 23:03
We are writing a VB.net application that currently we are able to log into BaaN and execute a special library but what we would like to be able to do is when the user logs into this new VB.net application we want to be able to pass the user id and password to the Baan4.Application call so they will not have to enter the information again.
I see that in the option there is a USER value, so is there one for password? For security reason we don't want the default to be set in the bw config file so looking for other options.
Any suggestions would be helpful.
Thanks
chadwickh
14th August 2007, 22:31
I don't understand the question :)
SandraDiehl
15th August 2007, 14:13
The question is simple but solution may not be:
Is there a way to call the Set BaanObj = CreateObject("Baan4.Application") from either excel VB or a VB.net application that would eliminate the BaaN login screen other than setting up the configuration file to have the user id and password? For security reason we do not want to have the configuration file to have the "saved password" checked so was hoping that along with the "-set USER=" variable that can be set in the "command" of the configuration that there is a "set PSWD" command for password.
The idea was to use the id and password the user used to get into the VB application and pass that value to the BaaN Login script to eliminate a second login screen from popping up to run the application, will not be able to do unless there is a password command like the "USER" command. That is what I am looking for, if anybody has any information rather if a password command exist.
AND if that command does exist I also need an example on how to set the values to pass it along when executing the CreateObject function.
Hopefully I have cleared up my request enough to get some suggestions.
Thanks
eppesuiG
15th August 2007, 18:13
You cannot pass a password as a parameter since all parameters are used after the user is authenticated.
A solution to your problem is, probably, a single sign on installation, where the user is not required to input any password after he log into his client machine. This solution isn't easy at all :-(
Al Smith
16th August 2007, 21:12
Hi,
Here's a VB6 application that passes the password to the login dialog then clicks the Connect button.
You should be able to convert it to .Net
I hope this helps.
Al.
Public lHwnd() As Long
Dim BaanObj As Baan4.Baan4
Dim winnum As Integer
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Const WM_SETTEXT = &HC
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const BM_SETSTATE = &HF3
Private Const VK_SPACE = &H20
Private Const GW_HWNDPREV = &H3
Dim Start As Double
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
winnum = winnum + 1
ReDim Preserve lHwnd(winnum)
lHwnd(winnum) = hwnd
EnumChildProc = 1
End Function
Sub Main()
Shell ("c:\baan\bin\bw.exe /username.bwc")
' find the windows handle for the login dialog box
getHwnd "Login for ProductionBox" ' Name in Title of Login Box
'Call function to Pass the password to the password field and click the connect button
LogIntoBaan ("UserPassword")
End Sub
Sub getHwnd(Title As String)
Dim retval As Long
ReDim lHwnd(1)
Do While lHwnd(0) = 0
lHwnd(0) = FindWindowEx(0, 0, vbNullString, Title)
DoEvents
Loop
Start = Timer
Do Until Timer > Start + 1
Loop
retval = EnumChildWindows(lHwnd(0), AddressOf EnumChildProc, 0)
End Sub
Sub LogIntoBaan(Password As String)
Call SendMessage(lHwnd(2), WM_SETTEXT, Len(Password), ByVal Password)
DoEvents
Call SendMessage(lHwnd(3), WM_LBUTTONDOWN, 0, 0)
DoEvents
Call SendMessage(lHwnd(3), BM_SETSTATE, 1, 0)
DoEvents
Call SendMessage(lHwnd(3), WM_LBUTTONUP, 0, 0)
DoEvents
Start = Timer
Do Until Timer > Start + 1
Loop
End Sub
SandraDiehl
17th August 2007, 15:22
Gave the code to my VB guy to see if he can make it work. I will post results once we have some.
I see you are from Marcellus; I used to live in Portage, MI and just moved down to South Carolina about a year ago. Small World!!!
alejandro
24th August 2007, 11:22
Take a look. to this thread (http://www.baanboard.com/baanboard/showthread.php?t=12366&highlight=getobject).
You have to define in ttaad2106m000 ttstpoledaem as one initial session for users.
If yo do this getobject will connect baan from vb using existing connection.
In this way passwords are not in script, etc...
Hope this helps.
nhhome
27th July 2008, 14:50
code for .net 3.5
Public Class Baan
Public lHwnd() As Integer
Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" _
(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Public Declare Function EnumChildWindows Lib "user32.dll" _
(ByVal hWndParent As Integer, ByVal lpEnumFunc As EnumWindowsCallback, ByVal lParam As Integer) As Integer
Delegate Function EnumWindowsCallback(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
Private Const WM_SETTEXT As Integer = &HC
Private Const WM_LBUTTONDOWN As Integer = &H201
Private Const WM_LBUTTONUP As Integer = &H202
Private Const BM_SETSTATE As Integer = &HF3
Private Const BM_CLICK As Integer = &HF5
Private Const VK_SPACE As Integer = &H20
Private Const GW_HWNDPREV As Integer = &H3
Dim Start As Double
Dim winnum As Integer
Public Sub Login(ByRef BaanObj As Object)
Shell("C:\Program Files\Baan\Baan Windows\bin\bw.exe")
' find the windows handle for the login dialog box
Call getHwnd("Login for baan5") ' Name in Title of Login Box
'Call function to Pass the password to the password field and click the connect button
LogIntoBaan("yourpsswrd")
End Sub
Function EnumChildProc(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
winnum = winnum + 1
ReDim Preserve lHwnd(winnum)
lHwnd(winnum) = hwnd
EnumChildProc = True
End Function
Public Sub getHwnd(ByVal Title As String)
Dim retval As Integer
Dim er As String
ReDim lHwnd(1)
Do While lHwnd(0) = 0
lHwnd(0) = FindWindowEx(0, 0, vbNullString, Title)
er = CStr(Err.LastDllError)
Loop
Start = Timer
Do Until Timer > Start + 1
Loop
retval = EnumChildWindows(lHwnd(0), AddressOf EnumChildProc, 0&)
End Sub
Public Sub LogIntoBaan(ByVal Password As String)
Call SendMessage(lHwnd(6), WM_SETTEXT, Len(Password), Password)
Call SendMessage(lHwnd(7), BM_CLICK, 0, 0)
Call SendMessage(lHwnd(7), BM_SETSTATE, 1, 0)
Call SendMessage(lHwnd(7), WM_LBUTTONDOWN, 0, 0)
Call SendMessage(lHwnd(7), WM_LBUTTONUP, 0, 0)
Start = Timer
Do Until Timer > Start + 1
Loop
End Sub
End Class