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 strUsername,con,rs,Com,objADsPath,objDomain,membership,group
%>
<html>
<head>
</head>
<body>
<%
strUsername = "<put the user name in here>"
strUserName = Right(strUserName, Len(strUserName) - InStrRev(strUserName, "\"))
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 memberof FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
membership=rs("memberof")
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
For each group in membership
response.write group&"<br>"
Next
%>
</body>
</html>
strSQL="select memberof FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
membership=recordset("memberof")
For each group in membership
response.write group&"<br>"
Next
strSQL="select AdsPath from 'GC://"+domainName+"' WHERE sAMAccountname ='"+userName+"'"
username=Request.ServerVariables("AUTH_USER")
username=lcase(Right(username, Len(username) - InStrRev(username, "\")))
set ADSysInfo = CreateObject("ADSystemInfo")
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
if IsArray(CurrentUser.MemberOf) then
strGroups = LCase(Join(CurrentUser.MemberOf))
else
strGroups = LCase(CurrentUser.MemberOf)
end if
set ADSysInfo = nothing
set CurrentUser = nothing
if instr(strGroups, "cn=cst") then
cstcheck=1
end if