Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Impersonation of user

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

  • myname123 Profile Picture
    myname123 15 on at
    RE: Impersonation of user

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

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Impersonation of user

    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
    myname123 15 on at
    RE: Impersonation of user

    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
    meelamri 13,204 User Group Leader on at
    RE: Impersonation of user

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans