Sharepoint沙盒解决方案在Office 365中不起作用

时间:2012-02-03 13:47:57

标签: sharepoint sharepoint-2010 web-parts sandbox office365

我构建了一个沙箱webpart解决方案,该解决方案遍历当前Web的所有组,并显示已定义组的所有成员。在我的本地SharePoint 2010实例中,webpart正是应该做的,但在云端我没有输出。我试过显示所有可用的组,但webpart也没有显示,我的代码出了什么问题?

protected override void RenderContents(HtmlTextWriter writer)
{
    base.RenderContents(writer);

    foreach (string name in GetGroupMembers())
        writer.Write(name);
}

public StringCollection GetGroupMembers()
{
    StringCollection groupMemebers = new StringCollection();
    SPGroupCollection groups = SPContext.Current.Web.Groups;

    //for each item in the collection of groups
    foreach (SPGroup group in groups)
        //display all users from the defined group
        if (group.ToString().Equals(DEFINED_GROUP))
            foreach (SPUser user in group.Users)
                groupMemebers.Add(user.Name);

    return groupMemebers;
}

1 个答案:

答案 0 :(得分:2)

解决它:

SPGroupCollection groups = SPContext.Current.Site.RootWeb.Groups;

在我的本地SharePoint中,我只在根网站上测试过它。