Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP Classic and Basic Authentication

Posted on 2010-08-27
2
Medium Priority
?
895 Views
Last Modified: 2012-05-10
I have an ASP Classic web site that is running on an IIS that is setup for Basic Authentication with anonymous access disabled.  I also have a login script that requires the user to type in a username and then validates it across active directory for their password, once validated it then creates several cookies to be used throughout the site.

Right now when you navigate to the site for the first time, you have to login to the windows authentication prompt, then login again at my login page.  Is there a way to capture the basic authentication username and password and have it pass to the login I already have?

I have included some of the code that I am using for the login validation page.
'**************************
'Active Directory CheckSum
'**************************	
On Error Resume Next	
if (not strUserName= "") then
		
	strADsPath = "WinNT://" & strADsPath
	Dim oADsObject  
	Dim tempstr
	tempstr = strDomain & "\" & strUserName
	
	Set oADsObject = GetObject(strADsPath)
	
	Dim strADsNamespace
	Dim oADsNamespace
	strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
	set oADsNamespace = GetObject(strADsNamespace)
	Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr, strPassword, 0)
	
	if not (Err.number = 0) then				
		Response.redirect"login.asp?Message=Please provide a correct login name<br>or system password for the " & strDomain & " domain!<br>"
		'response.write err.description & "<p>"
		if err.number = -2147022987 then ' for account logout
			Response.write "<strong>Your account has been logged out!</strong>"
		end if
		
	else				
		Dim strProj, Objrs
		Set Objrs = Server.CreateObject("ADODB.Recordset")
		Call OPEN_DB
		If AreYouATech = 1 Then
			strProj = "SELECT * FROM tblTechnician Where username = '" & StrUserName & "'"
		Else
			strProj = "SELECT * FROM tblNonTechnician WHERE ClientEmplID = " & StrUserName
		End If
		Set Objrs = MyConn.Execute(strProj)
		
		If NOT Objrs.EOF Then
			If AreYouATech = 1 Then
				'Cookies Go Here
			Else
				Dim RSClient, SQLClient
				Set RSClient = Server.CreateObject("ADODB.Recordset")
				Call OPEN_DB
				SQLClient = "SELECT * FROM tblClient WHERE ClientEmplID = " & StrUserName
				Set RSClient = MyConn.Execute(SQLClient)
				
				'Cookies Go Here
			End If
		Else
			Set Objrs = Nothing
			Set ObjConn = Nothing
			Response.redirect"login.asp?Message=Invalid UserName! Please try again"
		End If
	End If
End If

Open in new window

0
Comment
Question by:LouSch7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 14

Expert Comment

by:wolfman007
ID: 33542940
Request.ServerVariables("LOGON_USER") will pick up the username for the user when you are using Basic Authentication

see the following website

Authentication Methods in IIS
http://www.4guysfromrolla.com/webtech/020201-1.shtml
Request.ServerVariables("LOGON_USER")

Open in new window

0
 
LVL 14

Accepted Solution

by:
wolfman007 earned 2000 total points
ID: 33542995
You could also try using

Request.ServerVariables("AUTH_USER") Returns the raw authenticated user name

Request.ServerVariables("AUTH_PASSWORD") Returns the value entered in the client's authentication dialog

ASP ServerVariables Collection
http://www.w3schools.com/asp/coll_servervariables.asp
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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