Retrieve Domain Logon

  • Thread starter Thread starter tjonsek
  • Start date Start date
T

tjonsek

I am trying to pull the user logon info in an application to use as a
security stamp when someone completes a function. So far, I am able to
retrieve the computer name. This is, however, not what I'm looking for.

For example, if Sally logs on to the domain as 'sallyJ', then I'd like
to be able to pull the logon 'sallyJ' when she clicks a button.

Here is the code I am using:

(Before declarations)
Imports System.Security
Imports System.Security.Principal.WindowsIdentity

IN a sub btnName_Click():
Dim user As String
user = GetCurrent.Name.ToString

So far, if 'sallyJ' logs onto the network and is using a PC named
'sally_PC', then I get 'sally_PC' when I am really wanting 'sallyJ'.

I appreciate any help or direction you can give me.
 
WindowsIdentity.GetCurrent.Name should work... on my machine it gives me the
logon name in the form of 'domain\username'
 
Maybe this has to do with the fact that it is a web form. I don't know
the implications of webform vs. windows form, but I am only able to get
my computer name in this manner 'computername\ASPNET'.

If anyone here can help, please tell me.
If not, I'll pose this question to a specific ASP.NET group.
Thanks!
 
If you're doing this in a web form, you will get the ASPNET user if
anonymous access is on.

To be able to retrieve the user's current network name, you have to enable
windows authentication and impersonation (see the ASP.NET online docs for
more details - or indeed a asp.net newsgroup :-) ) .

Hope this helps...
 
Yes, to an extent it has. I have read quite a bit today in terms of
authentication and impersonation. I have set impersonation to 'true'
and authentication to 'windows'. The difference I saw was in getting
'computername\IUSER_computername'. I feel I am a step closer and am
wondering if a configuration in IIS could be causing the difference I
see. I also noted that authorization is set to allow all users. I don't
believe this is related or causing my issues.
Thanks.
 
My problem was due to configuration settings in IIS. I did a little
research and found that security was set to allow anonymous users. I
changed this to require Integrated Domain Authentication and it worked
like a charm.
Thanks for your help.
 
Back
Top