我有一個C#應用程序,它通過客戶端代理使用web服務。 Web服務設置爲使用Windows身份驗證(通過Active Directory進行HTTP 401 challange)。我的用戶帳戶被配置爲有權訪問Web服務。C#Webservice代理Windows身份驗證
當我通過瀏覽器調用webservice時,它運行良好。瀏覽器能夠執行401 challange並且不要求任何用戶標識密碼(因爲服務器和客戶端在內部通過AD控制器執行)。
問題是,當我嘗試通過C#應用程序使用服務時,它會拋出HTTP請求未經授權的錯誤。
我已經嘗試了以下所有選項,以便web服務代理執行Windows身份驗證。
ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultCredentials as System.Net.NetworkCredential
ClientCredentials.Windows.AllowedImpersonationLevel =System.Security.Principal.TokenImpersonationLevel.Impersonation
有人可以請幫助我如何使web服務調用就像瀏覽器一樣。在調用服務時,我無法傳遞用戶標識和密碼。