如何检索 SharePoint 2013 网站 (SPWeb) 上所有用户的列表?
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 对象上搜索一些 method\propery,但找不到解决方案
很简单。你甚至不必打开 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;
}
});
}
我正在开发 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 对象上搜索一些 method\propery,但找不到解决方案
很简单。你甚至不必打开 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;
}
});
}