I am working on a remote event receiver which uses app only permission. now i am trying to get the current user who execute the RER:-

var o = context.Web.CurrentUser.LoginName;
listItem["Author"] = context.Web.EnsureUser(HttpContext.Current.User.Identity.Name);

but the context.Web.CurrentUser.LoginName will return app@sharepoint instead of the actual username, and the HttpContext.Current.User.Identity.Name will return object reference not set to an instance..... any advice on this please? Thanks

  • 1
    The answer depends on which type of event you are handling. Item Event, List Event, App Event?
    – willman
    Feb 19 '20 at 16:33
  • @willman item event (item updated and item added)
    – John John
    Feb 19 '20 at 16:35

When you are handling an Item-triggered event, then the Properties parameter passed into your ProcessEvent or ProcessOneWayEvent methods has a ListEventProperties property which will contain the CurrentUserId, UserDisplayName, and UserLoginName that should all hold information about the user who "triggered" the event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.