LDAP / Shell() Problem [No Download]

modest

Registered User.
Local time
Today, 02:25
Joined
Jan 4, 2005
Messages
1,220
This is the code that works in the command prompt (It looks exactly like this). I'm trying to do the same thing in VBA:
Code:
C:\Program Files\tools> ldapsearch -D "cn=Directory Manager" -w testpass -h directorydev.domain.com -b aid=it0030,ou=Applications,o=domain.com,c=us userreferencedn=*xternal* dn lastaccesstime > "C:\Documents and Settings\UserLogin\Desktop\lastaccess.it0030.txt"



The problem is that the file doesn't download, like it does above. In the command above the file exports to the correct location and the only thing printed to the command window is a new line. In the code below, all the records that should be in the file are printed to the window... it seems as though everything after "lastaccesstime" is being ignored, which means no export for me.

Code:
Shell "C:\Program Files\tools\ldapsearch.exe " & _
        "-D " & Chr$(34) & "cn=Directory Manager" & Chr$(34) & " " & _
        "-w testpass " & _
        "-h directorydev.domain.com " & _
        "-b aid=it0030,ou=Applications,o=domain.com,c=us " & _
        "userreferencedn=*xternal* dn lastaccesstime" & _
        " > " & Chr$(34) & "C:\Documents and Settings\UserLogin\Desktop\lastaccess.it0030" & Chr$(34), _
        vbNormalFocus

I don't know what the problem is... I put it in a string and viewed it with a msgbox and everything seemed the same... I'm open to suggestions. If any of you say "you should do this in ADO" by all means... show me how :)

Thank you,
Modest
 
Last edited:
Apparently, VBA has no method of DOS redirection (the '>' character). So I can't print everything downloaded to that file.

What I'm going to try is to create a batch file with my script and then Shell the batch file to see if that might work.

If anyone knows how to run DOS/Command Prompt commands from VBA, please... let me know... I insist :)

-modest
 
My solution for anyone who might need it:

Dim strFrstFile As String

Code:
    strFrstFile = """C:\Program Files\tools\ldapsearch.exe""" & " " & _
                  "-D " & Chr$(34) & "cn=Directory Manager" & Chr$(34) & " " & _
                  "-w testpass " & _
                  "-h directorydev.domain.com " & _
                  "-b aid=it0030,ou=Applications,o=domain.com,c=us " & _
                  "userreferencedn=*xternal* dn lastaccesstime >" & _
                  """C:\Documents and Settings\UserLogin\Desktop\lastaccess.txt"""
                          
    Open "C:\Documents and Settings\UserLogin\Desktop\tempfile.bat" For Output As #1
        Print #1, strFrstFile          
        Print #1, "Exit"
    Close #1
    Shell """C:\Documents and Settings\UserLogin\Desktop\tempfile.bat"""

By all means, let me know if this help you or not. I go back through my posts and delete any that have been inactive that no one can use.
 
Last edited:
modest said:
I go back through my posts and delete any that have been inactive that no one can use.

That Sucks !!

I don't get in here very often, but my first instinct is to "search" when I have a problem. Your older posts may have solved my current problem..... :rolleyes:
 
That is the point of a forum.. what I'm saying is that sometimes I post something and no one responds. But I solve it myself. I leave most of the ones up, but the pointless ones that no one can use are deleted. Cheerio

-modest
 
from where can i get the ldapsearch.exe ?
thnaks
peleg
 
FWIW, I had a thread discussing about how to interact with console via VBA over here.

While I would say it would be far simpler to use batch file, this allows for interactivity.

HTH.
 
what????
i juts asked for the ldapsearch.exe?? what the conection to the link you just gave?
 
from where can i get the ldapsearch.exe ?
thnaks
peleg

From doing a quick Google search, it would appear that is something that gets installed with Lotus Notes. Are you using Lotus Notes?
 
what????
i juts asked for the ldapsearch.exe?? what the conection to the link you just gave?

Actually, I missed your post and was replying to the OP. Sorry.
 

Users who are viewing this thread

Back
Top Bottom