WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Lotus Notes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Changing Lotus Notes Password

 Keywords:  

;This program will change a Lotus Notes password for a Lotus Notes 5.0 and 6.0 PC client

;assumptions:
;The path specified in HKLM\SOFTWARE\Lotus\Notes[Path] contains nnotes.dll and the notes.ini
;There is only one user id file that needs to be changed (this is the file that holds the password).
;The information in the notes.ini file is accurate
;There is only one version of Lotus Notes installed on the PC


;check lotus notes version

;Unfortunately, Lotus does not version stamp their executables or DLL files.
;Checking the date stamp of a .DLL or .EXE did not prove to be reliable either.
;Depending on maintenance updates, it is possible that a Lotus Notes 4.6 client machine
;could have a nnotes.dll dated later than the nnotes.dll on a Lotus 5.0 client machine

;I need to check to see if Lotus Notes 5.0 or higher is installed, so I had to resort 
;to checking some registry entries

lnotesver5 = @FALSE
lnotesver6 = @FALSE


if RegExistValue(@REGMACHINE, "SOFTWARE\Lotus\Notes\5.0[Path]")
	lot5path = RegQueryValue(@REGMACHINE, "SOFTWARE\Lotus\Notes\5.0[Path]")
	if lot5path <> ""
		lot5pathlen=strlen(lot5path)
		if strsub(lot5path,lot5pathlen,1)!="\"
    		lot5path=strcat(lot5path,"\")
		endif
		if fileexist(strcat(lot5path, "notes.exe"))
			lnotesver5 = @TRUE
		endif
	endif
endif

if RegExistValue(@REGMACHINE, "SOFTWARE\Lotus\Notes\6.0[Path]")
	lot6path = RegQueryValue(@REGMACHINE, "SOFTWARE\Lotus\Notes\6.0[Path]")
	if lot6path <> ""
		lot6pathlen=strlen(lot6path)
		if strsub(lot6path,lot6pathlen,1)!="\"
    		lot6path=strcat(lot6path,"\")
		endif
		if fileexist(strcat(lot6path, "notes.exe"))
			lnotesver6 = @TRUE
		endif
	endif
endif

;if neither lotus notes 5 or 6 is not installed, then this program cannot be used
;this code would have to be updated when version 7 is released
; the "SECKFMChangePassword" function used later was introduced in version 5.0

if lnotesver5 == @FALSE && lnotesver6 == @FALSE
	Message("Lotus Notes Password", "Lotus Notes version 5 or 6 is not installed.  Password was not changed.")
	EXIT
endif
	

;get some user input
lotcurpw = AskPassword("ChangePassword", "Please enter your CURRENT Lotus Notes password")
lotnewpw = AskPassword("ChangePassword", "Please enter your NEW Lotus Notes password")

;HKLM\SOFTWARE\Lotus\Notes[Path] will have the same value as either lot6path or lot5path.  
;If BOTH Lotus Notes 5 and Lotus Notes 6 are installed on the same PC, then
; HKLM\SOFTWARE\Lotus\Notes[Path] will have the same value as Lotus 5 or Lotus 6, which ever was installed last, not used last

;I am making the assumption that in most cases, only one version of Lotus Notes is installed on the PC, so I am going to use the
;values in HKLM\SOFTWARE\Lotus\Notes[Path]

;if mutliple versions of Lotus Notes are installed, the desired user.id file may not be updated with the new password

;query the registry to get the lotus notes path
if !RegExistValue(@REGMACHINE, "SOFTWARE\Lotus\Notes[Path]")
	Message("Lotus Notes Password", "Error determining Lotus Notes path.  Password was not changed.")
	EXIT
endif

lotuspath = RegQueryValue(@REGMACHINE, "SOFTWARE\Lotus\Notes[Path]")

if !DirExist(lotuspath)
	Message("Lotus Notes Password", "Lotus Notes path does not exist.  Password was not changed.")
	EXIT
endif

;make sure that lotuspath has a trailing "\"
lotuspathlen=strlen(lotuspath)
if strsub(lotuspath,lotuspathlen,1)!="\"
    lotuspath=strcat(lotuspath,"\")
endif


lotusidfile = Inireadpvt("Notes", "KeyFilename", "", strcat(lotuspath,"notes.ini"))
lotusdatadir = Inireadpvt("Notes", "Directory", "", strcat(lotuspath,"notes.ini"))

if lotusidfile == "" || lotusdatadir == ""
	Message("Lotus Notes Password", "Error locating user ID file.  Password was not changed.")
	EXIT
endif


;make sure that lotusdatadir has a trailing "\"
lotusdatalen=strlen(lotusdatadir)
if strsub(lotusdatadir,lotusdatalen,1)!="\"
    lotusdatadir=strcat(lotusdatadir,"\")
endif

lotusidfile = strcat(lotusdatadir, lotusidfile)


if !FileExist(lotusidfile)
	Message("Lotus Notes Password", "Error locating user ID file.  Password was not changed.")
	EXIT
endif

;change to the lotus notes directory
DirChange(lotuspath)

dllname=strcat(lotuspath,"nnotes.dll")

if !FileExist(dllname)
	Message("Lotus Notes Password", "%dllname% does not exist.  Password was not changed.")
	EXIT
endif


;load nnotes.dll
dllhandle = dllload(dllname)


;initialize nnotes.dll for API calls
dllcall(dllhandle, long:"NotesInitExtended" , long:0, long:0)

lotpswdresult = dllcall(dllhandle, long:"SECKFMChangePassword",lpstr:lotusidfile,lpstr:lotcurpw,lpstr:lotnewpw)


Buffer = BinaryAlloc(256)
BinaryEodSet(Buffer,255)
x = dllcall(dllhandle, long:"OSLoadString", long:0, long:lotpswdresult, lpbinary:Buffer, long:255)

Text = BinaryPeekStr(Buffer,0,256)

;terminate nnotes.dll for API calls
dllcall(dllhandle, void:"NotesTerm")
dllfree(dllhandle)

if Text == "No error"
	Message("Lotus Notes Password", "Your Lotus Notes Password was sucessfully changed.")
else
	Message("Error changing Lotus Notes Password", Text)
endif

EXIT



Article ID:   W15687
File Created: 2003:05:13:11:29:34
Last Updated: 2003:05:13:11:29:34