0

In CSOM I'm trying to Impersonate the user, So the Code will run under different user (system) account.

On root site of Test web Application, I have Page which contains some input filed and Button. On button click I'm trying to create list item in My site (different web application).

To comelet this functionalityI wnat to impersonate the user, so the code will run under different use account(System Account)

Please Share your thought.

0

You can create the list item using impersonation by creating a NetworkCredential object of the user with elevated privileges. You have to pass in the UserName,Password and Domain of the specific user as shown below :

using System.Net;
using Microsoft.SharePoint.Client;

using (ClientContext context = new ClientContext("https://url")) 
{
  context.Credentials = new NetworkCredential("user", "password", "domain");
  // CSOM Logic
  context.ExecuteQuery();     
}

More Reference

0

There is no possibility to impersonate in client side object model because it is running under current user context.

You can achieve impersonate functionality by passing static network credential information and domain for creating client context but this is not recommended/feasible method to do impersonate.

ClientContext context = new ClientContext("http://server/");
context.Credentials = new NetworkCredential("user", "password", "domain");
// Some Cording
context.ExecuteQuery();

Please check this reference link.

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.