erezlevi Posted January 2, 2009 Share Posted January 2, 2009 hi, I have an issue with LDAP queury. If using the ldap-search-tool it can search my company directory (not Active-directory related). I need an example script for ADODB connection, not connecting to AD for searching but for global ldap queries. I tried using this: $serverName = "9.17.186.253" $baseStr = "ou=bluepages,o=ibm.com" $filterStr = "cn=zar*" $ado = ObjCreate("ADODB.Connection") $ado.Provider = "ADSDSOObject" $ado.Properties("User ID") = "" $ado.Properties("Password") = "" $ado.Properties("Encrypt Password") = 1 $ado.Open ("ADS-Search" ) $adoCmd = ObjCreate("ADODB.Command") $adoCmd.ActiveConnection = $ado $adoCmd.Properties("Page Size") = 99 $adoCmd.Properties("Cache Results") = 1 $adoCmd.CommandText = "<LDAP://" & $serverName & "/" & $baseStr & ">;" & $filterStr & ";ADsPath;subtree" $objectList = $adoCmd.Execute While Not $objectList.EOF() $user = ObjGet($objectList.Fields("ADsPath").value) If $user.displayName <> "" Then ConsoleWrite ($user.displayName & @CRLF) EndIf $objectList.MoveNext () Wend any idea? Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 bump Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 I'v tried this also: $objConnection = ObjCreate("ADODB.Connection") $objConnection.Open ("Provider=ADsDSOObject;") $objCommand = ObjCreate("ADODB.Command") $objCommand.ActiveConnection = $objConnection $objCommand.CommandText = "<LDAP://9.17.186.253:389,c=il,ou=bluepages,o=ibm.com>;(&(objectCategory=mail);subtree" $objRecordSet = $objCommand.Execute if $objRecordSet.RecordCount = 0 then MsgBox(0,"","Not Found!") else ConsoleWrite ($objRecordSet.Fields("mail").Value) EndIf but it gives me this error: C:\My Documents\LDAP\test1.au3 (11) : ==> The requested action with this object has failed.: $objRecordSet = $objCommand.Execute $objRecordSet = $objCommand.Execute^ ERROR any idea? someone? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 4, 2009 Developers Share Posted January 4, 2009 As mentioned in the PM: Are you sure you are using the correct provider for doing a LDAP call to the bluepages? It also helps to implement a ComErrorHandler to display better error info. Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 As mentioned in the PM: Are you sure you are using the correct provider for doing a LDAP call to the bluepages?It also helps to implement a ComErrorHandler to display better error info.JosHi, Jos, Thanks for replying....the issue is that when using WireShark (Network Sniffer) I don't even see a packet go out to the server, the application immidietly halt. Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 just another thing, if using this application it does work: "ldap search tool". Link to comment Share on other sites More sharing options...
Developers Jos Posted January 4, 2009 Developers Share Posted January 4, 2009 just another thing, if using this application it does work:"ldap search tool".Is this a AutoIt3 script?anyways as mentioned:1. are you sure you are using the correct provider?2. Did you add the ComErrorHandler to show better errors? SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 Is this a AutoIt3 script?anyways as mentioned:1. are you sure you are using the correct provider?2. Did you add the ComErrorHandler to show better errors?I got three errors:We intercepted a COM Error !Number is: 80020009Windescription is: ??5We intercepted a COM Error !Number is: 000000A9Windescription is: Variable must be of type 'Object'.+>17:48:21 AutoIT3.exe ended.rc:0I have no idea what those errors means. Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 what other providers are there ? I couldn't find any on the web. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 4, 2009 Share Posted January 4, 2009 (edited) what other providers are there ? I couldn't find any on the web.On the web...? You said you were trying to search your company's LDAP directory. What makes you think your company has its LDAP directory out on the web? That would normally be hosted on an internal server controlled by the company. Have you discussed this with your company's IT people?I would bet your error is on the $objRecordSet variable, which is not an object because the query failed. The query failed because you don't know where the LDAP server is, just as Jos said. Edited January 4, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
erezlevi Posted January 4, 2009 Author Share Posted January 4, 2009 (edited) hi, the server is my company server you are right about that, but it is LDAP based and I can query it using LDAP search tools (free tools on the web). now, regarding the issue, I got this code to make it work, it is VBS and I have no idea how to translate it to Auto-IT. can someone please help me do it ? ' Find first names of all the zar.... Set pLDAP = CreateObject("LDAPClient.3") Call pLDAP.Connect("9.17.186.253") Set pAttributeNames = CreateObject("LDAPClient.StringCollection") Call pAttributeNames.Add("givenName") Call pAttributeNames.Add("mail") ' Find all the zar... family names... Set pEntries = pLDAP.Search("c=il,ou=bluepages,o=ibm.com", "sn=zar*", , pAttributeNames) For Each pEntry In pEntries MsgBox pEntry.Attributes("givenName").Values(0).Value MsgBox pEntry.Attributes("mail").Values(0).Value Next Edited January 4, 2009 by erezlevi Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now