Dynamics CRM 2015/2016/365 Web API: User Impersonation

Source: Internet
Author: User

Update today on the use of user impersonation in the Web API interface, user simulation is not a new concept in Dynamics CRM development and has been supported by successive interfaces. Before we explain how to use this feature in the Web API, let's go through the specific features of user simulations.

User impersonation, as the name implies, is for impersonating other users. When calling the interface, if we all need to provide an account password information, but many times, our interface authentication information is an integrated account, but we would like to create a record through this interface is created by other users. If you have this requirement, you will need to use the user simulation function.

In the Dynamics CRM Web API, if it is very easy to turn on user impersonation, simply add an extra pair of tokens to the HTTP message header, for example: "Mscrmcallerid: { 8CBD0DA3-AEAB-E611-80F4-C4346BC540C4} ".


Let's look at a request message that creates a customer record using the user simulation feature:

POST https://crmhomedev06.api.crm6.dynamics.com/api/data/v8.2/accounts Http/1.1mscrmcallerid: { 8cbd0da3-aeab-e611-80f4-c4346bc540c4}odata-maxversion:4.0odata-version:4.0accept:application/jsonauthorization : Bearer Eyj0exaioijkv1qilcjhbgcioijsuzi1niising1dci6iljyuxf1oxj5zejwuldty29jdvhvyjiwsedstsisimtpzci6iljyuxf1oxj5zejwuldty29jdvhvy Jiwsedstsj9.eyjhdwqioijodhrwczovl2nybwhvbwvkzxywni5hcgkuy3jtni5kew5hbwljcy5jb20viiwiaxnzijoiahr0chm6ly9zdhmud2luzg93cy5uz Xqvymi4y2iymmuty2vhoc00ztqwlwjim2itnmixzgewmzg4mdewlyisimlhdci6mtq3otm2mtexnywibmjmijoxndc5mzyxmte3lcjlehaioje0nzkznjuwmt Csimfjcii6ijeilcjhbxiiolsichdkil0simfwcglkijointyzoti3ndktzdlmos00nzzmlwiym2qtzme3zgzkyjdlzjqziiwiyxbwawrhy3iioiiwiiwizv9 Lehaiojewodawlcjmyw1pbhlfbmftzsi6inhpb25niiwiz2l2zw5fbmftzsi6implzmyilcjpcgfkzhiioiiymdcundyumtm5lji0osisim5hbwuioijqzwzm Ihhpb25niiwib2lkijointg3odk2ngutnzvhmy00mme5ltkymtitmgy2ywfkmgeyn2u5iiwicgxhdgyioiiziiwichvpzci6ijewmdm3rkzfoujemey2qtiil Cjzy3aioij1c2vyx2ltcgvyc29uyxrpb24ilcjzdwiioii0u3a4z2htqudbslnvqnpjofm0m1rjwmxzbhzqntrfdfpxteh3qm44y0zjiiwidglkijoiymi4y2iymmuty2vhoc00ztqwlwjim2itnmixzgewmzg4mdewiiwidw5pcxvlx25 hbwuioijqzwzmlnhpb25nqgnybwhvbwvkzxywni5vbm1py3jvc29mdc5jb20ilcj1cg4ioijqzwzmlnhpb25nqgnybwhvbwvkzxywni5vbm1py3jvc29mdc5j B20ilcj2zxiioiixljailcj3awrzijpbijyyztkwmzk0lty5zjutndizny05mtkwltaxmje3nze0nwuxmcjdfq.kry_ 3od5-ogw9tn25boxgsgznn4jjjruzyjerjbtkjgyzpdx7zlhiauyicvq0jpsye0jot6nhh8r_ 4dtqegniwirfyih8-i2b5zexm55fcxw6kupp3emthbidxpqfkros_62uamloc0vw2p68rguxeaopvzbikr5_ Fsi1ojt2f-d9cccrpfm9purtelpz1ut2b6pxjd-5a779lsedv7vax6wktlhmoywqaxujj2_mgjr72eysoigpbegm1cyaztsjjhaefajrywwibo _zwqwnfbnddrkny1tcf_r6cnyhj2uicthggoitmfyazntpvgvscuhghbiv2wx9xisfrwgpgcontent-type:application/json; charset=utf-8host:crmhomedev06.api.crm6.dynamics.comcontent-length:36expect:100-continue{"name": "[f]MCXlwn^ uitpfofalaxgws^ "}

The test code called with C # is as follows:

  Jobject account = new Jobject ();            Account. ADD ("Name", Stringgenerator (Numbergenerator ()));            Httprequestmessage req = new Httprequestmessage (Httpmethod.post, "accounts");            Req. Content = new Stringcontent (Jsonconvert.serializeobject (account), Encoding.UTF8, "Application/json");            Req. Headers.add ("Mscrmcallerid", "{8cbd0da3-aeab-e611-80f4-c4346bc540c4}");            Httpresponsemessage resp = await _client. SendAsync (req);            Return resp. Issuccessstatuscode;


Dynamics CRM 2015/2016/365 Web API: User Impersonation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.