473,410 Members | 1,976 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,410 software developers and data experts.

Environment.UserName

I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen
Jun 27 '08 #1
10 4154
What if you try System.Web.HttpContext.Current.User.Identity.Name instead ?

System.Environment is rather related to the server side Windows process
rather than to the IIS context for a web connexion....

--
Patrice

"Helen Trim" <He*******@discussions.microsoft.coma écrit dans le message
de groupe de discussion :
3C**********************************@microsoft.com...
I am developing a web application in Visual Studio 2003, .NET 1.1 to run
on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen

Jun 27 '08 #2
Hello Patrice

Thanks for your reply. I tried this, but it gave me an empty string.

Any more ideas, please?

Regards
Helen
"Patrice" wrote:
What if you try System.Web.HttpContext.Current.User.Identity.Name instead ?

System.Environment is rather related to the server side Windows process
rather than to the IIS context for a web connexion....

--
Patrice

"Helen Trim" <He*******@discussions.microsoft.coma crit dans le message
de groupe de discussion :
3C**********************************@microsoft.com...
I am developing a web application in Visual Studio 2003, .NET 1.1 to run
on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen

Jun 27 '08 #3

ASPNET is the default "user name" the ASP.Net process uses
to log into the IIS service.

Nothing to do with the user browsing your pages.

Regards,

Joergen Bech

On Wed, 4 Jun 2008 07:55:01 -0700, Helen Trim
<He*******@discussions.microsoft.comwrote:
>Hello Patrice

Thanks for your reply. I tried this, but it gave me an empty string.

Any more ideas, please?

Regards
Helen
"Patrice" wrote:
>What if you try System.Web.HttpContext.Current.User.Identity.Name instead ?

System.Environment is rather related to the server side Windows process
rather than to the IIS context for a web connexion....

--
Patrice

"Helen Trim" <He*******@discussions.microsoft.coma crit dans le message
de groupe de discussion :
3C**********************************@microsoft.com...
I am developing a web application in Visual Studio 2003, .NET 1.1 to run
on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen

Jun 27 '08 #4
So IsAuthenticated is false ? Do you have an auhtentication method in place
on your site ?

If not try :

http://www.microsoft.com/technet/pro....mspx?mfr=true

--
Patrice

"Helen Trim" <He*******@discussions.microsoft.coma écrit dans le message
de groupe de discussion :
9C**********************************@microsoft.com...
Hello Patrice

Thanks for your reply. I tried this, but it gave me an empty string.

Any more ideas, please?

Regards
Helen
"Patrice" wrote:
>What if you try System.Web.HttpContext.Current.User.Identity.Name instead
?

System.Environment is rather related to the server side Windows process
rather than to the IIS context for a web connexion....

--
Patrice

"Helen Trim" <He*******@discussions.microsoft.coma crit dans le message
de groupe de discussion :
3C**********************************@microsoft.com...
I am developing a web application in Visual Studio 2003, .NET 1.1 to
run
on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen

Jun 27 '08 #5
Hello -

What about using Dim lUser =
Environment.GetEnvironmentVariable("USERNAME")?

Joe

On Jun 4, 11:18*am, "Patrice" <http://www.chez.com/scribe/wrote:
So IsAuthenticated is false ? Do you have an auhtentication method in place
on your site ?

If not try :

http://www.microsoft.com/technet/pro...ver2003/Librar...

--
Patrice

"Helen Trim" <HelenT...@discussions.microsoft.coma écrit dans le message
de groupe de discussion :
9C7525B3-2AB9-4227-A3F9-90D988B2F...@microsoft.com...
Hello Patrice
Thanks for your reply. *I tried this, but it gave me an empty string.
Any more ideas, please?
Regards
Helen
"Patrice" wrote:
What if you try System.Web.HttpContext.Current.User.Identity.Name instead
?
System.Environment is rather related to the server side Windows process
rather than to the IIS context for a web connexion....
--
Patrice
"Helen Trim" <HelenT...@discussions.microsoft.coma crit dans le message
de groupe de discussion :
3C128B85-81D3-492A-B75D-F848AB618...@microsoft.com...
I am developing a web application in Visual Studio 2003, .NET 1.1 to
run
on
our intranet. *I want to identify users to save them logging in.
The line:
UserName = Environment.UserName
is returning "ASPNET", instead of my user name.
I have read all the Help documentation, but I can't find any reason why
this
isn't working.
Am I missing a reference or import? *I have added a reference to
System.Security.dll. *My imports are:
Imports System
Imports System.Configuration
Imports System.Security.Principal
Imports System.Security.Permissions
Imports System.Threading
Thanks for your help,
Helen- Hide quoted text -

- Show quoted text -
Jun 27 '08 #6
Would be likely the same. Environment is not related with the web context
but with the server side process that runs ASP.NET...

Step 1 is to make sure an authentication method is actually configured.
Step 2 is then to get the user identity from System.web.HttpContext.User
(which is also exposed on web pages).

User authentication is dealt between the browser and IIS, it does not
necessarily have something to do with the identity that actually runs
ASP.NET processes server side...

--
Patrice
"Joe Duchtel" <du*****@gmail.coma écrit dans le message de groupe de
discussion :
97**********************************...oglegroups.com...
Hello -

What about using Dim lUser =
Environment.GetEnvironmentVariable("USERNAME")?

Joe

On Jun 4, 11:18 am, "Patrice" <http://www.chez.com/scribe/wrote:
>So IsAuthenticated is false ? Do you have an auhtentication method in
place
on your site ?

If not try :

http://www.microsoft.com/technet/pro...ver2003/Librar...

--
Patrice

"Helen Trim" <HelenT...@discussions.microsoft.coma écrit dans le
message
de groupe de discussion :
9C7525B3-2AB9-4227-A3F9-90D988B2F...@microsoft.com...
Hello Patrice
Thanks for your reply. I tried this, but it gave me an empty string.
Any more ideas, please?
Regards
Helen
"Patrice" wrote:
>What if you try System.Web.HttpContext.Current.User.Identity.Name
instead
?
>System.Environment is rather related to the server side Windows
process
rather than to the IIS context for a web connexion....
>--
Patrice
>"Helen Trim" <HelenT...@discussions.microsoft.coma crit dans le
message
de groupe de discussion :
3C128B85-81D3-492A-B75D-F848AB618...@microsoft.com...
I am developing a web application in Visual Studio 2003, .NET 1.1 to
run
on
our intranet. I want to identify users to save them logging in.
The line:
UserName = Environment.UserName
is returning "ASPNET", instead of my user name.
I have read all the Help documentation, but I can't find any reason
why
this
isn't working.
Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:
Imports System
Imports System.Configuration
Imports System.Security.Principal
Imports System.Security.Permissions
Imports System.Threading
Thanks for your help,
Helen- Hide quoted text -

- Show quoted text -
Jun 27 '08 #7
Helen,

The user that is running a WebApplication is ASPNET.

A user that is using the WebApplication is in fact unknown on your
environment, it can be thousands. Normally this is handled by a logon
procedure where you set the user after the authentiated login in in a
session.

As you wish, you can avoid the next login procedure by using cookies.
However every user from the client computer even a malicious one can then
login on your application.

Cor

"Helen Trim" <He*******@discussions.microsoft.comschreef in bericht
news:3C**********************************@microsof t.com...
>I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen
Jun 27 '08 #8

Hello ,,,
The process is running in the server context ,,, however on a corporate
network you could use windows authentication and so determine wich user is
logged on to the website
"Helen Trim" <He*******@discussions.microsoft.comschreef in bericht
news:3C**********************************@microsof t.com...
>I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen

Jun 27 '08 #9
Thanks for your advice, everyone. I found the answer by following the link
from Patrice. Turning off anonymous access in IIS solved the problem.

Regards
Helen

"Helen Trim" wrote:
I am developing a web application in Visual Studio 2003, .NET 1.1 to run on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen
Jun 27 '08 #10

By switching of anonymous access you are actually using windows
authentication , note that unknown users from outside your known corporate
environment ( active directory ? ) cannot access the website unless you
activate some kind of authentication

regards

Michel
"Helen Trim" <He*******@discussions.microsoft.comschreef in bericht
news:4A**********************************@microsof t.com...
Thanks for your advice, everyone. I found the answer by following the
link
from Patrice. Turning off anonymous access in IIS solved the problem.

Regards
Helen

"Helen Trim" wrote:
>I am developing a web application in Visual Studio 2003, .NET 1.1 to run
on
our intranet. I want to identify users to save them logging in.

The line:

UserName = Environment.UserName

is returning "ASPNET", instead of my user name.

I have read all the Help documentation, but I can't find any reason why
this
isn't working.

Am I missing a reference or import? I have added a reference to
System.Security.dll. My imports are:

Imports System

Imports System.Configuration

Imports System.Security.Principal

Imports System.Security.Permissions

Imports System.Threading

Thanks for your help,

Helen

Jun 27 '08 #11

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

Similar topics

1
by: DMc2004 | last post by:
I have serveral items I would to find out how to do: 1) How to get the username of the person currently logged onto a workstation; 2) How to get the username of who is logged onto a different...
4
by: 1qa2ws | last post by:
Hi, I need to get the windows current logged username and domain. Is it any possibility? 1qa2ws
5
by: Prisy | last post by:
In asp.net(C#) we can get the Process Name of a process using the following code: System.Diagnostics.Process item; item.ProcessName.ToString(); Is there a way to get the User Name of a...
3
by: John | last post by:
Hi Is it possible to get the currently logged in username in windows 2000/xp? Thanks Regards
2
by: news.microsoft.com | last post by:
Hello, I want to create a program that will monitor the usage of a particular file and record the date, time, and username of the person who modified the file. The FileSystemWatcher Class...
11
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then the process starts as the specified user, but hangs in a suspended state. In fact, any...
1
by: Marie Mercier | last post by:
Hi, would anyone know how, in VB.NET to capture a username of anyone who accesses my machine from our LAN. I have used System.Diagnostics, but I get no username or machine name. I have been asked...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, Does VS2005 have anything buildin to retrieve the Directory path for C:\Documents and Settings\UserName\Start Menu\Programs... Like an application has Application.StartupPath Or do...
1
by: cc | last post by:
Under what circumstances for a windows form app will Environment.Username return empty?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.