Donnie Walker
asked on
How to get more values from LDAP with Classic ASP
I have the function below that works, but I need it to give me back the values for sn, givenname, and mail from the LDAP but I cannot figure out how to make it work. Any help is appreciated.
With the following code:
function AuthenticateUser(UserName, Password, Domain)
dim strUser
AuthenticateUser = false
strUser = UserName
strPassword = Password
strQuery = "SELECT cn,sn,givenname,mail FROM 'LDAP://" & strDomain & "' WHERE objectClass='*'"
set oConn = server.CreateObject("ADODB .Connectio n")
oConn.Provider = "ADsDSOOBJECT"
oConn.Properties("User ID") = strUser
oConn.Properties("Password ") = strPassword
oConn.Properties("Encrypt Password") = true
oConn.open "DS Query", strUser, strPassword
set cmd = server.CreateObject("ADODB .Command")
set cmd.ActiveConnection = oConn
cmd.CommandText = strQuery
set oRS = cmd.Execute
if oRS.bof or oRS.eof then
AuthenticateUser = false
else
AuthenticateUser = true
end if
oConn.close
set oRS = nothing
set oConn = nothing
end function
With the following code:
function AuthenticateUser(UserName,
dim strUser
AuthenticateUser = false
strUser = UserName
strPassword = Password
strQuery = "SELECT cn,sn,givenname,mail FROM 'LDAP://" & strDomain & "' WHERE objectClass='*'"
set oConn = server.CreateObject("ADODB
oConn.Provider = "ADsDSOOBJECT"
oConn.Properties("User ID") = strUser
oConn.Properties("Password
oConn.Properties("Encrypt Password") = true
oConn.open "DS Query", strUser, strPassword
set cmd = server.CreateObject("ADODB
set cmd.ActiveConnection = oConn
cmd.CommandText = strQuery
set oRS = cmd.Execute
if oRS.bof or oRS.eof then
AuthenticateUser = false
else
AuthenticateUser = true
end if
oConn.close
set oRS = nothing
set oConn = nothing
end function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe this link will give you some ideas
http://answers.google.com/answers/threadview?id=365115
http://answers.google.com/answers/threadview?id=365115
You can grant them access to the site based on their Windows log-in
simply by unenabling Anonymous access and enabling Integrated Windows
authentication in the IIS console -> Anonymous access and
authentication control -> Edit... dialogue.
Once authenticated with Integrated Windows, you can get their username
through Request.ServerVariables("LOGON_USER" ).
Then use ADSI (Active Directory Services Interface). Pretty easy in
classic ASP and VBScript. Then you can get a user object through ADSI
based on the logged in username and the domain name
ASKER
So, they are logging in.
I just want to get their first, last name and email so I can use it else where.
I got the function some place and now I'm trying to figure out how to grab that data.