Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to bypass login dialog when accessing a Lotus Database?????

Status
Not open for further replies.

alinhardt

Programmer
Aug 28, 2003
7
US
I am trying to access a lotus database to read some data via vba code, but it keeps prompting me via a dialog box to enter the lotus notes password. I would like to bypass it. Anyone have any ideas?

Here is my code:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
session.Initialize
Set db = session.GetDatabase("", "xxxxxxxxxx.nsf")
If Not db.IsOpen Then
MsgBox db.Title & " does not exist", , "hp56p001.nsf"
Exit Sub
End If
 
I have found out that you can use the following if you know the password.

Session.Initialize("password")


But this will be used by others and I cannot hardcode in everyones passwords, and I want to eliminate the need for them to be bothered with the login if they already have notes open. Not sure if there is a way to glean the password from thier lotus notes id file "username.nsf" if notes is already open.

any assistance would be appreciated.
 
I'm using the following sequence at the top of a Lotus email routine and I believe it gets into a Notes session without need to enter a password if Lotus Notes is already running. Unfortunately developed blind because I do not has access to Notes, but appears to work because no complaints from users.

It's late bound;

Dim s as Object
Dim db as Object

Set s = CreateObject("Notes.Notessession")
Set db = s.getDatabase("", "")
db.Openmail
etc.

HTH Hugh,
 
Should add that my code was for vb6 but that should not matter much.

Extended version of the referenced email routine for vb6 in thread222-766157

regards Hugh,
 
Thanks!! That works just fine. I will also add that if Notes is not open, it will prompt for the password and still work without opening Notes.

Here is what I used:

Dim session As Object
Dim db As Object

Set session = CreateObject("Notes.Notessession")
Set db = session.GetDatabase("", "xxxxxx.nsf")

If Not db.IsOpen Then
MsgBox db.Title & " does not exist", , "xxxxxx.nsf"
Exit Sub
End If
 
Actually it did open notes when it prompted for the password.
 
alinhardt,

Pleased to hear it works and thanks for the feedback re the prompt for password if Notes is'nt already running.

Regards Hugh,
 
I can't understand how this code snippets work: do they allow opening a LOTUS database and passing Lotus a password??? I always get the password dialog appearing, and my VBA code locks until I insert the password!
How can I send the password? My 4.6 version does not support session.initialize(password) .

Alternatively, how can I access Windows API from within VBA, to implement this VB source?
Code:
WindowName = "Enter Password"
' Define AND Get the handle of the window you're looking for, at the same time.
hWnd_Of_FindWindow = FindWindow(ClassName, VarPtr(WindowName))
hWnd_Of_FindWindow = 1312738
' Process the results of FindWindow
If hWnd_Of_FindWindow > 0 Then
        Call SetForegroundWindow(hWnd_Of_FindWindow)
        Call keybd_event(VK_RETURN, ENTER, 0, 0) ' ‘ENTER’ Press
        Call keybd_event(VK_RETURN, ENTER, WM_KEYUP, 0) ' ‘ENTER’ Release
        Call SendMessageAPI(hWnd_Of_FindWindow, WM_KEYDOWN, 0, 0)
Else
 ' End If
This works in a visual basic standalone app, but it does not inside Microsoft Access, although I also added these declarations:

Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (lpClassName As String, lpWindowName As Long) As Integer
Private Declare Function SendMessageAPI Lib "user32" Alias "SendMessageA" (hWnd As Long, wMsg As Long, wParam As Long, lParam As Long) As Long
Private Declare Sub keybd_event Lib "user32" (bVirtualKey As Byte, bScanCode As Byte, dwFlags As Long, dwExtraInfo As Long)
Private Declare Sub SetForegroundWindow Lib "user32" (hWnd As Long)

-- Jumpjack --
 
jumpjack,

You are trying to breathe life back into an old thread and that is probably why you have had little help up to now. Your issue is not directly related to the start of this thread. I recommend you start a new thread which describes what you are trying to do in detail.

The code you have posted appears to try to find a Window with a caption of "Enter password" - set the focus to it and then simulates pressing and releasing the return key on it. It does not enter a password, so unless the "Enter password" window is coming up with a password already in it and hitting Return is just required to confirm it you have little chance of it working.

Having said that you should in any case remove the line;

hWnd_Of_FindWindow = 1312738

from your code because hWnd_Of_FindWindow has already been found in the line above it and it will not have a constant value of 1312738.

I suggest you carefully review all the code above in this thread and avoid the simulated keystrokes approach.

regards Hugh,
 
I manually assign hWnd_Of_FindWindow because the function always returns 0!
and I'm trying with ENTER just to see if it works: I should get at least an "access denied" or "wrong password" error, but actually look like anything is sent to the window.
I am using Access 97: maybe I should use a slightly different code?

-- Jumpjack --
 
Ref your FindWindow woes, replace the declaration with;

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long

then replace your;
hWnd_Of_FindWindow = FindWindow(ClassName, VarPtr(WindowName))

with;
hWnd_Of_FindWindow = FindWindow(0&, WindowName)

or;
hWnd_Of_FindWindow = FindWindow("NOTES", WindowName)

Be sure hWnd_Of_FindWindow is dimmed as a Long as in;
Dim hWnd_Of_FindWindow as Long

Hugh,


 
replace your;
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (lpClassName As String, lpWindowName As Long) As Integer

with;
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long

 
Looks like FindWindow works.
WHat is not working is SetForeground and keybd_event : how can I bring window to foreground? How can I send keypresses?


-- Jumpjack --
 
Please refer to the code posted by wiglaer in thread222-766157 as previously advised. Even if you do not want to automate Lotus the API calls you seem to require now are demonstrated there in lines 10 thru 30.

Hugh,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top