2010-12-22 39 views
0

我是否處於Catch-22狀態?我的目標是採用我繼承的WCF服務,並在虛擬機上運行它,並通過從臺式PC中調用它進行測試。虛擬機在工作組中,而不在公司的域中。基本上,我們需要更多的測試環境,理想情況下每個開發者一個(我們可能有2到4個人需要這個)。因此,虛擬機的想法是,每個開發人員都可以擁有自己的Web服務器,這個服務器可以在一定程度上匹配或者真實環境(我們實際上有兩個網站,一個外部/暴露內部)。 [使用VS2010 .NET 4.0]試圖在非域虛擬機上運行WCF Web服務,安全錯誤

在內部服務,每種方法被裝飾與此屬性:

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 

我還在研究爲什麼這種需要。我認爲這是因爲webapp調用「內部」服務,並且a)我們需要用戶的憑據,或者b)我們可以執行一些PrinciplePermission.Demands來查看用戶是否在一個組中。我的興趣是創建一些ConsoleTest程序或UnitTest程序。

我改爲允許這樣的:

[OperationBehavior(Impersonation = ImpersonationOption.Allowed)] 

,因爲我是在試圖在瀏覽器中查看.SVC收到此錯誤:

的承包經營「EditAccountFamily」要求Windows身份自動模擬。代表調用者的Windows身份不是通過綁定('WSHttpBinding','http://tempuri.org/')爲合同提供的('IAdminService','http://tempuri.org/'。

與原來的綁定這個樣子我沒有得到錯誤:

不過,我相信我需要關閉此安全性,因爲Web服務是不是在域

我傾向於在客戶端得到這些錯誤:

1)安全令牌的請求不能滿足,因爲身份驗證失敗 - 作爲「SecurityNegotiation未處理」的InnerException。

2)呼叫者不是由服務認證爲的「SecurityNegotiation是未處理的」一個的InnerException。

因此,我可以創建一些配置的代碼和web.config,這將允許每個開發人員在他自己的VM上工作嗎?還是必須將虛擬機加入域?

排列的數量似乎接近無窮。我已經開始創建一個Word.doc來說明如何處理每個錯誤,但是現在我處於被卡住的catch-22中。

感謝,

尼爾


服務器綁定:

<bindings> 
    <wsHttpBinding> 
    <binding 
     name="wsHttpEndpointBinding" 
     maxBufferPoolSize="2147483647" 
     maxReceivedMessageSize="500000000"> 
     <readerQuotas 
     maxDepth="2147483647" 
     maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" 
     maxBytesPerRead="2147483647" 
     maxNameTableCharCount="2147483647" /> 
     <!-- <security mode="None" /> This is one thing I tried --> 
     <security> 
     <message 
      clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

<behaviors> 
    <serviceBehaviors> 


    <behavior 
     name="ABC.AdminService.AdminServiceBehavior"> 
     <!-- To avoid disclosing metadata information, set the value below to false and 
      remove the metadata endpoint above before deployment --> 
     <serviceMetadata 
     httpGetEnabled="true" /> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. 
      Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug 
     includeExceptionDetailInFaults="true" /> 
     <serviceCredentials> 
     </serviceCredentials> 
     <!--<serviceAuthorization principalPermissionMode="UseAspNetRoles" 
      roleProviderName="AspNetWindowsTokenRoleProvider"/>--> 
     <serviceAuthorization 
     principalPermissionMode="UseWindowsGroups" 
     impersonateCallerForAllOperations="true" /> 
    </behavior> 

    </serviceBehaviors> 

</behaviors> 


<serviceHostingEnvironment 
    multipleSiteBindingsEnabled="true" /> 

客戶:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IAdminService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
        enabled="false" /> 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="Windows" negotiateServiceCredential="true" 
         algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://192.168.159.132/EC_AdminService/AdminService.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAdminService" 
      contract="svcRef.IAdminService" name="WSHttpBinding_IAdminService"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

更新12/27/2010: 即使這樣簡單的方法獲取SecurityNegotiation錯誤:

[OperationBehavior(Impersonation = ImpersonationOption.Allowed)] 
public string TestHelloWorldOpen(string name) 
{ 
    return "Hello1 " + name; 
} 
+0

請發佈您的客戶端和服務器綁定。 – 2010-12-22 22:39:30

+0

@Greg:綁定張貼 – NealWalters 2010-12-22 23:56:05

回答

0

嘗試並從安全因素服務器和客戶端綁定。

問題可能是由於服務器和客戶端安全元素之間不匹配造成的。通常,當WCF出現問題時,這是因爲綁定配置中存在錯誤。一個好的故障排除策略是刪除所有不必要的配置元素,然後嘗試將它們逐個添加回來 - 從而隔離問題。

0

你在你的問題說:

...the idea of the VM was that each developer could have his own web server that somewhat matches our real environment.

我的意思是,你將有這樣的問題跟你把使用Windows身份驗證,直到你把它放在域VM每個應用程序。我不認爲這是一個WCF特定的問題。這是一個信任來自不可信域的憑證的問題。另外,我假設你的真實環境是在一個域上,所以要真正匹配你的虛擬機應該在一個域上的環境。

(回覆評論):我只是假設你可能有多個應用程序。我可能是錯的。但是,如果您在ASP.NET中使用Windows身份驗證,則會遇到此問題。

最不理想的情況是在應用程序和服務中使用自定義代碼,以使它們在特殊的測試/開發環境中運行。