2013-06-20 87 views
0

我正在試圖製作一個程序,用於從CRM創建Sharepoint中的文件夾結構(即代碼從Microsoft CRM 2011運行)。但是,我的目標之一是通過輸入不同的URL來動態訪問多個SharePoint站點。在運行時訪問SharePoint Web服務

這個想法是,給定一個共享點URL和適當的憑據,代碼仍然能夠與Sharepoint網站進行交互。但是,我試圖避免爲每個Sharepoint站點添加服務引用(可能包括尚未創建的站點)。

所以,我想知道,是否有可能在運行時只提供URL和憑據訪問Sharepoint,或者每次建立新的SP站點時是否需要創建單獨的服務引用?

謝謝!

回答

0

您可以使用動態Web服務引用。

看一看 http://www.codeproject.com/Articles/12317/How-to-make-your-Web-Reference-proxy-URL-dynamic

如果您正在使用SharePoint客戶端對象API,您可以設置的網址和密碼動態。在您的app.config文件中配置url和密碼。

using (ClientContext clientcontext = new ClientContext("http://yourspserverurl/")) { 
     clientcontext.Credentials = new NetworkCredential("username", "password", "domain"); 
     List list = clientcontext.Web.Lists.GetByTitle("your sharepoint list"); 
     clientcontext.ExecuteQuery(); 

} 

對於SharePoint 2013

Please see my bloghttps://mydevexperience.wordpress.com/2013/10/20/sharepoint-2013-office-365-authentication-using-sharepoint-client-object-model/