2011-04-27 52 views
0

保護WCF服務我想使用我在asp.net網站中使用的Active Directory自定義主體,該自定義主體用於託管服務。使用以下代碼設置導航網站和自定義校長時一切正常使用NTLM CustomBinding和asp.net中的自定義委託人保護WCF

static void context_AuthenticateRequest(對象發件人,EventArgs e) { CustomIdentity identity; CustomPrincipal principal = GetPrincipalFromCookie();

 if (principal == null) 
     { 
      ... create principal from active directory 
      ... Store Principal in a cookie 
     } 

     HttpContext.Current.User = principal; 
     Thread.CurrentPrincipal = principal; 
    } 

然而,當我做一個WCF調用我的服務會出現一個登錄對話框刪除行HttpContext.Current.User =在登錄主要結果對話框未出現,但就是對我沒有用,因爲我需要在這爲我的應用程序填充WebUserSecurityContext。我使用customBinding使用NTLM

 <httpTransport authenticationScheme="Ntlm" 
     maxBufferSize="2147483647" 
     maxReceivedMessageSize="2147483647" 
     maxBufferPoolSize="2147483647" proxyAuthenticationScheme="Anonymous"/> 
    </binding> 
    </customBinding> 

我失去了我的配置,以防止此登錄對話框,或是否有更好的辦法設置?任何幫助,將不勝感激

回答

0

HttpContext.Current不考慮,直到AspNetCompatibilityMode啓用。您是否已啓用AspNetCompatibilityMode進行維修?

+0

嗨AspNetCompatibilityMode已經啓用服務 – Shay 2011-05-11 12:09:25