Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LDAP SQL query syntax

Status
Not open for further replies.

spaulding

Technical User
Jan 10, 2001
123
US
I'm not sure why but the following script only returns records where the description field in Active Directory is blank.

<%
On Error Resume Next


Dim oconn
Dim rs
Dim sqltext
dim c


Set oconn=CreateObject("ADODB.Connection")
oconn.Provider="ADsDSOOBJECT"
oconn.open
sqltext="Select ADsPath, cn, Description FROM 'LDAP://DC=FISD,DC=org'"


Set rs=oconn.Execute(sqltext)
c=1
Do While Not rs.eof

response.write c & " Container name: " & rs("cn") & " Path:" & rs("ADsPath") & " description:" & rs("description") &"<br>"
rs.movenext
c=c+1
Loop



%>

I want it to return all records and list what the description field value is, because my next step in this project is to search for specific values.

I'd appreciate any help I can get.
 
Did a little more research and found an answer here:

It seems that some of the values returned from the LDAP query are returned as an array, which causes the error.

To get around this problem use the join function to collapse the array into a string.

So in my case I created a variable and loaded the value into it, then used the variable in the response.write function

Desc=join(rs("description").value)

response.write "Description: " & desc

Not sure why this occurred or even which of the properties are affected, but this seems to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top