I've been attempting to retrieve the username from within a .NET web
application and have been having difficulties getting the right
result.
example code:
using System.Security.Principal;
this.textname = WindowsIdentity.GetCurrent().Name;
This code returns COMPUTER_NAME\ASPNET in my case but I'm trying to
return my actual username.
I currently have Window XP Pro set up with a user account requiring a
password on my development machine.
I used a quick vbscript to confirm to myself that it is possible to
retrieve the information I'm looking for.
example code:
Option Explicit
'Script to open Internet Explorer
Dim objIE
Set objIE = CreateObject("internetexplorer.application")
objIE.Navigate "http://aime.halifax.mil.ca/aime/notifications.aspx?
guest=true"
objIE.Visible=True
'Script to retrieve username from network
dim wshShell
dim strUserName
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
WScript.Echo "User Name: " & strUserName
Any ideas on how to achieve the same results while in c#?
Thanks, i.code
--
To unsubscribe, reply using "remove me" as the subject.