1

Windows 인증을 사용하는 WCF 서비스가있는 Silverlight 응용 프로그램이 있습니다. 사용자가 올바르게 인증됩니다. 그리고 클라이언트 측에서 사용자 이름과 역할에 액세스 할 수 있습니다. 그러나 서버 측에서 어떻게 동일한 작업을 수행합니까? 내가 해봤이WCF 서비스에서 Windows 인증을 사용하여 서버 측 사용자 이름에 액세스하려면 어떻게합니까?

ServiceSecurityContext.Current.WindowsIdentity 

그것은 내가 여기에 유래에 비슷한 질문에 대한 답변으로 발견하지만 컴파일하지 않는 것입니다
IIdentity caller = ServiceSecurityContext.Current.PrimaryIdentity; 

. 'ServiceSecurityContext에 현재 정의에 대한 정의가 없습니다.'예외가 발생합니다.

그래서 서버 측에서 사용자를 얻으려면 어떻게해야합니까?

답변

1

내가 이것을 시도,

HttpContext.Current.User; 

희망이

+1

를 서비스가 ASP.NET 호환성 모드로 설정되어있는 경우에만 작동합니다. – syneptody

+0

정말요? 요청 헤더에서 사용자 이름을 가져 오지 않습니까? –

+0

에 따르면 : http://msdn.microsoft.com/en-us/library/aa702682.aspx "HttpContext : Current는 WCF 서비스에서 액세스 할 때 항상 null입니다. 대신 RequestContext를 사용하십시오." ... ASP.NET 호환성으로 서비스가 장식되어 있지 않은 경우 – syneptody

2
public static string GetUserIdentity() 
{ 
    return OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name; 
} 

OperationContext는 System.ServiceModel 네임 스페이스에 있습니다.

+1

흠을하는 데 도움이 노력하지만, 내 ServiceSecurityContext가 null .. – grabah