Getting Windows Username

J

Jonathan Dixon

I am developing an intranet and was wondering, when a user logs on is there
a way to get the username of the windows account in asp.net.

I have tried the following but they return the worker process username e.g
DOMAIN\ASPNET

Can somone suggest a way or provide some code the get the username of the
logged on account in windows

Thanks
Jonathan Dixon

User.Identity.Name.ToString();

System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
 
J

Jonathan Dixon

Sorry it was just a matter of disabling anononous access, will this have any
implications
 
A

Andy Fish

Jonathan Dixon said:
Sorry it was just a matter of disabling anononous access, will this have any
implications

sure it will. if you are running with anonymous access, the app runs in the
security context of the worker process. If you are using windows
authenticated access, the app will run in the security context of the logged
on user. For instance, file permissions etc will depend on the user
accessing the application.

also, obviously people without a windows account will not be able to access
the application

whether this is a problem for your specific application depends on what the
app does.
 
J

Jonathan Dixon

I have came accross a problem when putting it on a server it ust get the
servers logon name,

Is there a way, it will be a intranet and users will logon with the user
account onto windows, the intranet web page will then appear, i want the
intranet web page to get the account name from the person logged on to the
computer in the asp.net page.


I hope that is clear i am not sure how to phrase it so


if i logon as

Jonathan

the asp.net webpage would get Jonathan


at the same time a colleague logs on to windows as andrew, the intranet web
page loads up and get his username which is andrew.

Any idea how to do this.

Regards

Jonathan Dixon
 
A

Andy Fish

in internet services manager, go to web site properties, directory security,
anonymous access, and ensure that only 'integrated windows authentication'
is checked
 
J

Jonathan Dixon

I have done that but it returns the name of the user logged on at the server
not the client running the intranet on the system they are logged on at.

Thanks for your continuing help

Regards

Jonathan Dixon
 
U

user

Jonathan said:
I have done that but it returns the name of the user logged on at the server
not the client running the intranet on the system they are logged on at.

Thanks for your continuing help

Regards

Jonathan Dixon

Hello,

Add the following to the AUTHENTICATION of web.config

<authentication mode="Windows" />

Chiefdnd
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top