Solved

How to get more values from LDAP with Classic ASP

Posted on 2013-02-06
3
1,157 Views
Last Modified: 2013-02-06
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.Connection")
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
0
Comment
Question by:Donnie Walker
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Tony Massa earned 500 total points
ID: 38861753
Are you trying to authenticate as some other account, or are you searching for information (attributes) for just the one "strUser" person?

http://blogs.technet.com/b/heyscriptingguy/archive/2005/12/09/how-can-i-use-alternate-credentials-when-searching-active-directory.aspx
0
 

Author Comment

by:Donnie Walker
ID: 38861775
I have the user logging in with HTTP Basic Authentication and I then pass that to the function above.

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.
0
 
LVL 17

Expert Comment

by:Tony Massa
ID: 38861954
Maybe this link will give you some ideas
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
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Do you have users whose passwords are expiring and they are constantly calling you?  Well I sure did and needed a way to put an end to this.  We have a lot of remote users which would not be notified that their passwords were expiring since they wer…
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now