2014-10-14 4 views
0

activex 객체를 사용하지 않고 원격 서버에서 호스팅되는 asp.net에서 클라이언트 윈도우 사용자 이름을 얻는 것이 가능합니까?activex 객체를 사용하지 않고 windows 사용자 이름을 얻으십시오

내가 다음 코드를 사용했다

 Response.Write("HttpContext.Current.Request.LogonUserIdentity.Name " & HttpContext.Current.Request.LogonUserIdentity.Name) 
     Response.Write("<br/>") 
     Response.Write("HttpContext.Current.Request.IsAuthenticated " & HttpContext.Current.Request.IsAuthenticated) 
     Response.Write("<br/>") 
     Response.Write("HttpContext.Current.User.Identity.Name " & HttpContext.Current.User.Identity.Name) 
     Response.Write("<br/>") 
     Response.Write("System.Environment.UserName " & System.Environment.UserName) 
     Response.Write("<br/>") 
     Response.Write("Security.Principal.WindowsIdentity.GetCurrent().Name() " & System.Security.Principal.WindowsIdentity.GetCurrent().Name()) 
     Response.Write("<br/>") 

하지만 항상하지 클라이언트 사용자 이름 나에게 서버 사용자 이름을주고있다.

+0

가상 디렉토리/응용 프로그램이 구성되는 방법 ? –

+2

Windows 인증을 사용하는 경우에만 가능합니다. –

+0

이 정보에 액세스하는 방법은 가능하지만 모든 브라우저에서 다릅니다 (존재하는 경우). 예를 들어 Mozilla FireFox는 [nsIEnvironment] (https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIEnvironment)를 사용합니다. 따라서 자바 스크립트는 먼저 브라우저를 감지 한 다음 이에 따라 Windows 사용자 이름에 액세스합니다. 또한 C#을 사용하는 경우 [WAFFLE] (http://dblock.github.io/waffle/)을 사용할 수 있습니다. [출처] (https://github.com/dblock/waffle) – Hillboy

답변

-1

당신은

string Hostname=Request.ServerVariables["REMOTE_HOST"]; 
string Username=Request.ServerVariables["REMOTE_USER"]; 
+0

_ "[REMOTE_USER] 사용자 이름이 Windows 계정에 매핑되기 전에 클라이언트 **가 보낸 승인 헤더에서 파생 된 ** 사용자 이름 웹 서버에 인증 필터가 설치되어있는 경우 들어오는 사용자를 계정에 매핑하는 경우 LOGON_USER를 사용하여 매핑 된 사용자 이름을 봅니다. " –

-2

이 줄 당신이

Response.Write("HttpContext.Current.User.Identity.Name " & HttpContext.Current.User.Identity.Name) 

심판 "Windows 인증"을 사용하는 경우 작동 역시 ServerVariables를 사용하려고 할 수 있습니다 MSDN