determine Username ?

kcwallace

Centurion
Joined
May 27, 2004
Messages
175
Location
Austin, TX
It is my understanding that the below code is the best way to determine a users network name in an ASP.Net page. However when I run it I get an empty string. Can someone help?

Visual Basic:
Imports System.Security
Imports System.Security.Principal.WindowsPrincipal

Dim logon_str As String = HttpContext.Current.User.Identity.Name
Dim str_int As Integer
str_int = logon_str.IndexOf("\")'for some reason it this forum is dropping the "back slash".  It is there in the real code
logon_name = HttpContext.Current.User.Identity.Name.Substring(str_int + 1)
 
Yes, for that you need to check IIS to see if anonymous connections are allowed, if so you should disable it and allow only Windows Authentication.
 
Back
Top