get username using asp

J

James

I have the following script & I need to get the username (with no
domain info) & feed the username into c:\documents and settings
\username\my documents". So, for instance, if the username is JSmith,
then I'll have
c:\documents and settings\JSmith\my documents below. Thanks

==================================================================================
<HTML>

<HEAD>
<TITLE>This is only a test</TITLE>
</HEAD>
<BODY topmargin="0" leftmargin="0">
<div align="center">
<img border="0" src="picture.gif">

<OBJECT width="994"
CLASSID="CLSID:AAB0606-D808-479A-9398-34879AAA"
ID="application1"
CODEBASE="http://webserver//SupportWebSite/test.CAB#Version=5"
VIEWASTEXT>
</OBJECT>
</div>


<TABLE align="center">
<tr align="center" valign="middle">
<td width="100%" valign="top"><br>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-
serif" size="1">This is only a test.<br>
</font><span class="bodytextblk"><br>
</p>
</td>
</tr>
</TABLE>

</BODY>

</HTML
===================================================================================
 
A

Adrienne Boswell

Gazing into my crystal ball I observed =?Utf-8?B?SmFtZXM=?=
I have the following script & I need to get the username (with no
domain info) & feed the username into c:\documents and settings
\username\my documents". So, for instance, if the username is JSmith,
then I'll have
c:\documents and settings\JSmith\my documents below. Thanks

I'm sorry, but I have to say something here about your markup. Yes,
this is a client side issue, but you should know that writing to
standards will help you in the long run. Using semantic markup, without
presentation is a lot simpler and easier to debug down the line.

At very bottom of this post there is an answer to your original
question. Read on.

======================================================================= =
========== <HTML>

<HEAD>
<TITLE>This is only a test</TITLE>
</HEAD>
<BODY topmargin="0" leftmargin="0">
The topmargin and bottom margin attributes of the TABLE element are
deprecated. Use CSS.
<div align="center">
The align attribute for the DIV element is deprecated. Use CSS.
<img border="0" src="picture.gif">
The alt attribute of the IMG element is required.

<TABLE align="center">
<tr align="center" valign="middle">
<td width="100%" valign="top"><br>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-
serif" size="1">This is only a test.<br>
</font><span class="bodytextblk"><br>
</p>
</td>
</tr>
</TABLE>
This bit is ridiculous! and so 90's! This is an abuse of tables.
Tables are for marking up tabular data. A plain paragraph would be more
suited, and if you wanted to make it center aligned, you could do this:

<style type="text/css">
body {margin:0; font-family: verdana, arial, helvetica, sans-serif;
font-size:70% /*way to small*/; text-align:center;}
</style>
</head>
<body>
<p>What you want to say.</p>
</body>

Isn't that a lot easier? As promised:
[http://www.4guysfromrolla.com/webtech/092298-3.shtml]
Also see:
[http://cavalcade-of-coding.info/fonttext.php] for why verdana is not a
good font for the www.
 
J

James

unfortunately, the <%=Request.ServerVariables("LOGON_USER")%> did not work. I
do not want to make the user login into the website to pull the "logon_user".
This is a big hassle. I want to enable anonymous access. The user logins in
into his/her workstation using his/her userid. Is there anyway thru asp or
other language to pull this info into a webpage? That is, the %username% env
variable is the one that I want to feed into the website. Thanks


Adrienne Boswell said:
Gazing into my crystal ball I observed =?Utf-8?B?SmFtZXM=?=
I have the following script & I need to get the username (with no
domain info) & feed the username into c:\documents and settings
\username\my documents". So, for instance, if the username is JSmith,
then I'll have
c:\documents and settings\JSmith\my documents below. Thanks

I'm sorry, but I have to say something here about your markup. Yes,
this is a client side issue, but you should know that writing to
standards will help you in the long run. Using semantic markup, without
presentation is a lot simpler and easier to debug down the line.

At very bottom of this post there is an answer to your original
question. Read on.

======================================================================= =
========== <HTML>

<HEAD>
<TITLE>This is only a test</TITLE>
</HEAD>
<BODY topmargin="0" leftmargin="0">
The topmargin and bottom margin attributes of the TABLE element are
deprecated. Use CSS.
<div align="center">
The align attribute for the DIV element is deprecated. Use CSS.
<img border="0" src="picture.gif">
The alt attribute of the IMG element is required.

<TABLE align="center">
<tr align="center" valign="middle">
<td width="100%" valign="top"><br>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-
serif" size="1">This is only a test.<br>
</font><span class="bodytextblk"><br>
</p>
</td>
</tr>
</TABLE>
This bit is ridiculous! and so 90's! This is an abuse of tables.
Tables are for marking up tabular data. A plain paragraph would be more
suited, and if you wanted to make it center aligned, you could do this:

<style type="text/css">
body {margin:0; font-family: verdana, arial, helvetica, sans-serif;
font-size:70% /*way to small*/; text-align:center;}
</style>
</head>
<body>
<p>What you want to say.</p>
</body>

Isn't that a lot easier? As promised:
[http://www.4guysfromrolla.com/webtech/092298-3.shtml]
Also see:
[http://cavalcade-of-coding.info/fonttext.php] for why verdana is not a
good font for the www.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
 
B

Bob Barrows

Err ... "anonymous" means "anonymous".
I'm assuming you are doing this for an intranet rather than the
internet, and that the client machine is in the same domain as the web
server (or in a trusted domain). If so, go into the website's properties
in IIS Manager and
1. Enable Integrate Authentication so the user's network credentials are
used to authenticate the user
and
2. Disable Anonymous so the user's login name is put in the Request's
ServerVariables collection.

If this is an internet application, then you are SOL.

Further info
1. You cannot access the %username% evironment variable on the client's
machine from server-side script (or any other information on the
client's machine that is not provided as part of the http request, for
that matter).
2. Default browser security security settings will also prevent
client-side script from accessing this sort of information as well.
Hacker exploits have made browser creators very strict about what
client-side script is allowed to see on a user's machine. I'm not even
sure if this would be possible if the user was convinced to lower his
browser security settings for your site.

unfortunately, the <%=Request.ServerVariables("LOGON_USER")%> did not
work. I do not want to make the user login into the website to pull
the "logon_user". This is a big hassle. I want to enable anonymous
access. The user logins in into his/her workstation using his/her
userid. Is there anyway thru asp or other language to pull this info
into a webpage? That is, the %username% env variable is the one that
I want to feed into the website. Thanks


Adrienne Boswell said:
 
D

Dooza

Bob said:
Err ... "anonymous" means "anonymous".
I'm assuming you are doing this for an intranet rather than the
internet, and that the client machine is in the same domain as the web
server (or in a trusted domain). If so, go into the website's properties
in IIS Manager and
1. Enable Integrate Authentication so the user's network credentials are
used to authenticate the user
and
2. Disable Anonymous so the user's login name is put in the Request's
ServerVariables collection.

I use this method for our intranet. If your using Firefox you need to
change a few hidden settings to allow that server to authenticate you.

Type about:config in the address bar
Find the following and add the address of your intranet server to them:

network.automatic-ntlm-auth.trusted-uris
network.negotiate-auth.delegation-uris
network.negotiate-auth.trusted-uris

I haven't tried any other browser.

Dooza
 
D

Dooza

James said:
I've used the following command to get the currently logged on user:

<% WhoAmI = Request.ServerVariables("LOGON_USER") %>

This returns a value of "Domain\username"

Is there a way to truncate that value by removing "domain\" from it? All I
need is username without the domain prefix. Thanks

<% WhoAmI = REPLACE(Request.ServerVariables("LOGON_USER"),"domain\","") %>

Dooza
 
E

Evertjan.

Dooza wrote on 13 aug 2009 in microsoft.public.inetserver.asp.general:
<% WhoAmI =
REPLACE(Request.ServerVariables("LOGON_USER"),"domain\","") %>

even simpler:

<%
WhoAmI = MID(Request.ServerVariables("LOGON_USER"),8)
%>

============================

but if the length and content of the letters in "domain\" is unknown:

<%
WhoAmI = Request.ServerVariables("LOGON_USER")
WhoAmI = MID(WhoAmI,INSTR(WhoAmI,"\")+1)
%>
 
D

Dooza

Evertjan. said:
Dooza wrote on 13 aug 2009 in microsoft.public.inetserver.asp.general:


even simpler:

<%
WhoAmI = MID(Request.ServerVariables("LOGON_USER"),8)
%>

============================

but if the length and content of the letters in "domain\" is unknown:

<%
WhoAmI = Request.ServerVariables("LOGON_USER")
WhoAmI = MID(WhoAmI,INSTR(WhoAmI,"\")+1)
%>

Very nice, I will keep that one for later use!

Dooza
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top