Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > get username using asp

Reply
Thread Tools

get username using asp

 
 
James
Guest
Posts: n/a
 
      08-06-2009
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>
<PARAM NAME="URL" VALUE="http://webserver//SupportWebSite" >
<PARAM NAME="PATH" VALUE="c:\documents and settings\\my documents"
>

</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
================================================== =================================
 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      08-06-2009
Gazing into my crystal ball I observed =?Utf-8?B?SmFtZXM=?=
<(E-Mail Removed)> writing in
news:(E-Mail Removed):

> 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.

>


<snip>

>
>
><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

 
Reply With Quote
 
 
 
 
James
Guest
Posts: n/a
 
      08-06-2009
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" wrote:

> Gazing into my crystal ball I observed =?Utf-8?B?SmFtZXM=?=
> <(E-Mail Removed)> writing in
> news:(E-Mail Removed):
>
> > 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.
>
> >

>
> <snip>
>
> >
> >
> ><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
>
>

 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      08-06-2009
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.


James wrote:
> 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" wrote:
>
>> Isn't that a lot easier? As promised:
>> [http://www.4guysfromrolla.com/webtech/092298-3.shtml]



--
HTH,
Bob Barrows


 
Reply With Quote
 
Dooza
Guest
Posts: n/a
 
      08-07-2009
Bob Barrows wrote:
> 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
 
Reply With Quote
 
Dooza
Guest
Posts: n/a
 
      08-13-2009
James wrote:
> 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"),"dom ain\","") %>

Dooza
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-13-2009
Dooza wrote on 13 aug 2009 in microsoft.public.inetserver.asp.general:

> James wrote:
>> 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"),"dom ain\","") %>


even simpler:

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

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

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

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


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Dooza
Guest
Posts: n/a
 
      08-17-2009
Evertjan. wrote:
> Dooza wrote on 13 aug 2009 in microsoft.public.inetserver.asp.general:
>
>> James wrote:
>>> 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"),"dom ain\","") %>

>
> even simpler:
>
> <%
> WhoAmI = MID(Request.ServerVariables("LOGON_USER"),
> %>
>
> ============================
>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get username using asp.net James ASP .Net 2 08-05-2009 09:01 PM
How to get username on IIS run intranet (ASP) Primoz Bradac ASP General 5 08-12-2008 01:46 PM
loginview control displays network username instead of (web) username Shailesh Patel ASP .Net Web Controls 0 11-08-2006 08:19 PM
Get username when using Anonymous Access? jhcorey@yahoo.com ASP .Net 5 10-24-2005 04:59 PM
Change the username found in "C:\Documents and Settings\Username" The Reluctant Robot Named Jude Computer Support 1 05-05-2004 07:11 AM



Advertisments