2011-12-29 4 views
0

어떤 사용자가 서버 측에서 WCF Ria 서비스를 호출하는지 알 수 있습니까? 클라이언트 측은 siverlight이므로 시스템을 사용하려면 먼저 사용자를 인증해야합니다.클라이언트 측에서 실버 라이트를 사용하여 서버 측에서 WCF Ria 서비스를 호출하는 사용자를 알 수 있습니까?

실제로 현재 작업에서 어떤 사용자가 서비스를 호출하고 있는지 알아야합니다. 덕분에 검색이 많이되었지만 좋은 결과는 없습니다.

답변

0

일단 클라이언트 측에서 인증 시도를 성공적으로 완료하면 서버는 클라이언트 측의 호출자에게 토큰을 발급 할 수 있습니다. 서버에 대한 후속 호출에서 클라이언트는 토큰을 인수 중 하나로 보내고 서버는 토큰을 확인하고 그에 따라 응답합니다.

토큰에는 지정된 사용자를 식별하는 정보 세그먼트가 포함될 수 있으며이를 구현하면 원하는 기능을 제공 할 수 있습니다.

토큰을 생성하는 유일한 지침은 고유하고 예측할 수 없으며 만료 될 수 있다는 것입니다. 나는 항상 토큰을 암호화하여 횡설수설 한 것처럼 보이지만 단계는 선택 사항입니다.

0

"googleing"을 많이했기 때문에 해결책을 찾기 전에 많은 골칫거리를 겪었습니다. 나는 RIA 서비스를 사용하지 않는다. 그러나 그것은 (희망을 갖고) 같은 것이어야한다. ... :

SL-Client는 "login-request"를 서버에 보낸다. 제 (WCF) 서버 측에

, 나는 (SL-Client에 대한 LoginData은 = 반환-정보를) 다음을 수행하십시오 당신은 사용자 WindowsPrincipal을 확인하려면

public LoginData LoginRequest() { 
    (...) 
    OperationContext context = OperationContext.Current; 
    System.ServiceModel.Channels.MessageProperties prp = context.IncomingMessageProperties; 
    System.ServiceModel.Channels.RemoteEndpointMessageProperty endPrp = prp[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty; 
     (...) 
     try { 
      clientIP = endPrp.Address; 
      System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse(clientIP); 
      System.Net.IPHostEntry ipHostEntry = System.Net.Dns.GetHostEntry(ipAddress); 
     (...) 

, 당신은 다음을 수행 할 수 있습니다 (사용자가 로그인 할 수 있습니다에는 SecurityGroup = 서버 측 설정) :

(...) 
    switch (securityGroup) { 
      case SecurityGroup.AllClientsCanAccess: { 
       clientCanLogin = true; 
      } break; 
      case SecurityGroup.UseWindowsCredentials: { 
       if (OperationContext.Current.ServiceSecurityContext != null && OperationContext.Current.ServiceSecurityContext.WindowsIdentity != null) { 
         if (OperationContext.Current.ServiceSecurityContext.WindowsIdentity.IsAuthenticated) { 

          if (subSecurityInfo1 == true) { // only clients in specific roles can log in 
           bool userRoleFound = false; 

           WindowsPrincipal userPrincipal = new WindowsPrincipal(OperationContext.Current.ServiceSecurityContext.WindowsIdentity); 
           if (userPrincipal == null) 
            break; 

           foreach (string userRoleToPass in subSecurityList) { // subSecurityList = settings, which roles can pass 

            loginError.ErrorInfo += string.Format("{0}\n", userRoleToPass); 

            if (userPrincipal.IsInRole(userRoleToPass)) { 
             clientCanLogin = userRoleFound = true; 
             break; 
            } 
           } 

           if (userRoleFound) { 
            loginError.ErrorInfo = string.Empty; 
            break; 
           } 
           else { 
            loginError.ErrorNo = LoginErrorCodeNoEnum.UserIsNotInRole; 
           } 
          } 
          (...) 

는 희망이 도움이 ...

관련 문제