Jump to content

Recommended Posts

Posted

<%@ 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

Posted
What is your internal DNS domain name, School.com, you need to make sure your search path it right, the easiest way is to look at your AD using ADSI Edit on a server (just be sure not to change anything) this will give you the LDAP search path.
Posted

I can see any thinks like cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber, employeeid, extensionattribute15, displayname, distinguishedName .....

only memberof because the users have multi groups

Posted
ADsPath it is for User OU not for user group

 

You should be able to go higher to the first folder/OU that contains both and then that is your strBase search path.

Posted
By example I am ace i am in 4 groups: IT Groups, Admin group, Programmer Group , and domain admins group I need to get those groups by using asp not only for me for all staff and students

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...