Solved

HOWTO : query LDAP with ASP (not an AD)

Posted on 2014-03-10
9
772 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
It's based on AD not ldap
0
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Sybux
Comment Utility
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 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Team work to fine the tip
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now