[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp ldap connection

Posted on 2007-08-06
6
Medium Priority
?
958 Views
Last Modified: 2010-08-05
hi,

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>"
Next

but i get this error:

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

please help
0
Comment
Question by:eaweb
  • 4
  • 2
6 Comments
 

Author Comment

by:eaweb
ID: 19639234
or does someone have a asp ldap connection and display to a exchange server
0
 
LVL 5

Accepted Solution

by:
spambler earned 1500 total points
ID: 19660779
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
%>
<HTML>
<HEAD>
<TITLE>Listing of Domain Groups</TITLE>
</HEAD>
<%
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("<tr><th>Name</th><th>ADsPath</th><th>Description</th><th>Members</th></tr>")
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)
      Response.Write("</td>")
      aMember = oRecordSet.Fields("member")
      Response.Write("<td>")
      'Response.Write("<td><select size = '5'> ")
      If Not IsNull(aMember) Then
            For icount = 0 to UBound(aMember)
                  Response.Write(aMember(iCount)&"<BR>")
'                  Response.Write("<option>" & aMember(iCount))
            Next
      End If
      Response.Write("</td></tr>")
      oRecordSet.MoveNext
Wend
Response.Write("</font>")
Response.Write("</table>")

oRecordSet.Close
oCon.Close

Set oRecordSet = Nothing
Set oCon = Nothing
%>
</BODY>
</HTML>

0
 

Author Comment

by:eaweb
ID: 19687073
hi

i tried your code but i got this error:

Script error detected at line 12.
Source line: Set oRootDSE = GetObject("GC://RootDSE")
0
Independent Software Vendors: 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!

 

Author Comment

by:eaweb
ID: 19687185
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, _
               rs.Fields(2).Value
         rs.MoveNext
      Wend

      conn.Close
%>


error:

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

Expert Comment

by:spambler
ID: 19688434
What happens if you comment out both your DIM's?
0
 

Author Comment

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

Featured Post

Independent Software Vendors: 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!

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 .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

829 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