Environment.UserName

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
 
H

Helen Trim

Hello Patrice

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

Any more ideas, please?

Regards
Helen
 
J

Joergen Bech

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
 
J

Joe Duchtel

Hello -

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

Joe
 
C

Cor Ligthert[MVP]

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
 
M

Michel Posseth [MCP]

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
 
H

Helen Trim

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
 
M

Michel Posseth [MCP]

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
 

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

Top