乾草, 我工作的一個Windows窗體應用程序(C#)連接到SharePoint網站,並從中讀取數據(表)使用特定的用戶名/密碼,連接到SharePoint網站通過winform應用程序
問題是: 如何使用特定的用戶名/密碼連接到站點,而不是使用當前的windows用戶或域用戶。
請指點
編輯:P.S:對SP 2007
我的代碼工作:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite sourceSite = new SPSite(txtBoxSP.Text))
{
SPWeb sourceWeb = sourceSite.RootWeb;
SPUserCollection usrs = sourceWeb.AllUsers;
SPListCollection col = sourceWeb.GetListsOfType(SPBaseType.GenericList);
foreach (SPList list in col)
System.Diagnostics.Debug.WriteLine(string.Format("My Name: {0}, Type: {1}, Length: {2}",
list.Title, list.GetType().ToString(), list.ItemCount.ToString()));
}
});
「Microsoft.SharePoint.SPSite」不包含一個定義爲「憑據」,沒有擴展方法「憑據」接受一個類型的Microsoft.SharePoint程序「第一個參數。 SPSite'可以找到(你是否缺少使用指令或程序集引用?)!請諮詢.. – 2010-11-21 08:52:40
更新:什麼是'網絡'對象?,我猜你提供的關於web部件開發的例子不是winApp,對吧? – 2010-11-21 09:22:31
在這個例子中(編號爲[3]),他們使用一個傳遞給SPSite構造函數的'SPUserToken'。 – 2010-11-21 09:24:36