【问题标题】:How to get a list of all users in SharePoint如何获取 SharePoint 中所有用户的列表
【发布时间】:2009-08-12 23:39:45
【问题描述】:

如何通过代码获取SharePoint中某个组内所有用户的列表?

【问题讨论】:

    标签: c# sharepoint


    【解决方案1】:
    using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
    {
        SPGroupCollection collGroups = oWebsite.Groups;
        foreach (SPGroup oGroup in collGroups)
        {
            foreach(SPUser oUser in oGroup.Users)
            {
               Response.Write(oUser.Name);
            }
        }
    }
    

    【讨论】:

    【解决方案2】:

    我改用了第一行,它起作用了。谢谢老兄:)

    SPGroupCollection collGroups = SPContext.Current.Web.Groups;
    
     foreach (SPGroup oGroup in collGroups)
                    {
                        foreach (SPUser oUser in oGroup.Users)
                        {
                            Response.Write(oUser.Name);
    
                        Label l = new Label();
                        l.Text = oUser.Name;
    
                        PlaceHolderContents.Controls.Add(l);
                        PlaceHolderContents.Controls.Add(new LiteralControl("<br/>"));
                    }
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-17
      • 2017-01-12
      • 2022-01-02
      • 2020-06-23
      • 1970-01-01
      • 2021-10-31
      • 2011-12-24
      • 1970-01-01
      相关资源
      最近更新 更多