MikeBronner
Programmer
Could someone post an example of ASP code used to query LDAP without any proprietary components?
Thanks! Take Care,
Mike
Thanks! Take Care,
Mike
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<%@ Language=VBScript %>
<%
Option Explicit
Dim objADsPath,objDomain
%>
<html>
<head>
</head>
<body>
<%
Set objDomain = GetObject ("GC://RootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Response.Write objADsPath & "<BR>"
%>
</body>
</html>
<%@ Language=VBScript %>
<%
Option Explicit
Dim con,rs,Com,objADsPath,objDomain
%>
<html>
<head>
</head>
<body bgcolor="#CCCCCC">
<%
Set objDomain = GetObject ("GC://RootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
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 department from 'GC://"+objADsPath+"' WHERE department ='*'"
Set rs = Com.Execute
Do While Not rs.EOF Or rs.BOF
Response.Write rs("department") & "<BR>"
rs.MoveNext
Loop
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
%>
</body>
</html>
<%@ Language=VBScript %>
<%
Option Explicit
Dim objGroup,objMember,groupldap
%>
<html>
<head>
</head>
<body bgcolor="#CCCCCC">
<%
groupldap="[b]cn=groupname,dc=domain,dc=com[/b]"
Set objGroup = GetObject ("LDAP://"&groupldap&"")%>
<table border="0" cellpadding="0" bgcolor="#CCCCCC">
<%For each objMember in objGroup.Members%>
<tr><td><b><font face='Tahoma' size='2'><% response.write objMember.Name%></b></td></tr>
<%Next
Set objGroup=nothing%>
</table>
</body>
</html>
<%@ Language=VBScript %>
<%
Option Explicit
Dim objGroup,objMember,groupldap
%>
<html>
<head>
</head>
<body>
<%
groupldap="[b]cn=groupname,dc=domain,dc=com[/b]"
Set objGroup = GetObject ("LDAP://"&groupldap&"")%>
<%For each objMember in objGroup.Members%>
<font face='Tahoma' size='2'><% response.write objMember.[COLOR=red]cn[/color]%><br>
<%Next
Set objGroup=nothing%>
</body>
</html>