I'm trying to rename a folder in a Sharepoint document store through a web application.
Changing the folder name works fine, but the name of the editor became the service user running the web application. I want to set the editor to the actual user who wanted to change it.
//get the user, and the folder
var user = clientContext.Web.EnsureUser(userLogin);
//camlDirectorySelect is a CamlQuery to get the directory...
var folders = spsList.GetItems(camlDirectorySelect);
clientContext.Load(folders, x => x.Include(y => y["Title"], y => y["FileLeafRef"], y => y["Editor"], y => y["CheckoutUser"], y => y["Modified_x0020_By"]));
clientContext.ExecuteQuery();
if(folders.Count == 1) {
var theFolder = folders[0];
theFolder["Title"] = renameParams.NewDirName;
theFolder["FileLeafRef"] = renameParams.NewDirName;
theFolder["Author"] = user; //The 'Author' does change
theFolder["Editor"] = user; //But 'Editor' will be the user executing the code (running the web app)...
//tried this too, but no luck: theFolder["Editor"] = String.Format(@"{0};#{1}", user.Id, user.Title);
theFolder.Update();
clientContext.ExecuteQuery();
}
A similar method works perfectly for files, and I can change the 'Author' for folders too. Any ideas?
