Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HOWTO : query LDAP with ASP (not an AD)

Posted on 2014-03-10
9
Medium Priority
?
980 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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

972 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