简体   繁体   English

如何在SharePoint 2013网站(SPWeb)上检索所有用户的列表?

[英]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.

相关问题 如何在SharePoint 2013中检索当前用户的声明 - How to retrieve claims for current user in SharePoint 2013 如何使用控制台应用程序[C#]检索成员的所有Sharepoint 2013 FBA用户? - How to retrieve all Sharepoint 2013 FBA user of a membership using console application [C#]? 如何从FieldLookupValue Sharepoint 2013 CSOM中检索关联的列表名称 - How to retrieve associated list name from a FieldLookupValue Sharepoint 2013 CSOM 如何使用 powershell/c# 列出 SharePoint 中的所有 2013 工作流 - How to list all 2013 workflows in SharePoint using powershell/c# 如何使用 SharePoint 2013 事件接收器按正确顺序检索列表项附件 - How to retrieve list item attachments with SharePoint 2013 Event Receiver in correct order C# 从 SharePoint 2013 文档库中检索文档列表 - C# Retrieve Document List From SharePoint 2013 Document Library 如何以编程方式检索EPi Server网站的所有已启用语言的列表? - How to retrieve a list of all enabled languages for the EPi Server website programmatically? 如何在SharePoint 2013工作流中检索仅限日期字段的正确值 - How to retrieve correct value of date only field in SharePoint 2013 workflow 将网站另存为SharePoint 2013中的文档 - Saving website as document in SharePoint 2013 在SharePoint 2010中保存/检索网站特定(SPWeb)数据的最佳实践是什么? - What is the best practice to save/retrieve site specific (SPWeb) data in SharePoint 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM