Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HOWTO : query LDAP with ASP (not an AD)

Posted on 2014-03-10
9
Medium Priority
?
935 Views
Last Modified: 2014-03-18
Hi,

I'm looking for an example of how to read value in a LDAP server. I've googled but always found example based on AD.

Does anyone got such example ?

Thx
0
Comment
Question by:Sybux
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39917147
with ADO you should be able to do so?
set objADsPath as needed
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select  ... from 'GC://"+objADsPath+"' WHERE ... "
Set rs = Com.Execute

While Not rs.EOF 
  ...
  rs.MoveNext
wend

rs.Close
con.Close
Set rs = Nothing
Set con = Nothing 

Open in new window

0
 

Author Comment

by:Sybux
ID: 39917163
It's based on AD not ldap
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39917174
AD is a directory service provider, LDAP is a protocol used to query AD and other directory service providers. The LDAP query in the article i referenced will work with AD, or any other provider - it is not an AD specific query.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39917177
ok, I think then you need to get the LDAPClient objects (http://download.cnet.com/ActiveX-LDAP-Client/3000-2206_4-10019353.html),  and :
Set pLDAP = CreateObject("LDAPClient.3")
Call pLDAP.Connect("ldapserver","389","cn=Directory Manager", "password")

Set pAttributeNames = CreateObject("LDAPClient.StringCollection")
Call pAttributeNames.Add("givenName")

' Find all the Johns and all the Smiths
Set pEntries = pLDAP.Search("o=airus", "(|(givenName=John)(sn=Smith))", , pAttributeNames)
For Each pEntry In pEntries
    Response.Write(pEntry.Attributes("givenName").Values(0).Value & "<br>")
Next 

Open in new window

hope this helps
0
 

Author Comment

by:Sybux
ID: 39917383
So based on your comments, I've written this :
	Set conn = Server.CreateObject("ADODB.Connection")
	conn.provider ="ADsDSOObject"
	conn.open "Active Directory Provider"
	Set objCmd = CreateObject("ADODB.Command")
	objCmd.ActiveConnection = conn
	objCmd.Properties("SearchScope") = 2
	objCmd.Properties("Page Size") = 20

	objCmd.CommandText = "select cn,mail,sn from 'LDAP://" & ldapIp & "/" & ldapDn & "'"
	response.write objCmd.commandtext & "<br>"
	Set rs = objCmd.Execute

	While Not rs.EOF 
	  response.write rs.Fields("sn")
	  response.write (".")
	  rs.MoveNext
	wend

Open in new window


It seems that the query return something as "response.write (".")" print many points on screen. But I can't get any values
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39917408
that would be the case if rs.Fields("sn") is returning empty/null all the time ...
you may use another field name instead of sn to get some data...
0
 

Accepted Solution

by:
Sybux earned 0 total points
ID: 39928019
Ok finally I did it.

You put me on the way. In fact, datas read in the SQL statement are presented as Array. So we can't just read the value. We have to go throw the array as for example :

myValue = rs.Fields("cn")
if isArray(myValue) then response.write myValue(0)
0
 

Author Closing Comment

by:Sybux
ID: 39936358
Team work to fine the tip
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question