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.
Com.CommandText ="select description FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
descriptionarray=rs("description")
descriptionstring=description(0)
<%@ Language=VBScript %>
<%
response.buffer = true
SUB CloseAll
rs.close
set rs=nothing
con.close
set con=nothing
END SUB
%>
<html>
<head>
</head>
<body>
<%
groupdsn=request.querystring("group")
if groupdsn="" then
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 adspath,name from 'GC://"+objADsPath+"' WHERE objectCategory='Group' ORDER BY name"
Set rs = Com.Execute
if rs.EOF then
Call CloseAll
response.write "No Groups Found."
else
rsarray=rs.getrows
Call CloseAll
numrows=ubound(rsarray,2)
for rowcounter=0 to numrows
response.write "<a href='"+Request.ServerVariables("SCRIPT_NAME")+"?group="+rsarray(1,rowcounter)+"'>"+rsarray(0,rowcounter)+"</a><br>"
next
end if
else
set objgroup=GetObject(groupdsn)
response.write "<b>Members of "+groupdsn+"</b><br>"
For each objMember in objGroup.Members
response.write objMember.cn+"<br>"
Next
Set objGroup=nothing
end if
%>
</body>
</html>
<%@ Language=VBScript %>
<%
response.buffer = true
%>
<html>
<head>
<style type="text/css" media="screen, tv, projection"> @import "phonebook.css"; </style>
</head>
<body bgcolor="#DFDFDF" topmargin="0">
<%
user = request.queryString("user")
If user <> "" Then
objRootOU="ou=staff,"
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 otherTelephone, name, department, title, mail, [URL unfurl="true"]wwwhomepage,[/URL] telephonenumber, mobile, facsimileTelephoneNumber, physicalDeliveryOfficeName, company from 'GC://"+objRootOU+objADsPath+"' where sAMAccountname='"+user+"'"
Set rs = Com.Execute
otherTelephone=rs("otherTelephone")
name=rs("name")
department=rs("department")
title=rs("title")
mail=rs("mail")
[URL unfurl="true"]wwwhomepage=rs("wwwhomepage")[/URL]
telephonenumber=rs("telephonenumber")
mobile=rs("mobile")
facsimileTelephoneNumber=rs("facsimileTelephoneNumber")
physicalDeliveryOfficeName=rs("physicalDeliveryOfficeName")
company=rs("company")
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
if isarray(otherTelephone) then
for each strnumber in otherTelephone
strotherTelephone=","&strotherTelephone&","&strnumber
next
end if
%>
<table border="0" cellpadding="0" bgcolor="#DFDFDF">
<tr><td id="userinfo" colspan="2"><b><%=name%></b> - <%=company%></td></tr>
<tr><td id="userinfo">Title: </td><td><%=title%></tr>
<tr><td id="userinfo">Branch: </td><td><%=department%></tr>
<tr><td id="userinfo">Office: </td><td><%=physicalDeliveryOfficeName%></tr>
<tr><td id="userinfo">E-mail Address: </td><td><a href="mailto:<%=mail%>"><%=mail%></a></td></tr>
<tr><td id="userinfo">Phone Extension: </td><td><%=telephonenumber%><%=strotherTelephone%></td></tr>
<tr><td id="userinfo">Mobile Number: </td><td><%=mobile%></tr>
<tr><td id="userinfo">Fax Number: </td><td><%=facsimileTelephoneNumber%></tr>
</table>
<%Else%>
<p><br>Click on the name<br>of the person for<br>contact info.</p>
<%End If%>
</body>
</html>