簡體   English   中英

從Windows Store應用程序使用Windows Auth調用WCF服務

[英]Calling a WCF service using Windows Auth from a Windows Store App

我在為Win Auth配置的本地計算機上已將WCF服務部署到IIS

<basicHttpBinding>
    <binding name="NewBinding0">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </basicHttpBinding>

我有一個測試WPF項目,它可以正常工作。 我試圖創建Windows Store應用程序,並使用登錄的(域)用戶調用該服務,但無法使該服務正常工作,我的用戶是域用戶,可以通過調用Windows.System.UserProfile.UserInformation.GetDomainNameAsync()看到它Windows.System.UserProfile.UserInformation.GetDomainNameAsync()

如果實現部分ConfigureEndpoint並顯式設置憑據,則可以正常使用該服務-

        static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials)
    {
        clientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("<domain>\\<username>", "<password>");
    }

但是如果我只是把

clientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

我收到以下錯誤

{“ HTTP請求通過客戶端身份驗證方案'Ntlm'被未經授權。從服務器收到的身份驗證標頭為'Negotiate,NTLM'。”}

我已經配置了企業身份驗證和專用網絡(客戶端和服務器)功能

在登錄的域用戶的上下文中,我需要怎么做才能調用該服務?

(我發現了這個懸而未決的問題 ,可能是同一問題,但還沒有答案嗎?

原來,該問題是由於我在筆記本電腦上托管該服務(用於測試)並使用“ localhost”調用它的結果。

我已經將相同的服務部署到我們域中的另一台服務器上,並更新了應用程序中的終結點地址,並且一切正常。

似乎本地主機上的Windows應用商店調用服務受到限制

如果我顯式提供憑據,但不確定是否僅攜帶登錄的用戶,則不太確定為什么這樣可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM