Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling Active Directory Info into ASP

Status
Not open for further replies.

Rikkimaru

Programmer
Feb 2, 2005
16
0
0
US
I have an interesting challenge.

I'm working with an application that currently allows users to log in, validate themselves via username and password located in a database and then change user-specific details.

I have windows machines on my network. Is there a way to pull windows active directory information using ASP? Specifically, I want ASP to retrieve a client's network user-name.

The idea is to have the user's network name captured by ASP and then the database can searched using the client's user-name.

I know that it's kinda crazy, but what would life be without experimentation?
:)
 
I use the 'Display User Information' script by Ralph Montgomery Link
as a reference.
I think you will find your answer here...

Hope this helps...

_____________________________________
Feed a man a fish and feed him for a day.
Teach a man to fish and feed him for a lifetime...
 
Thanks for the help K0b3
Here's what I came up with on my own though...
This isn't the complete code, but it is the section I was having trouble with.

In addition to this, I turned Anonymous Authentification off and turned Windows Authentification on in IIS.

It works fine right now except for people who don't have their emails configured properly either in Active Directory or the SQL Database.

Code:
Dim login
Dim email

'LOGON_USER is a server variable and it gets the user's network name in the 'form DOMAIN\User

login = Request.ServerVariables("LOGON_USER")



'This following code makes the email variable equal to to login name of the user at the machine
'Hence if the LOGON_USER variable = DOMAIN\USER then email = USER

email = Mid(login, (InStr(login, "\")+1))


'This query searches the database for an instance where the email = USER@DOMAIN.com

DIM sqlquery
sqlquery = "SELECT * FROM Persons WHERE MailAddress = '"&email&"@DOMAIN.com'"

Set login_search=SQLCONNECTION.execute(sqlquery)



DO while not login_search.eof

dim database_login
database_login=login_search("MailAddress")

dim database_password
database_password=login_search("Password")

login_search.movenext 
LOOP



login_search.close
SQLCONNECTION.close
set SQLCONNECTION = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top