Closed Thread Icon

Topic awaiting preservation: getting username with ASP Pages that link to <a href="https://ozoneasylum.com/backlink?for=12515" title="Pages that link to Topic awaiting preservation: getting username with ASP" rel="nofollow" >Topic awaiting preservation: getting username with ASP\

 
Author Thread
Ensabanur
Bipolar (III) Inmate

From: KY
Insane since: Nov 2001

posted posted 11-21-2002 19:24

Is it possible to get the username of the person logged on the computer with ASP? I know I can get the IP and the broswer info. I really need to get the username

Any help would be appreciated

Ensa

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 11-21-2002 20:06

From a webpage? nuh uh



.:[ Never resist a perfect moment ]:.

stinx
Bipolar (III) Inmate

From: London, UK
Insane since: Apr 2002

posted posted 11-22-2002 13:21

The only way you can do that is to force user authentication on your site. If it's ASP, I assume you're using some version of IIS, which will allow you to set authentication on part or all of the site. IIRC it's usually an NT/2K/XP user account that needs to log on, and you can use normal file permissions to control what they can see, if you want to go that far.

If you have access to that level of admin for your server, and you set user authentication for your site, then Request.ServerVariables("AUTH_USER") will give you the username.

Ensabanur
Bipolar (III) Inmate

From: KY
Insane since: Nov 2001

posted posted 11-22-2002 16:56

Figured it wasn't.
So now I'm trying to create an ASP page by using a vbscipt that "document.write"'s the asp code.
I don't even know if it's possible to get it to work.
I wrote it but when I try to view it it says that
document.write("<%") is an unterminated string. Am I correct in assuming I can't do this?

here's the full code

___________

code:
<script Language="VBScript">
Dim ObjNet
on Error resume next
set ObjNet = createobject("wscript.network")

username=ObjNet.UserName
domain=ObjNet.UserDomain

total=0

document.write("dim connect")
document.write("connect ='DBQ=' & Server.Mappath('admin/calendar.mdb') & ';Driver={Microsoft Access Driver (*.mdb)};'")

document.write("Dim connection")
document.write("set connection = server.createobject('adodb.connection')")

document.write("connection.connectionTimeout=30")
document.write("connection.commandtimeout = 80")
document.write("connection.open connect")

document.write("dim rs")
document.write("set rs = server.createobject('adodb.recordset')")
document.write("rs.open 'select * from personal where user= '&username, connection, 1, 3")
document.write("rs.close")
document.write("set rs = nothing")
document.write("connection.close")
document.write("set connection=nothing")
document.write(username)
</script>



Any Help would be appreciated

Ensa

stinx
Bipolar (III) Inmate

From: London, UK
Insane since: Apr 2002

posted posted 11-25-2002 15:52

What you just tried to do was get your browser to run asp code. That's not going to work, as you found out. If this is on a public web server then you'll have to come up with some other way of authenticating users, be it through sessions and logins, password protected directories or whatever.

If you can get to the database via a network share, then you could just use client side vbscript to open up a connection and do the command. Instead of calling createobject('adodb.connection') in the server scope, you can just call it in the client, same as you called createobject("wscript.network"). Your browser might scream about security, but you're contemplating using the script host to get the network details, so I'm guessing you don't care about that.


« BackwardsOnwards »

Show Forum Drop Down Menu