2013-07-11 73 views
0

我有一個WCF服務,它也使用SharePoint的用戶配置文件服務。 當我嘗試在IIS上運行服務時出現此錯誤。WCF身份驗證綁定錯誤

主機 (「IntegratedWindowsAuthentication」)上配置的認證方案不允許 的結合「的WSHttpBinding」(「匿名」)的那些配置。請確保將 SecurityMode設置爲Transport或TransportCredentialOnly。 此外,這可以通過改變認證 方案爲通過IIS管理工具本申請中,通過 的ServiceHost.Authentication.AuthenticationSchemes屬性,則 應用配置文件中的 元件,通過在更新ClientCredentialType屬性來解決綁定, 或通過調整 HttpTransportBindingElement上的AuthenticationScheme屬性。

這裏是我的web.config

<bindings> 
<basicHttpBinding> 

    <binding name="UserProfileServiceSoap" closeTimeout="00:01:00" 
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
    useDefaultWebProxy="true"> 
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
    maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
    <security mode="TransportCredentialOnly"> 
    <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" /> 
    <message clientCredentialType="UserName" algorithmSuite="Default" /> 
    </security> 
    </binding> 

</basicHttpBinding> 
<wsHttpBinding> 

    <binding name="HttpBinding1" maxReceivedMessageSize="2147483647" receiveTimeout="10:00:00" openTimeout="10:00:00" 
    sendTimeout="10:00:00" closeTimeout="10:00:00" bypassProxyOnLocal="false" transactionFlow="false" 
    hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288000" allowCookies="false"> 
    <security mode="None"/> 
    </binding> 

    <binding name="WSHttpBinding_MessageSecurity" maxReceivedMessageSize="2147483647" receiveTimeout="10:00:00" 
    openTimeout="10:00:00" sendTimeout="10:00:00" closeTimeout="10:00:00" bypassProxyOnLocal="false" 
    transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288000" allowCookies="false"> 
    <security mode="Message"> 
    <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""> 
    <extendedProtectionPolicy policyEnforcement="Never"/> 
    </transport> 
    <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/> 
    </security> 
    </binding> 

</wsHttpBinding> 
</bindings> 

services> 
<service name="UserProfileWcf.UserProfileService" behaviorConfiguration="UserProfileWcf.UserProfileServiceBehavior"> 
<!-- Service Endpoints --> 
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpBinding1" contract="UserProfileWcf.ServiceContract.IUserProfileService" name="UserProfileServiceEndpoint"> 
<identity> 
<dns value="localhost"/> 
</identity> 
</endpoint> 
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
</service> 
</services> 
<behaviors> 
<serviceBehaviors> 
<behavior name="UserProfileWcf.UserProfileServiceBehavior"> 
<!-- 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"/> 
<dataContractSerializer maxItemsInObjectGraph="65536000"/> 
<serviceThrottling maxConcurrentSessions="2147483647"/> 
</behavior> 
</serviceBehaviors> 
</behaviors> 
     <client> 
      <endpoint address="http://xyz/_vti_bin/userprofileservice.asmx" 
        binding="basicHttpBinding" bindingConfiguration="UserProfileServiceSoap" 
        contract="SharePointUserProfileService.UserProfileServiceSoap" 
        name="UserProfileServiceSoap" /> 
     </client> 

相同的配置工作正常,我的本地機器上。我的綁定出錯了?

+1

我認爲你用wsHttpBinding爲其中一個端點定義了一個配置是HttpBinding1,它的安全模式設置爲none。看起來您在IIS中託管服務(因此IIS充當服務主機)時,您已使用Windows身份驗證。嘗試將安全模式設置爲Transport for HttpBinding1,或嘗試將IIS身份驗證更改爲匿名以查看其是否有效。 – vibhu

+0

當你說相同的配置在你的機器上工作正常時,你的意思是開發環境嗎? – vibhu

+0

工作的人(允許匿名)。 :\ 我很驚訝。我多麼想念這麼一個小而重要的事情。感謝Vibhu,請單獨發佈您的答案,所以我可以將其標記爲答案 – Nanu

回答

1

我認爲你用來爲wsHttpBinding定義一個端點的配置是HttpBinding1,它的安全模式設置爲none。看起來您在IIS中託管服務(因此IIS充當服務主機)時,您已使用Windows身份驗證。嘗試將安全模式設置爲Transport for HttpBinding1,或嘗試將IIS身份驗證更改爲匿名以查看其是否有效。