Jun 05 2023 04:25 AM
Hi,
I have a solution, in which I add an item to a SharePoint 2019 on-premise list. I am not passing credentails, thus the connection is setup using the credentails of the user running the app.
On my machine this works great, however on another user's machine, not the credentials of the user running the app are used, but the credentials of the user which is used to setup SharePoint on the machine are used. That account is the "modified by" instead of the account running the App.
The difference between my machine and the other machine, is that the setup of the machine was done with the account that is now always displaying as the "modified by". It looks like that this account is always used for setting up the connection to SharePoint when no credentials are passed. Hope you can help me in the right direction and have some info if indeed the credentials of the user that has setup SharePoint are cached and how to avoid that that account is used. Also when the password of that account changes, the connection to SharePoint is broken.
See below example code of the connection and adding of the SharePoint item.
ClientContext clientcontext = new ClientContext("https:\\mysharepointurl");
List list = clientcontext.Web.Lists.GetByTitle("MyList");
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem listItem = list.AddItem(itemCreateInfo);
listItem["Title"] = "Test Item";
listItem.Update();
clientcontext.ExecuteQuery();
Best Regards,
John
Jun 05 2023 04:33 AM
Jun 05 2023 04:44 AM