get user's network name

Hi all,

I am using VB 2005 in a click-once app. I am trying to get the user name. I have tried My.User.Name with no luck. It returns "". I have also tried

Security.Principal.WindowsIdentity.GetCurrent.Name.ToString but get an error about the request failing.

I have also tried this with a return of "":

IfTypeOfMy.User.CurrentPrincipalIs _

Security.Principal.WindowsPrincipalThen

' The application is using Windows authentication.

' The name format is DOMAIN\USERNAME.

Dim parts()AsString = Split(My.User.Name,"\")

usrName = parts(1)

' The application is using custom authentication.

Else

' The application is using custom authentication.

usrName =My.User.Name

EndIf

Any other ideas?

Thanks.

[2027 byte] By [SteveHempen] at [2007-12-22]
# 1
Problem solved. I used System.Environment.UserName.
SteveHempen at 2007-8-30 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2

Foud this searching for "GET LOGGED ON USER NAME"

http://msdn2.microsoft.com/en-us/library/ts4s4536.aspx

Hope it helps.

Rabtok at 2007-8-30 > top of Msdn Tech,Visual Basic,Visual Basic Language...