如何使用远程事件接收器 SharePoint 获取用户详细信息?
How to get user details using remote event receiver SharePoint?
我正在使用远程事件接收器处理 SharePoint 加载项。我为我的 SharePoint 网站创建了一个加载项,以获取添加的项目、更新的项目和删除的项目详细信息的日志。我正在获取项目 ID,它提供有关对其执行操作的项目的详细信息。
如何获取修改文件的用户的详细信息?
这是我添加项目的代码:
if (clientContext != null)
{
//Get reference to the host web list with name Feedback
var documentsList =
clientContext.Web.Lists.GetByTitle("DemoRemoteEventReceiverList");
clientContext.Load(documentsList);
clientContext.ExecuteQuery();
string remoteUrl =
"https://myApp.azurewebsites.net/Services/RemoteEventReceiver.svc";
//Create the remote event receiver definition
EventReceiverDefinitionCreationInformation newEventReceiver = new
EventReceiverDefinitionCreationInformation()
{
EventType = EventReceiverType.ItemAdded,
ReceiverAssembly = Assembly.GetExecutingAssembly().FullName,
ReceiverName = "RemoteEventReceiver1",
ReceiverClass = "RemoteEventReceiver1",
ReceiverUrl = remoteUrl,
SequenceNumber = 15001
};
//Add the remote event receiver to the host web list
documentsList.EventReceivers.Add(newEventReceiver);
clientContext.ExecuteQuery();
}
尝试
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
var user = clientContext.Web.CurrentUser;
clientContext.Load(user);
clientContext.ExecuteQuery();
我正在使用远程事件接收器处理 SharePoint 加载项。我为我的 SharePoint 网站创建了一个加载项,以获取添加的项目、更新的项目和删除的项目详细信息的日志。我正在获取项目 ID,它提供有关对其执行操作的项目的详细信息。 如何获取修改文件的用户的详细信息?
这是我添加项目的代码:
if (clientContext != null)
{
//Get reference to the host web list with name Feedback
var documentsList =
clientContext.Web.Lists.GetByTitle("DemoRemoteEventReceiverList");
clientContext.Load(documentsList);
clientContext.ExecuteQuery();
string remoteUrl =
"https://myApp.azurewebsites.net/Services/RemoteEventReceiver.svc";
//Create the remote event receiver definition
EventReceiverDefinitionCreationInformation newEventReceiver = new
EventReceiverDefinitionCreationInformation()
{
EventType = EventReceiverType.ItemAdded,
ReceiverAssembly = Assembly.GetExecutingAssembly().FullName,
ReceiverName = "RemoteEventReceiver1",
ReceiverClass = "RemoteEventReceiver1",
ReceiverUrl = remoteUrl,
SequenceNumber = 15001
};
//Add the remote event receiver to the host web list
documentsList.EventReceivers.Add(newEventReceiver);
clientContext.ExecuteQuery();
}
尝试
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
var user = clientContext.Web.CurrentUser;
clientContext.Load(user);
clientContext.ExecuteQuery();