[英]How to retrieve the list of all user on a SharePoint 2013 website (SPWeb)?
我正在使用SharePoint 2013應用程序,但遇到以下問題。 在我的代碼中,我有這樣的東西:
List<string> urlList = IndirizziProtocolliSQL.GetListaIndirizziSiti(dbConfig);
foreach (string currentUrl in urlList)
{
Debug.Print("Current url: " + currentUrl);
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
using (SPSite oSiteCollection = new SPSite(currentUrl))
{
using (SPWeb oWebsite = oSiteCollection.OpenWeb())
{
// RETRIEVE THE LIST OF USERS OF THE CURRENT SITE
}
}
});
}
如您所見,我正在檢索SharePoint應用程序中的網站列表(工作正常)。
對於當前站點(由SPWeb oWebSite變量表示),我必須檢索已注冊到該網站的所有用戶的列表。
我該怎么做? 我試圖在oWebsite對象上搜索一些方法\\屬性,但找不到解決方案
這很簡單。 您甚至不必打開SPWeb。
List<string> urlList = IndirizziProtocolliSQL.GetListaIndirizziSiti(dbConfig);
foreach (string currentUrl in urlList)
{
Debug.Print("Current url: " + currentUrl);
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
using (SPSite oSiteCollection = new SPSite(currentUrl))
{
# Gets the collection of all users that belong to the site collection.
SPUserCollection users = oSiteCollection.RootWeb.SiteUsers;
}
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.