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.

Lotus Notes LDAP Export


;******************************************************************
;******************************************************************
;***  TITLE: LDAP Export ******************************************
;***  DATE: June 1, 2005  *****************************************
;***  CREATED BY: Charlie Travis  *********************************
;***  PURPOSE: This program creates an LDIF file of all ***********
;***  email addresses.  *******************************************
;******************************************************************
;******************************************************************

ONCANCEL="EXIT"

;Delete previous debug file
FileDelete("C:\wbdebug.txt")

;Enable creation of new debug file
DebugTrace(@on, "c:\wbdebug.txt")

 
DirChange ("C:\Notes\")

If FileExist ("C:\Notes\Export.old")
FileDelete ("C:\Notes\Export.old")
Endif

If FileExist ("C:\Notes\Export.txt")
FileRename ("C:\Notes\Export.txt", "C:\Notes\Export.old")
EndIf

If FileExist ("C:\Notes\Export_tmp1.old")
FileDelete ("C:\Notes\Export_tmp1.old")
Endif

If FileExist ("C:\Notes\Export_tmp1.txt")
FileRename ("C:\Notes\Export_tmp1.txt", "C:\Notes\Export_tmp1.old")
EndIf

If FileExist ("C:\Notes\Export_tmp2.old")
FileDelete ("C:\Notes\Export_tmp2.old")
Endif

If FileExist ("C:\Notes\Export_tmp2.txt")
FileRename ("C:\Notes\Export_tmp2.txt", "C:\Notes\Export_tmp2.old")
EndIf

If FileExist ("C:\Notes\LDAP.old")
FileDelete ("C:\Notes\LDAP.old")
Endif

If FileExist ("C:\Notes\LDAP.txt")
FileRename ("C:\Notes\LDAP.txt", "C:\Notes\LDAP.old")
EndIf

DirChange ("C:\Notes")

Run ("cmd", "")

WinActivate ("~C:\WINDOWS\system32\cmd.exe")

SendKeysTo ("~C:\WINDOWS\system32\cmd.exe","Ldapsearch -h : ""objectclass=dominoperson"" mail -L>Export.txt")


Delay (2)

SendKeysTo ("~C:\WINDOWS\system32\cmd.exe","{ENTER}")

Delay (6)

SendKeysTo ("~C:\WINDOWS\system32\cmd.exe","exit")
SendKeysTo ("~C:\WINDOWS\system32\cmd.exe","{ENTER}")

WinWaitClose ("~C:\WINDOWS\system32\cmd.exe") ;Wait for Ldapsearch window to close

New = ''
Old = FileGet("C:\Notes\Export.txt")
Cnts = ItemCount(Old, @LF)
For Cnt = 1 To Cnts
   If StrIndex(ItemExtract(Cnt, Old, @LF), 'CN=', 0, @FWDSCAN)==1 Then Continue
   New = ItemInsert(ItemExtract(Cnt, Old, @LF), -1, New, @LF)
Next ;Cnt
FilePut("C:\Notes\Export_tmp1.txt", New)

data = FileGet("C:\Notes\Export_tmp1.txt")
newdata = StrReplace(data,"mail=","")
FilePut("C:\Notes\Export_tmp2.txt",newdata)

New = ''
Old = FileGet("C:\Notes\Export_tmp2.txt")
Cnts = ItemCount(Old, @LF)
For Cnt = 1 To Cnts
   If StrIndex(ItemExtract(Cnt, Old, @LF), @CR, 0, @FWDSCAN)==1 Then Continue
   New = ItemInsert(ItemExtract(Cnt, Old, @LF), -1, New, @LF)
Next ;Cnt
FilePut("C:\Notes\LDAP.txt", New)

:CANCEL
%ONCANCEL%
EXIT

Article ID:   W17231
File Created: 2007:07:03:14:28:54
Last Updated: 2007:07:03:14:28:54