1

Is there any way to update any user's profile properties using CSOM? I'm trying to update the user's profile picture. I'm able to update the current logged in user's profile picture using the following code snippet:

ClientContext context = new ClientContext("https://<sharepoint site url>");
context.Credentials = new SharePointOnlineCredentials("[email protected]", <password as securestring>");
PeopleManager peopleManager = new PeopleManager(context);

Stream fileStream = new FileStream(@"<image file path>", FileMode.Open);
peopleManager.SetMyProfilePicture(fileStream);

context.Load(userProperties);
context.ExecuteQuery();

But how do I update another user if I know the username? Provided I have admin rights on the User Profile Service Application.

1 Answer 1

1

Unfortunately , there is no option available to do this

You only have the available methods to can Change the current user's profile picture

  • CSOM: SetMyProfilePicture
  • JSOM: setMyProfilePicture
  • REST: SetMyProfilePicture

    • POST http://<siteUri>/_api/SP.UserProfiles.PeopleManager/SetMyProfilePicture and pass the picture parameter in the request body.
  • SSOM: UserProfile[PropertyConstants.PictureUrl].Value or SetMyProfilePicture (not supported with SharePoint Online)

Also, check this article Automatically updating User Profile properties in SharePoint Online/Office 365 not working that introduces a workaround, meanwhile, it requires to know the username and password for each user .

1
  • There must be an endpoint where it is possible to update any picture, otherwise it would not possible to do it even from the central administration.
    – Emaborsa
    Commented Nov 29, 2017 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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