如何按代码获取SharePoint中某个组中所有用户的列表?
答案 0 :(得分:11)
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);
}
}
}
答案 1 :(得分:6)
我使用了第一行而且它有效。谢谢老兄:)
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/>"));
}
}