473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Struggling to get windows UserName into an ASP variable

I am a newsbie to ASP but need to get a script together that will insert the
Windows Username of the local machine into an access database.

I get the errors from my code below, can anyone help me please as I've hit a
deadend:

Thanks

CODE:

<% @ Language="VBScript" %>

<%'force authentication- put this at top of ASP code

If Request.ServerVariables("LOGON_USER") = "" Then

Response.Status = "401 access denied"

End If

Username=(Request.ServerVariables("LOGON_USER"))

'declare variables

dim connection

dim sSQL,sConnString

'declare SQL statement that will query the database

sSQL="INSERT INTO Log (Name) VALUES (Username)"

'define the connection string, specify database

' driver and the location of database

sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _

"DBQ=" & Server.MapPath("ServerLog.mdb") & ";"

'create an ADO connection object

Set connection = Server.CreateObject("ADODB.Connection")

'Open the connection to the database

connection.Open(sConnString)

'execute the SQL

connection.execute(sSQL)

'check to see if there were any errors

If err.number=0 Then

response.write "the data was inserted successfully."

Else

response.write "there was a problem entering the data."

End If

'close the object and free up resources

Connection.Close

Set Connection = Nothing

%>


Jul 19 '05 #1
3 8828
What you need to do is actually change a setting in IIS for this page or
directory or site. You have to turn OFF anonymous access and enable one of
the settings that uses Windows authentication, preferably Integrated Windows
Authentication. Take a look here at the authentication methods available
and what they all mean.

http://www.iisfaq.com/?View=A26

Ray at home

"Newbie" <Ne****@nospam.com> wrote in message
news:yRq5c.215$PA5.52@newsfe1-win...
I am a newsbie to ASP but need to get a script together that will insert the Windows Username of the local machine into an access database.

I get the errors from my code below, can anyone help me please as I've hit a deadend:

Thanks

CODE:

<% @ Language="VBScript" %>

<%'force authentication- put this at top of ASP code

If Request.ServerVariables("LOGON_USER") = "" Then

Response.Status = "401 access denied"

End If

Username=(Request.ServerVariables("LOGON_USER"))

Jul 19 '05 #2
sSQL="INSERT INTO Log (Name) VALUES ('" & replace(Username."'","''") & "')"

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Newbie" <Ne****@nospam.com> wrote in message
news:yRq5c.215$PA5.52@newsfe1-win...
I am a newsbie to ASP but need to get a script together that will insert the Windows Username of the local machine into an access database.

I get the errors from my code below, can anyone help me please as I've hit a deadend:

Thanks

CODE:

<% @ Language="VBScript" %>

<%'force authentication- put this at top of ASP code

If Request.ServerVariables("LOGON_USER") = "" Then

Response.Status = "401 access denied"

End If

Username=(Request.ServerVariables("LOGON_USER"))

'declare variables

dim connection

dim sSQL,sConnString

'declare SQL statement that will query the database

sSQL="INSERT INTO Log (Name) VALUES (Username)"

'define the connection string, specify database

' driver and the location of database

sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _

"DBQ=" & Server.MapPath("ServerLog.mdb") & ";"

'create an ADO connection object

Set connection = Server.CreateObject("ADODB.Connection")

'Open the connection to the database

connection.Open(sConnString)

'execute the SQL

connection.execute(sSQL)

'check to see if there were any errors

If err.number=0 Then

response.write "the data was inserted successfully."

Else

response.write "there was a problem entering the data."

End If

'close the object and free up resources

Connection.Close

Set Connection = Nothing

%>

Jul 19 '05 #3
He can in fact use that code to force authentication.

The problem in this case is that he's not using the variable "Username"
correctly in his line:
sSQL="INSERT INTO Log (Name) VALUES (Username)"
(as pointed out by Mark S)

--
Tom Kaminski IIS MVP
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://mvp.support.microsoft.com/
http://www.microsoft.com/windowsserv...y/centers/iis/

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:eo**************@TK2MSFTNGP09.phx.gbl...
What you need to do is actually change a setting in IIS for this page or
directory or site. You have to turn OFF anonymous access and enable one of the settings that uses Windows authentication, preferably Integrated Windows Authentication. Take a look here at the authentication methods available
and what they all mean.

http://www.iisfaq.com/?View=A26

Ray at home

"Newbie" <Ne****@nospam.com> wrote in message
news:yRq5c.215$PA5.52@newsfe1-win...
I am a newsbie to ASP but need to get a script together that will insert the
Windows Username of the local machine into an access database.

I get the errors from my code below, can anyone help me please as I've

hit a
deadend:

Thanks

CODE:

<% @ Language="VBScript" %>

<%'force authentication- put this at top of ASP code

If Request.ServerVariables("LOGON_USER") = "" Then

Response.Status = "401 access denied"

End If

Username=(Request.ServerVariables("LOGON_USER"))


Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shannon Wright | last post by:
I am trying to request form elements from a form from a page that looks like this: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html;...
5
by: Zille Hassan | last post by:
Dear All Newbie question here. i design form to take input from user(username,password). How do i autheticate if the user is Windows Domain user and once it has authenticated successfully, how...
1
by: Micromanaged | last post by:
Trying to set up an asp page where the rank and file employees can view the results of an Access 2k database with the standard links, etc. Certain employees have been tasked with updating things in...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to...
5
by: nikou_70 | last post by:
I have a problem with ("auth_user") in asp,I try to use windows username and password in asp page for limitation user access to pages, but this server variable returns empty string, can you help me...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
0
JamieHowarth0
by: JamieHowarth0 | last post by:
I have been trying to find a solution to this on the Internet for months. Literally, ages and ages and ages, praying that someone in the open-source community has enough knowledge to put together an...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.