当用户添加到组时执行自定义操作 [英] Execute custom action when user added to a group
问题描述
大家好,
我想赶上将一个人添加到组共享点并应用一些操作(登录列表历史记录...)的事件
I want to catch the event of adding a person to a group sharepoint and apply some actions (log on list history...)
有没有一种存档方法.
任何帮助将不胜感激
致谢
推荐答案
Hamza,
Hi Hamza,
Sharepoint 2013具有一个名为 在添加用户时触发的SPSecurityEventReceiver 是Sharepoint组,您的自定义事件必须来自 SPSecurityEventReceiver.
Sharepoint 2013 have an event receiver called SPSecurityEventReceiver which fire on adding a user is to Sharepoint group, your custom event must inheret from SPSecurityEventReceiver.
这是在添加 时详细的分步添加自定义事件处理程序一个可以与人共享的人,请看看.
Here's the detailed Step-by-step adding custom event handler on adding a person to sharepoint group Please have a look.
http://www.c-sharpcorner.com/UploadFile/anavijai/create-groupuseradded-event-receiver-in-sharepoint-2013/
http://www.c-sharpcorner.com/UploadFile/anavijai/create-groupuseradded-event-receiver-in-sharepoint-2013/
http://sampathnarsingam.blogspot.com/2013/02/sharepoint-2013-new-event-receiver-for.html
http://sampathnarsingam.blogspot.com/2013/02/sharepoint-2013-new-event-receiver-for.html
namespace GroupUserAddedEventReceiver
{
class GroupUserAddedEvent:SPSecurityEventReceiver
{
publicoverridevoid GroupUserAdded(SPSecurityEventProperties properties)
{
base.GroupUserAdded(properties);
// Get the added user details
SPUser userAdded = properties.Web.AllUsers.GetByID(properties.GroupUserId);
// Get the group details to which the user is added
SPGroup groupAdded = properties.Web.Groups.GetByID(properties.GroupId);
// Get the group details list
SPList list = properties.Web.Lists.TryGetList("Group Details");
// Check if the list exists
if (list != null)
{
// Add a new item
SPListItem item = list.Items.Add();
// update the title column
item["Title"] = "User: " + userAdded.Name + " added to the group - " + groupAdded.Name;
// Update the item
item.Update();
// Update the list
list.Update();
}
}
}
}
我希望这会对您有所帮助
i hope this will help you
这篇关于当用户添加到组时执行自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!