asp ldap connection

Posted on 2007-08-06
Last Modified: 2010-08-05

i am trying to get connected to my exchange server with ldap using this code:

StrServer = "Exchange01"
Set cont = GetObject("LDAP://" & strServer)
For Each obj in cont
   Response.Write obj.Name & "<BR>"

but i get this error:

Script error detected at line 3.
Source line: Set cont = GetObject("LDAP://" & strServer)

please help
Question by:eaweb

    Author Comment

    or does someone have a asp ldap connection and display to a exchange server
    LVL 5

    Accepted Solution

    You could always try replacing LDAP with GC.  Sometimes works for me.

    However, here's some code I'm currently using in it's most basic form.  Probably not what you're after but it may include something you have missed.

    <%@ Language="VBScript" %>
    Option Explicit
    <TITLE>Listing of Domain Groups</TITLE>
    Dim oRootDSE, oCon, oCmd, oRecordSet
    Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
    Dim aDescription, aMember, iCount

    Set oRootDSE             = GetObject("GC://RootDSE")
    sDomainADsPath            = "GC://" & oRootDSE.Get("defaultNamingContext")

    RESPONSE.WRITE "oRootDSE = " & sDomainADsPath& "<BR>"

    Set oRootDSE             = Nothing
    Set oCon             = Server.CreateObject("ADODB.Connection")
    sUser                  = "DOMAIN\SPAMBLER"
    sPassword            = "MYPASSWORD"
    oCon.Provider             = "ADsDSOObject"
    oCon.Open "ADProvider", sUser, sPassword
    Set oCmd            = Server.CreateObject("ADODB.Command")
    Set oCmd.ActiveConnection = oCon
    sProperties            = "name,ADsPath,description,member"
    sGroup                  = "*"
    oCmd.CommandText      = "<" & sDomainADsPath & ">;(&(objectCategory=group)(name=" & sGroup & "));" & sProperties & ";subtree"
    oCmd.Properties("Page Size") = 100
    Set oRecordSet = oCmd.Execute

    Response.Write("<strong> Global Groups for the domain: " & Replace(Mid(sDomainADsPath,11), ",DC=", ".") & "</strong>")

    Response.Write("<table border='1'>")
    Response.Write("<font size=-2>")
    While Not oRecordSet.EOF
          Response.Write("<tr><td>" & oRecordSet.Fields("name") & "</td>")
          Response.Write("<td>" & oRecordSet.Fields("ADsPath") & "</td>")
          aDescription = oRecordSet.Fields("description")
          Response.Write("<td> ")
          If Not IsNull(aDescription) Then Response.Write aDescription(0)
          aMember = oRecordSet.Fields("member")
          'Response.Write("<td><select size = '5'> ")
          If Not IsNull(aMember) Then
                For icount = 0 to UBound(aMember)
    '                  Response.Write("<option>" & aMember(iCount))
          End If


    Set oRecordSet = Nothing
    Set oCon = Nothing


    Author Comment


    i tried your code but i got this error:

    Script error detected at line 12.
    Source line: Set oRootDSE = GetObject("GC://RootDSE")

    Author Comment

    hi i tried this code but got the following error:

    Dim conn As ADODB.Connection

          Dim rs As ADODB.Recordset

          Set conn = New ADODB.Connection
          conn.Provider = "ADSDSOObject"
          conn.Open "ADs Provider"

          Set rs = conn.Execute( _
                "<LDAP://curxch1/o=Maduro & Curiel's Group/ou=CURACAO/cn=recipients>;" _
                & "(objectClass=*);ADsPath,objectClass,cn;subtree")

          While Not rs.EOF
             Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, _



    Script error detected at line 8.
    Source line: Dim conn As ADODB.Connection
    Description: Expected end of statement
    LVL 5

    Expert Comment

    What happens if you comment out both your DIM's?

    Author Comment

    Script error detected at line 8.
    Source line: Set conn = New ADODB.Connection
    Description: Class not defined: 'ADODB'

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    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…

    737 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

    17 Experts available now in Live!

    Get 1:1 Help Now