Connection to OpenLDAP server with a ADODB connection

Author Message
olivierv75

  • Total Posts : 3
  • Scores: 0
  • Reward points : 0
  • Joined: 1/2/2012
  • Location: Paris
  • Status: offline
Connection to OpenLDAP server with a ADODB connection Monday, January 02, 2012 10:58 PM (permalink)
0
Hello,

I would like to set up a VBScript that will retrieve the information stored on an OpenLDAP server but I have some problems with the initialization of the connection, or rather the RecordSet object.
Can anyone tell me what's wrong in my script which appears below?

strUserLDAP = "cn=user,ou=connectors,dc=domain,dc=us"
strLDAPPassword = "ldapPassword"
sBaseDN =  "LDAP://ldap.domaine.us:389/ou=groups,dc=domain,dc=us"

Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Properties("User ID") = strUserLDAP
oConnection.Properties("Password") = strLDAPPassword
oConnection.Properties("Encrypt Password") = false
oConnection.Open "ADs Provider", strUserLDAP, strLDAPPassword
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnexion

sLDAPQuery = "<"& sBaseDN &">"
'sLDAPFilter = "(objectClass=*)"
sAttribut = "dn"
sLDAPQuery = sLDAPQuery & ";" & sLDAPFilter & ";" & sAttribut & ";onelevel"
oCommand.CommandText = sLDAPQuery

On Error Resume Next
Set oRecordSet = oCommand.Execute
If Err <> 0 Then
MsgBox "Impossible to get result !" & vbcrlf & "Description error:" & Err.description
WScript.Quit
Else
MsgBox "It's all right"
End If
Thanks for your help

<message edited by olivierv75 on Tuesday, January 03, 2012 4:10 AM>
 
#1
    ebgreen

    • Total Posts : 8219
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Connection to OpenLDAP server with a ADODB connection Tuesday, January 03, 2012 3:22 AM (permalink)
    0
    What error do you get? If you are not getting an error, remove the On Error Resume next and see what error you get. Which specific line is causing the error?
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      olivierv75

      • Total Posts : 3
      • Scores: 0
      • Reward points : 0
      • Joined: 1/2/2012
      • Location: Paris
      • Status: offline
      Re:Connection to OpenLDAP server with a ADODB connection Tuesday, January 03, 2012 3:41 AM (permalink)
      0
      Hello ebgreen,
       
      The problem seems to occur at the line "Set oRecordSet oCommand.Execute =" ; when I create a Recordset object. The dialog box displays the following information:

      Error: Error not specified
      Code: 80004005
      Source: Provider
       
      An idea ?
       
      #3
        ebgreen

        • Total Posts : 8219
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:Connection to OpenLDAP server with a ADODB connection Tuesday, January 03, 2012 4:03 AM (permalink)
        0
        The first thing that I see is:
         
        sLDAPQuery = sRequeteLDAP & ";" & sLDAPFilter & ";" & sAttribut & ";onelevel"
         
        but I don't see anywhere that you define sRequeteLDAP
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          olivierv75

          • Total Posts : 3
          • Scores: 0
          • Reward points : 0
          • Joined: 1/2/2012
          • Location: Paris
          • Status: offline
          Re:Connection to OpenLDAP server with a ADODB connection Tuesday, January 03, 2012 4:12 AM (permalink)
          0
          It's actually a mistake when I wanted to translate French programm in a English program. I forgot to replace all the iterations sRequeteLDAP by sLDAPQuery.
          In my original program (in French) all variables are defined. I also corrected the script that appears in my first message
          <message edited by olivierv75 on Tuesday, January 03, 2012 5:21 AM>
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9