Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WindowsIdentity.GetCurrent

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
I am trying to get the current log in user (DomainName/UserName).. for window authentication for my asp application.

This is what I have so far.. Got this right off MSDN

'Get the current identity and put it into an identity object.
Dim MyIdentity2 As WindowsIdentity = WindowsIdentity.GetCurrent
'Put the previous identity into a principal object.
Dim MyPrincipal2 As New WindowsPrincipal(MyIdentity2)
'Principal values.
Dim PrincipalName2 As String = MyPrincipal2.Identity.Name

This is returning COMPUTERNAME/ASPNET????

How to I get DomainName\USER???

Thanks in advance


 
In the current version of Visual Studio you have to not allow Anonymous access - if it is allowed all users are the default Computername/aspnet... user.

Hope this helps.

Hope everyone is having a great day!

Thanks - Jennifer
 
How can I leave Anonymous access ON and still get DomainName\UserName?

 
I use this~

Dim username As String = Mid(Request.ServerVariables("AUTH_USER"), 5)

Our domain name is three characters long. The fourth character is the slash. Consequently I start with the fifth character.

I shut off anonymous access in IIS. I don't know how to do it with otherwise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top