【发布时间】:2009-08-12 23:39:45
【问题描述】:
如何通过代码获取SharePoint中某个组内所有用户的列表?
【问题讨论】:
标签: c# sharepoint
如何通过代码获取SharePoint中某个组内所有用户的列表?
【问题讨论】:
标签: c# sharepoint
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);
}
}
}
【讨论】:
我改用了第一行,它起作用了。谢谢老兄:)
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/>"));
}
}
【讨论】: