CSOM - can't update the listItem["Editor"] (Modified by) in .NET Core

natacat 1 Reputation point

The issue is related to .NET Core with CSOM.
In .NET Core the authentication for SharePoint Online changed and it’s no longer supporting the “SharePointOnlineCredentials” class.
I followed the official documentation successfully : https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard
This code runs in Azure function V3, and the API is triggered by a user button click in the SharePointOnline UI. This API creates a new SP item.

However, in the previous versions I could update the sharepoint item “Modified by” system field easily with a new User object.
In this version since the authentication changed, each ExceuteQuery action, the access token for the admin user is requested, and the “Modified by” field is the admin and not the User as I defined in my code.

I wish the current user will be defined as the item creator/editor. and not the user defined for the access token.

Please assist how can I perfom this action.


Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
2,773 questions
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
6,416 questions
{count} votes

3 answers

Sort by: Newest
  1. Michaël Maillot 1 Reputation point


    Does your problem still persist?

    I'm also using an Azure Function v3 and I can update the Editor field, through an AAD Application, in AppOnly Context. But you have to know that you must consent the highest SharePoint Permissions ("Sites.FullControl.All") to make that work.

  2. Jerryzy 10,411 Reputation points

    Hi @natacat ,

    I can reproduce the same issue in .NET Core Solution.

    As the authencation way changed, this could affect to update Editor field to other values, seems the new CSOM libraray have some comptible issue with .NET Core solution.

    You could submit a UserVoice in SharePoint Online Dev Platform about this issue:

    SharePoint Dev Platform

    And if possible, I suggest you could switch to .NET Framework instead of .NET Core to update author/editor field value.

    If the response is helpful, please click "Accept Answer" and upvote it :)

    1 person found this answer helpful.

  3. sadomovalex 3,601 Reputation points

    one option is to pass current user's login name from Sharepoint Online to button click handler and then to Azure function. This is how login name of current user can be retrieved in javascript:

    var ctx = SP.ClientContext.get_current();
    var user = web.get_currentUser();
    Function.createDelegate(this, function(sender, args) {
        // pass user.get_LoginName() to AF
    Function.createDelegate(this, function(sender, args) {
        // handle error

    and then inside Azure function update Modified By field like that:

    var ctx = ...
    var user = ctx.Web.EnsureUser(loginName);
    var item = ...
    item["Editor"] = user;