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

发布于 2025-01-02 23:05:56 字数 834 浏览 5 评论 0原文

我构建了一个沙箱 Web 部件解决方案,该解决方案运行当前 Web 的所有组并显示已定义组的所有成员。在我的本地 SharePoint 2010 实例中,Web 部件完全执行其应有的操作,但在云中我没有输出。我尝试过显示所有可用组,但 Web 部件也没有显示任何内容,我的代码有什么问题吗?

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;
}

I have build a sandbox webpart solution that runs through all groups of the current web and displays all members of the defined group. In my local SharePoint 2010 instance the webpart does exactly what it should but in the cloud i have no output. I have tried do display all available groups but the webpart also shows nothing, what is wrong with my code?

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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

脱离于你 2025-01-09 23:05:56

解决方法:

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

在我的本地 SharePoint 中,我只在根 Web 中测试了它。

Solved it with:

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

In my locals SharePoint I have only tested it in the root web.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文