Environment.UserName

  • Thread starter Thread starter Helen Trim
  • Start date Start date
H

Helen Trim

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

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

Any more ideas, please?

Regards
Helen
 
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
 
Hello -

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

Joe
 
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
 
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
 
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
 
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
 
Back
Top