<%@ LANGUAGE=VBSCRIPT %>
<%Option Explicit%>
<%
dim user
user=Request.ServerVariables("LOGON_USER")
Session("user")=user
'response.write(user)
Function getADUserInfo(strUID)
on error resume next
strGeneralLookupError = false
strBase = ""
strFilter = "(sAMAccountName=" & strUID & ")"
strAttributes = "cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber, employeeid, extensionattribute15, displayname, distinguishedName, memberOf"
'strAttributes = "cn, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
strScope = "subtree"
strFullCommand = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope
set rsADUserInfo = Server.CreateObject("ADODB.Recordset")
set rsADUserInfo = connAD.Execute(strFullCommand)
if err.number <> 0 then
strGeneralLookupError = true
end if
set getADUserInfo = rsADUserInfo
set rsADUserInfo = Nothing
End Function
Sub getUserData(p_strUserID)
on error resume next
set rsUserData = Server.CreateObject("ADODB.Recordset")
set rsUserData = getADUserInfo(p_strUserID)
if not rsUserData.EOF then
Session("name") = rsUserData("displayname")
'strUserSN = rsUserData("sn")
'strUserOU = rsUserData("company")
'strUserEmail = rsUserData("mail")
session("group") = rsUserData("distinguishedName")
session("passuser") = rsUserData("memberOf")
else
strADLookupSuccess = false
end if
rsUserData.Close
set rsUserData = Nothing
End Sub
on error resume next
response.expires = 0
DIM connAD, rsUserData, rsADUserInfo
DIM strUserGN, strUserSN, strUserOU, strUserEmail, strUserPhone, test
DIM strBase, strFilter,strAttributes, strScope, strFullCommand
DIM strGeneralLookupError, strADLookupSuccess
DIM strUserID
strUserGN = "The user can not be found in the system."
strGeneralLookupError = false
strADLookupSuccess = true
set connAD = Server.CreateObject("ADODB.Connection")
connAD.Provider = "ADsDSOObject"
connAD.Properties("User ID") = "school\adminuser" ' ### remember to make sure this user has rights to access AD
connAD.Properties("Password") = "*******"
connAD.Properties("Encrypt Password") = true
connAD.Open
strUserID = "user"
call getUserData(strUserID)
connAD.Close
set connAD = Nothing
response.write("Name: "&Session("name")&" ")
response.write("Pass Username: "&Session("passuser")&" ")
response.write("Group: "&Session("group")&" ")
%>
I have this code for ASP and I can not see the groups of this user any help please??
Thanks,
ACE