我試圖調用SharePoint列表服務來獲取列表定義和數據。 SharePoint網站是我的公司,但我無法控制它。這是我所知道的有關服務器的安全性:.NET調用SharePoint Web服務獲取HTTP 401未經授權的異常
服務器是HTTPS:登錄時// 服務器接受的Windows Active Directory憑據...
我已經試過基本,摘要,CredentialCache,剛剛的NetworkCredential,UnsafeAuthenticatedConnectionSharing ,UseDefaultCredentials,預認證...不知道正確的配置是什麼...
我收到的錯誤是HTTP 401未授權。
Uri url = new Uri(baseAddress + "/_vti_bin/Lists.asmx", UriKind.Absolute);
Lists.Lists client = new Lists.Lists();
// sometimes works
CredentialCache cache = new CredentialCache();
cache.Add(url, "NTLM", new NetworkCredential(context.UserName, context.Password, context.Domain));
client.UseDefaultCredentials = false;
client.Credentials = CredentialCache.DefaultCredentials;
// doesn't work ever
//client.Credentials = new NetworkCredential(context.UserName, context.Password, context.Domain);
//client.PreAuthenticate = true;
client.UnsafeAuthenticatedConnectionSharing = true;
client.Url = url.AbsoluteUri;
listData = client.GetList(listName).OuterXml;
當您在瀏覽器中訪問該網站時,請說明您如何正常登錄。 – djeeg 2011-02-10 06:47:59