简体   繁体   中英

Getting Client username in VB.Net

I am trying to get the client domain\\username from a VB.Net application.

When I use

System.Security.Principal.WindowsIdentity.GetCurrent().Name

I get the results I want. But only when running it locally through visual studio / iisexpress But When I try to put it on my IIS 7.5 (on windows 2008 server), the program will stop when it gets to running this line of code. It just stops.

using this

on Error GoTo test_Error

test_Error: 
Error_Handler(writes errors to a sql log) 

The error is not caught.

So what is going on? Thanks!

UPDATE: Using the 'Try-catch' here

            Try
               MsgBox(System.Security.Principal.WindowsIdentity.GetCurrent().Name)
            Catch ex As Exception
               MsgBox(ex.Message)
            End Try

and still cannot get an error message to show (Chrome broswer, yes popups are enabled)

Using chrome developer tools I found this was the error:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

Try this -

Request.ServerVariables("AUTH_USER")

This will return raw authenticated username.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM