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
response.buffer = true
Dim con,rs,Com,objADsPath,objDomain,objADOU,intUAC
Const ADS_UF_ACCOUNTDISABLE = 2
%>
<html>
<head>
</head>
<body topmargin="0" leftmargin="0" 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.Properties("Cache Results") = False
Com.CommandText ="select userAccountControl,name from 'LDAP://"+objADsPath+"' WHERE objectCategory='person'"
Set rs = Com.Execute
While not rs.eof
intUAC=rs.fields("userAccountControl")
If intUAC AND ADS_UF_ACCOUNTDISABLE Then
response.write rs.fields("name")&" is disabled.<br>"
End If
rs.movenext
Wend
rs.close
set rs=nothing
con.close
set con=nothing
%>
</body>
</html>
Dim RootDSE
Dim UserContainer
Dim User
Dim RelativePathFromDomainToUserContainer
RelativePathFromDomainToUserContainer = "OU=Helpdesk,OU=Beheerders,OU=CAK-USERS,"
Set RootDSE = GetObject("LDAP://RootDSE")
Set UserContainer = GetObject("LDAP://" & RelativePathFromDomainToUserContainer & RootDSE.Get("DefaultNamingContext"))
UserContainer.Filter = Array("User")
For Each User in Usercontainer
Response.Write User.AdsPath & "<BR>"
Next