会员请求 SPGroup 共享点的电子邮件地址

发布于 2024-10-07 08:08:15 字数 107 浏览 1 评论 0原文

在 sharepoint 中创建组时,我们有一个选项 “发送会员请求至以下电子邮件地址”

用于向 SPGroup 发送会员请求。

但是我们如何以编程方式设置电子邮件地址

While creating Group in sharepoint we have an option
"Send membership requests to the following e-mail address"

It is used to send membership request to the SPGroup.

But how can we set the e-mail address programmatically

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

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

发布评论

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

评论(2

夏日浅笑〃 2024-10-14 08:08:15

我正在尝试在功能激活事件中完成同样的事情。我已经找到了如何创建组以及如何访问对象模型中的这些设置。你可以使用我下面的例子。问题是,尽管调用了 SPGroup.Update(),但我对 SPGroup 的这些布尔属性的更改并未生效。创建的 SPGroup 仍使用默认设置(成员资格请求已关闭)。

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {

        SPSite site = (SPSite)properties.Feature.Parent;
        {
            using (SPWeb web = site.RootWeb)
            {
                SPGroupCollection collGroups = web.SiteGroups;
                SPUser user = web.EnsureUser("DOMAIN\\username");

                collGroups.Add("MySPGroupName", user, user, "MySPGroupDescription");
                if (!web.AssociatedGroups.Contains(collGroups["MySPGroupName"]))
                {
                    web.AssociatedGroups.Add(collGroups["MySPGroupName"]);
                }
                SPRoleAssignment assignment = new SPRoleAssignment(collGroups["MySPGroupName"]);
                SPRoleDefinition def = web.RoleDefinitions.GetByType(SPRoleType.Contributor);
                assignment.RoleDefinitionBindings.Add(def);
                web.RoleAssignments.Add(assignment);
                web.Update();
                collGroups["MySPGroupName"].AllowMembersEditMembership = true;
                collGroups["MySPGroupName"].AllowRequestToJoinLeave = true;
                collGroups["MySPGroupName"].OnlyAllowMembersViewMembership = false;
                string emailForRequests = "[email protected]";
                if (!String.IsNullOrEmpty(user.Email))
                    emailForRequests = user.Email;
                collGroups["MySPGroupName"].RequestToJoinLeaveEmailSetting = emailForRequests;
                collGroups["MySPGroupName"].Update();
            }
        }

    }

I'm trying to accomplish the same thing in a feature activated event. I have found how to create the group and how to access these settings in the object model. You can use my example below. The problem is, my changes to these boolean properties of the SPGroup don't take, despite calling SPGroup.Update(). The SPGroup created still uses the default settings (membership requests are turned off).

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {

        SPSite site = (SPSite)properties.Feature.Parent;
        {
            using (SPWeb web = site.RootWeb)
            {
                SPGroupCollection collGroups = web.SiteGroups;
                SPUser user = web.EnsureUser("DOMAIN\\username");

                collGroups.Add("MySPGroupName", user, user, "MySPGroupDescription");
                if (!web.AssociatedGroups.Contains(collGroups["MySPGroupName"]))
                {
                    web.AssociatedGroups.Add(collGroups["MySPGroupName"]);
                }
                SPRoleAssignment assignment = new SPRoleAssignment(collGroups["MySPGroupName"]);
                SPRoleDefinition def = web.RoleDefinitions.GetByType(SPRoleType.Contributor);
                assignment.RoleDefinitionBindings.Add(def);
                web.RoleAssignments.Add(assignment);
                web.Update();
                collGroups["MySPGroupName"].AllowMembersEditMembership = true;
                collGroups["MySPGroupName"].AllowRequestToJoinLeave = true;
                collGroups["MySPGroupName"].OnlyAllowMembersViewMembership = false;
                string emailForRequests = "[email protected]";
                if (!String.IsNullOrEmpty(user.Email))
                    emailForRequests = user.Email;
                collGroups["MySPGroupName"].RequestToJoinLeaveEmailSetting = emailForRequests;
                collGroups["MySPGroupName"].Update();
            }
        }

    }
奶茶白久 2024-10-14 08:08:15

如果使用 SP 2013,使用 PowerShell 您可以使用以下代码:

$membersGroup = $siteCollection.SiteGroups["$groupName"]
$membersGroup.RequestToJoinLeaveEmailSetting = "[email protected]"
$membersGroup.Update() 

If using SP 2013, using PowerShell you can use the following code:

$membersGroup = $siteCollection.SiteGroups["$groupName"]
$membersGroup.RequestToJoinLeaveEmailSetting = "[email protected]"
$membersGroup.Update() 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文