web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Impersonation of user

(0) ShareShare
ReportReport
Posted on by 15

Hello,

We are using Sharepoint to communicate with our CRM (on-prem v.8) via an API that's hosted on IIS (through AD).

Said API is connecting to CRM via a static admin user -  

    <add name="CRM" connectionString="Url=ourUrl.com; Domain=ourDomain; Username=Admin; Password=****; authtype=AD" />

Our issue is that whenever a user uploads a file in Sharepoint and sends it to CRM (the file is stored under Annotation entity in CRM) the Note that's created contains the Admin user instead of the actual user who created the note.

Now, I assume this is caused because of the connectionString's static Admin user, but is there any way to impersonate the sender and override the CreatedBy field in Annotation entity to display the actual user?

and if not, is there any other way of solving this issue without needing to create a custom entity?

P.S. I read there is a way to set the CreatedOnBehalfBy field via impersonation but that field is not displayed when a note is created and we'd like the username to be shown

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    I believe you can create the note on behalf of the current user by adding MSCRMCallerID header in your req.

    could you share a piece of code? This will help to give a more detailed answer.

  • myname123 Profile Picture
    15 on at

    Thank you for answering. 

    Here is the relevant code:

    $.ajax({
      // url = http://our/path/to/crm/webmethods/
      url: appConfig.apiUrl   'CreateAnnotation',
      type: 'POST',
      dataType: 'json',
      // data defined elsewhere
      data: data,
      contentType: 'application/json',
      success: function (d, textStatus, xhr) {
        // func callback defined elsewhere
        if (func) func(d);
      }
    });

    Now I tried changing the ajax call to something like this:

    $.ajax({
      url: appConfig.apiUrl   'CreateAnnotation',
      type: 'POST',
      dataType: 'json',
      beforeSend: function (request) {
        // logged-in user's guid
        request.setRequestHeader("MSCRMCallerID", guid);
      },
      data: data,
      contentType: 'application/json',
      success: function (d, textStatus, xhr) {
        if (func) func(d);
      }
    });

    but still getting the same result.

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    Did you add "Behalf of Another User privileges" to the user's security role?  You will find this privilege in the miscellaneous privileges section under the business management tab.

  • myname123 Profile Picture
    15 on at

    Yes. Our security role already has Behalf of Another User.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 96

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 69 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans