Groups | Blog | Home
all groups > asp.net security > july 2007 >

asp.net security : How to find Current User Name


Herb
7/23/2007 7:34:03 AM
When I run my ASP.NET application from my development PC,
Me.User.Identity.Name works. When I run it from my Intranet site, it does
not. Any suggestions?
Herb
7/23/2007 8:18:04 AM
No luck. This yields a blank string.
These are my three lines of code:
Response.Write(">" & Me.User.Identity.Name & "<<BR>")
Response.Write(">" & System.Security.Principal.WindowsIdentity.
GetCurrent().Name & "<<BR>")
Response.Write(">" & Context.User.Identity.Name & "<")

When run locally yields:
[quoted text, click to view]

When run on the Intranet yields:
[quoted text, click to view]


From

[quoted text, click to view]
Herb
7/23/2007 10:16:00 AM
oops! it's always the simple things, isn't it? Incidentally,
Me.User.Identity.Name also works. Is there a preferred method?

[quoted text, click to view]
Dominick Baier
7/23/2007 3:02:21 PM
Use

Context.User.Identity.Name


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

Dominick Baier
7/23/2007 3:58:14 PM
Then i guess you have'nt disabled anonymous auth on your intranet server
(in IIS)...
-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

Dominick Baier
7/23/2007 5:22:26 PM
Me implies that you are on a page - Context works everywhere...
-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

AddThis Social Bookmark Button