[英]How to retrieve the list of all user on a SharePoint 2013 website (SPWeb)?
I am working on a SharePoint 2013 application and I have the following problem. 我正在使用SharePoint 2013应用程序,但遇到以下问题。 Into my code I have something like this:
在我的代码中,我有这样的东西:
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
}
}
});
}
As you can see I am retriueving the list of the sites in a SharePoint application (it works fine). 如您所见,我正在检索SharePoint应用程序中的网站列表(工作正常)。
For the current site (represented by the SPWeb oWebSite variable) I have to retrieve the list of all the user registered to this website. 对于当前站点(由SPWeb oWebSite变量表示),我必须检索已注册到该网站的所有用户的列表。
How can I do it? 我该怎么做? I was trying to search some method\\propery on the oWebsite object but I can't findi a solution
我试图在oWebsite对象上搜索一些方法\\属性,但找不到解决方案
It is very simple. 这很简单。 Yo don't even have to open SPWeb.
您甚至不必打开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.