getting a network username

zeocrash

Newcomer
Joined
Sep 15, 2004
Messages
8
ok right i'm writing an intranet page for my company.
The idea of the page is basically to let a user to select items off a list and thenthen send the order to an e-mail address.

the problem i'm having is simple, i need to get the network logon name of the user.
at the moment i'm using the following code.
Code:
        Dim uname As String
        Dim myDetails As System.Security.Principal.WindowsIdentity = GetCurrent()
        If Not myDetails.IsAnonymous Then
            uname = myDetails.Name
        End If
when I run this code, it gives me "NT AUTHORITY\NETWORK SERVICE" as the username instead of DKA2, my actual username. how do i get this to show my actual username
 
Dim username As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name

Is what I have been using
 
You are getting the name of the account IIS is running as. If you wish to get the name of the user logged in to your web application then you could use
Code:
User.Identity.Name
 
thanks, i solved my problems in the end. it turns out that the solution involved putting
Code:
<identity impersonate="true"/>
into web.config.
it seems my problems were arrising from the fact that web.config is case sensitive :(
 
Back
Top