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 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 t,x,con,rs,Com,objADsPath,objDomain,iLoop,bolFound,strdepartments
strdepartments=""
%>
<html>
<head>
<script type="text/javascript">
function listlink(a,q)
{
for (var c = 0; c <= q; c++)
{if (document.departmentchoice.departmentname[c].checked) b = document.departmentchoice.departmentname[c].value;}
open('list.asp?letter='+a+'&department='+b,'ListFrame');
open('info.asp','InfoFrame');
open('blank.htm','EmailFrame');
}
function reflist()
{
open('list.asp','ListFrame');
open('blank.htm','InfoFrame');
open('blank.htm','EmailFrame');
}
</script>
<title>Phone List</title>
<style>
.over { background-color: #FFFF66; cursor: hand}
.out { background-color: #CCCCCC}
</style>
</head>
<body bgcolor="#CCCCCC" topmargin="0" leftmargin="0">
<%
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 objectCategory='person' AND department='*' ORDER BY department"
Set rs = Com.Execute
Do While Not rs.EOF
dim myarray
myarray=split(strdepartments,",")
bolFound = False
For iLoop = LBound(myarray) to UBound(myarray)
If CStr(myarray(iLoop)) = CStr(rs("department")) Then
bolFound = True
End If
Next
IF bolFound = False Then
If strdepartments="" then
strdepartments=rs("department")
Else
strdepartments=strdepartments&","&rs("department")
End If
End If
rs.MoveNext
Loop
rs.Close
dim deparray
deparray=split(strdepartments,",")
t=UBound(deparray)+1
%>
<form name="departmentchoice">
<table border="1" cellpadding="0" cellspacing="0" width="550">
<tr><td colspan="26" valign="middle" align="center" height="20"><p><font face="Tahoma" size="1"><b>
<input type="radio" onclick="reflist();" name="departmentname" value="*" checked>All
<%For iLoop = LBound(deparray) to UBound(deparray)%>
<input type="radio" onclick="reflist();" name="departmentname" value="<%response.write deparray(iLoop)%>"><%response.write deparray(iLoop)%>
<%Next%>
</b></font></p></td>
</tr>
<tr>
<%For x = 65 to 90%>
<td onMouseOver="this.className='over'" onMouseOut="this.className='out'" class="out" width="20" height="20" valign="middle" align="center" onclick="listlink('<%response.write chr(x)%>','<%response.write t%>');"><a><b><font color="#000080" face="Verdana" size="2"><%response.write chr(x)%></font></b></a></td>
<%Next%>
</tr>
<tr>
<td valign="top" colspan="10"><IFRAME NAME="ListFrame" FRAMEBORDER="0" SCROLLING="AUTO" SRC="list.asp" width="223" height="458"></IFRAME></td>
<td valign="top" colspan="16"><IFRAME NAME="InfoFrame" FRAMEBORDER="0" SCROLLING="AUTO" SRC="blank.htm" width="320" height="125"></IFRAME>
<IFRAME NAME="EmailFrame" FRAMEBORDER="0" SCROLLING="AUTO" SRC="blank.htm" width="320" height="330"></IFRAME></td>
</tr>
</table>
</form>
</body>
</html>