<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Gold Coast</title><link>http://blogs.msdn.com/b/devkeydet/</link><description>Over the years, this blog has been about many different things related to software development with Microsoft technologies.  Since my current role focuses on Dynamics CRM / XRM, that&amp;#39;s what it&amp;#39;s primarily about right now.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/devkeydet" /><feedburner:info uri="devkeydet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>devkeydet</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>North 52 Formula Manager = WOW</title><link>http://feedproxy.google.com/~r/devkeydet/~3/Y0O4RYwqqHo/north-52-formula-manager.aspx</link><pubDate>Thu, 25 Apr 2013 14:02:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10413957</guid><dc:creator>keydet</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10413957</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/04/25/north-52-formula-manager.aspx#comments</comments><description>&lt;p&gt;DISCLAIMER: This is my opinion.&amp;#160; I get nothing from the makers of this addon for expressing my opinion.&amp;#160; &lt;/p&gt;  &lt;p&gt;I’m a developer at heart.&amp;#160; I love writing code.&amp;#160; But I also abelieve in the “don’t write code unless you have to” philosophy.&amp;#160; Well, I finally got around to playing around with &lt;a href="http://www.north52.com/formulamanager.html"&gt;North 52 Formula Manager&lt;/a&gt; and watch most of the &lt;a href="http://www.youtube.com/user/north52root/videos?flow=list&amp;amp;view=0&amp;amp;sort=da"&gt;YouTube Videos&lt;/a&gt;.&amp;#160; All I can say is WOW.&amp;#160; This addon is the answer to so many “Why can’t you do that with CRM without writing code?” questions.&amp;#160; Frankly, I can’t think of any CRM/XRM app that WOULDN’T benefit from this addon.&amp;#160; I also can’t rationalize writing code when I know I can use this addon to implement so many scenarios faster.&amp;#160; You owe it to yourself to take a look at this addon.&amp;#160; Review their site and watch the videos.&amp;#160; I suspect you won’t be disappointed you did.&amp;#160; Even with this addon, there will still be times when you will need to write JavaScript and .NET plugin code.&amp;#160; However, the scenarios will be far fewer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10413957" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Y0O4RYwqqHo:CnS8EQ_zmuo:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Y0O4RYwqqHo:CnS8EQ_zmuo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=Y0O4RYwqqHo:CnS8EQ_zmuo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Y0O4RYwqqHo:CnS8EQ_zmuo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=Y0O4RYwqqHo:CnS8EQ_zmuo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Y0O4RYwqqHo:CnS8EQ_zmuo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/Y0O4RYwqqHo" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/04/25/north-52-formula-manager.aspx</feedburner:origLink></item><item><title>Convergence 2013 Recordings</title><link>http://feedproxy.google.com/~r/devkeydet/~3/v26sqcbzYkk/convergence-2013-recordings.aspx</link><pubDate>Thu, 18 Apr 2013 22:49:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10412395</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10412395</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/04/18/convergence-2013-recordings.aspx#comments</comments><description>&lt;p&gt;As Girish says in his post:&lt;/p&gt;  &lt;p&gt;“If you didn’t attend Convergence 2013, you can still watch the recording of the keynotes and breakout sessions by registering for the Virtual Convergence. Best part is that it is completely free!”&lt;/p&gt;  &lt;p&gt;More details here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/b/girishr/archive/2013/04/17/watch-convergence-2013-session-recordings-for-free.aspx" href="http://blogs.msdn.com/b/girishr/archive/2013/04/17/watch-convergence-2013-session-recordings-for-free.aspx"&gt;http://blogs.msdn.com/b/girishr/archive/2013/04/17/watch-convergence-2013-session-recordings-for-free.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10412395" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=v26sqcbzYkk:RbaBG-tj7t0:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=v26sqcbzYkk:RbaBG-tj7t0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=v26sqcbzYkk:RbaBG-tj7t0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=v26sqcbzYkk:RbaBG-tj7t0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=v26sqcbzYkk:RbaBG-tj7t0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=v26sqcbzYkk:RbaBG-tj7t0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/v26sqcbzYkk" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/04/18/convergence-2013-recordings.aspx</feedburner:origLink></item><item><title>CRM and SQL 2012 AlwaysOn Availability Groups</title><link>http://feedproxy.google.com/~r/devkeydet/~3/6qzU4OxXDlk/sql-2012-alwayson-availability-groups.aspx</link><pubDate>Thu, 04 Apr 2013 19:30:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10407696</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10407696</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/04/04/sql-2012-alwayson-availability-groups.aspx#comments</comments><description>&lt;p&gt;I’ve spent a fair amount of time lately talking to people about the benefits of using SQL Server 2012 AlwaysOn Availability Groups in your CRM infrastructure.&amp;#160; I just came across a great video that’s a great primer on AlwaysOn Availability Groups:&lt;/p&gt; &lt;iframe style="width: 512px; height: 288px;" src="http://channel9.msdn.com/posts/SQL-2012-AlwaysOn-Availability-Groups/player?w=512&amp;amp;h=288" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;   &lt;p&gt;Here is a link to the SQL documentation as well:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/hh510230"&gt;http://msdn.microsoft.com/en-us/library/hh510230&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;AlwaysOn is already used in CRM Online for both local failover/redundancy and geographically distributed failover/redundancy for disaster recovery.&amp;#160; As of &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=36229"&gt;Update Rollup 12 for Microsoft Dynamics CRM 2011&lt;/a&gt;, the implementation guide has been updated with AlwayOn guidance:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/jj822357.aspx"&gt;http://msdn.microsoft.com/en-us/library/jj822357.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One of the nice features of AlwaysOn is &lt;a href="http://msdn.microsoft.com/en-us/library/ff878253"&gt;Active Secondaries: Readable Secondary Replicas (AlwaysOn Availability Groups)&lt;/a&gt;.&amp;#160;&amp;#160; You can configure custom reports to use the readable replica.&amp;#160; Here’s a good blog post on the topic:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/thecrmguys/archive/2012/08/10/crm-reporting-and-sql-2012-alwayson-availability-groups-better-together.aspx"&gt;http://blogs.msdn.com/b/thecrmguys/archive/2012/08/10/crm-reporting-and-sql-2012-alwayson-availability-groups-better-together.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Make sure you read the limitations of this approach stated in the blog post.&amp;#160; You should evaluate the feasibility of using this approach to determine whether the benefits are applicable to you.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10407696" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=6qzU4OxXDlk:wfERURwHllY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=6qzU4OxXDlk:wfERURwHllY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=6qzU4OxXDlk:wfERURwHllY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=6qzU4OxXDlk:wfERURwHllY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=6qzU4OxXDlk:wfERURwHllY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=6qzU4OxXDlk:wfERURwHllY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/6qzU4OxXDlk" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/SQL+Server/">SQL Server</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/04/04/sql-2012-alwayson-availability-groups.aspx</feedburner:origLink></item><item><title>TOOL HIGHLIGHT: CRM 2011 Web Resource Linker/Publisher</title><link>http://feedproxy.google.com/~r/devkeydet/~3/Q4xSNX6-UfU/tool-highlight-crm-2011-web-resource-linker-publisher.aspx</link><pubDate>Wed, 03 Apr 2013 14:05:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10407252</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10407252</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/04/03/tool-highlight-crm-2011-web-resource-linker-publisher.aspx#comments</comments><description>&lt;p&gt;I’ve &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2012/07/01/crm-solution-manager.aspx"&gt;blogged previously&lt;/a&gt; about why I like the approach &lt;a href="http://crmsolutionmanager.com/"&gt;CRM Solution Manager&lt;/a&gt; uses for authoring web resources in Visual Studio.&amp;#160; While I think CRM Solution Manager is a fantastic tool, there are ways to get some of the benefits of it’s approach to web resource authoring with a couple other free Visual Studio addins.&amp;#160; The first tool is &lt;a href="http://webresourcelinker.codeplex.com/"&gt;CRM 2011 Web Resource Linker/Publisher&lt;/a&gt;.&amp;#160; This tool provides the ability to map a file in a Visual Studio project to a web resource in CRM.&amp;#160; Because of this, I can organize my scripts in a folder structure which aligns with the relative path naming convention that’s recommended in the CRM SDK.&amp;#160; See &lt;a title="http://msdn.microsoft.com/en-us/library/gg309536.aspx" href="http://msdn.microsoft.com/en-us/library/gg309536.aspx"&gt;http://msdn.microsoft.com/en-us/library/gg309536.aspx&lt;/a&gt; for more details.&amp;#160; In the picture below, I just started with an empty web app and added the dkdt_ structure below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/3441.image_5F00_498D88F7.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/2474.image_5F00_thumb_5F00_5AFDE9CF.png" width="239" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then, I simply link/publish the files:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/3438.image_5F00_4848F018.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/3463.image_5F00_thumb_5F00_203640F9.png" width="608" height="772" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here’s an example of what initial linking looks like:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/1616.image_5F00_2610E492.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/5504.image_5F00_thumb_5F00_135BEADB.png" width="644" height="395" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice that you can also create a new web resource right from the linker dialog.&amp;#160; Once you’ve linked the files, you can do things like multi-select in Solution Explorer and deploy/publish just the files you care about:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/3441.image_5F00_447B257B.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/2376.image_5F00_thumb_5F00_5175058C.png" width="312" height="772" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;But wait, there’s more.&amp;#160; Since this is just a standard web app project, I can take advantage of all the goodness that Visual Studio 2012 has to offer.&amp;#160; For example, I can use &lt;a href="http://nuget.org/"&gt;NuGet&lt;/a&gt; to add the &lt;a href="http://nuget.org/packages/Crm2011JsVsDoc/"&gt;CRM 2011 Client Side VSDoc&lt;/a&gt; to get JavaScript Intellisense for Xrm.Page and simply drag and drop the file from Solution Explorer to the open JavaScript file that needs Intellisense and Visual Studio takes care of adding the reference:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/4034.image_5F00_0294402D.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/8156.image_5F00_thumb_5F00_5AEDC402.png" width="644" height="404" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I can also take advantage of addins which are designed to work with web projects such as &lt;a href="http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6"&gt;Web Essentials 2012&lt;/a&gt;.&amp;#160; One example is the JavaScript Minification feature:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/3060.image_5F00_39FA515B.png"&gt;&lt;img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/4530.image_5F00_thumb_5F00_593CF82E.png" width="644" height="454" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;…which will give me a production optimized version of my JavaScript file.&amp;#160; Because these are just files, I can just relink if I want to test the minified version.&amp;#160; To hit home the “because they are just files” point, I’ll give you another example.&amp;#160; I’ve grown fond of &lt;a href="http://www.typescriptlang.org/"&gt;TypeScript&lt;/a&gt;.&amp;#160; There’s even an &lt;a href="http://xrm2011typescript.codeplex.com/"&gt;Xrm.Page TypeScript&lt;/a&gt; definition file.&amp;#160; Because TypeScript ultimately produces JavaScript files, those files can simply be linked/published.&amp;#160; I think you are starting to see the “it just works” pattern here.&lt;/p&gt;  &lt;p&gt;So, for me, I’ve stopped using the &lt;a href="http://msdn.microsoft.com/en-us/library/hh372957.aspx"&gt;Developer Toolkit for Microsoft Dynamics CRM&lt;/a&gt; to &lt;a href="http://msdn.microsoft.com/en-us/library/hh547404.aspx"&gt;Create and Deploy Web Resources&lt;/a&gt; because many of these things I talk about don’t work with the supplied template.&amp;#160; Furthermore, the Developer Toolkit forces you to deploy all of your web resources every time and it doesn’t publish.&amp;#160; You have to do that manually.&amp;#160; I’ve found the approach I lay out in this post to be the most productive way of using Visual Studio to develop web resources.&amp;#160; However, I still use the Developer Toolkit to &lt;a href="http://msdn.microsoft.com/en-us/library/hh547400.aspx"&gt;Create and Deploy Plug-ins&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/hh547421.aspx"&gt;Create and Deploy Workflow Libraries&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;HTH&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10407252" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Q4xSNX6-UfU:m6bsN7CibHw:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Q4xSNX6-UfU:m6bsN7CibHw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=Q4xSNX6-UfU:m6bsN7CibHw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Q4xSNX6-UfU:m6bsN7CibHw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=Q4xSNX6-UfU:m6bsN7CibHw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=Q4xSNX6-UfU:m6bsN7CibHw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/Q4xSNX6-UfU" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/javascript/">javascript</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Visual+Studio+2012/">Visual Studio 2012</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/04/03/tool-highlight-crm-2011-web-resource-linker-publisher.aspx</feedburner:origLink></item><item><title>Authenticating to an Azure hosted web service from CRM Online Sandbox code</title><link>http://feedproxy.google.com/~r/devkeydet/~3/EkOJlnTAUtg/authenticating-to-an-azure-hosted-web-service-from-crm-online-sandbox-code.aspx</link><pubDate>Wed, 13 Mar 2013 04:39:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10401842</guid><dc:creator>keydet</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10401842</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/03/13/authenticating-to-an-azure-hosted-web-service-from-crm-online-sandbox-code.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;UPDATE (14MAR2013): Uploaded a modified sample which addresses storing credentials in secure config and adds comments around how to encrypt those credentials.&amp;#160; While I show a synchronous plugin in the demo for simplicity of the walkthrough, you should always evaluate whether your plugin logic can fire asynchronously if the action doesn’t require that the user see the result of the action immediately after the record is saved.&amp;#160; Calling an external system from a synchronous plugin can have negative side effects for both user experience and tight coupling with the external system.&amp;#160; When you absolutely must use a synchronous plugin, make sure your code is short lived and try to put your azure web role in a data center as close to your CRM Online data center as possible to minimize network latency.&amp;#160; You should also weigh the pros / cons of using this approach over the inherent Azure Service Bust capabilities Dynamics CRM provides which I talk about in my &lt;/em&gt;&lt;a href="http://Integrating with systems behind a firewall from CRM Online using Windows Azure Service Bus Relay"&gt;&lt;em&gt;Integrating with systems behind a firewall from CRM Online using Windows Azure Service Bus Relay&lt;/em&gt;&lt;/a&gt;&lt;em&gt; post.&amp;#160; While the context of my post is talking to systems behind a firewall, you can also use Azure Service Bus as a mechanism to integrate with a web service running in Windows Azure.&amp;#160; As of the CRM Online December 2012 Service Update and Update Rollup 12, Dynamics CRM includes new support for Windows Azure persistent queues, use of the updated Windows Azure portal to configure ACS, and synchronous plug-in support for posting to the service bus.&amp;#160; &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Scenario:&lt;/p&gt;  &lt;p&gt;“I need to execute some code from a plugin which requires full trust.&amp;#160; CRM Online doesn’t give me the ability to run full trust code so I want to put my full trust code behind a web service running in a Windows Azure Web Role.&amp;#160; However, every approach I attempt to use to authenticate from the plugin to the web service fails due to sandbox issues.”&lt;/p&gt;  &lt;p&gt;While I thought I covered this in my Design for Online post, I learned that my assumptions were incorrect.&amp;#160; I was under then impression that the approach I mention explained in the &lt;a href="http://blogs.msdn.com/b/steve_fox/archive/2012/02/07/sharepoint-online-and-windows-azure-developing-secure-bcs-connections-using-wcf-services.aspx"&gt;SharePoint Online and Windows Azure: Developing Secure BCS Connections using WCF Services&lt;/a&gt; post which uses UserNamePasswordValidator class would work in CRM Online.&amp;#160; I swear I had it working at one point.&amp;#160; That's what they all say:).&amp;#160; I recently tried it again and discovered that the client code (the code running in the plugin) required full trust.&amp;#160; I couldn’t figure out a way to get this working in full trust.&amp;#160; I still don’t know why this requires full trust and my attempts at finding an explanation internally at Microsoft came up short.&amp;#160; If someone else has gotten this approach to work, then I would love to know what I am missing.&amp;#160; &lt;/p&gt;  &lt;p&gt;Anyway, I had originally been going down a SOAP based approach.&amp;#160; I actually had a sample working from a sandboxed plugin using custom SOAP headers similar to what’s described &lt;a href="http://www.adilmughal.com/2011/10/client-additional-parameters-using.html"&gt;here&lt;/a&gt;.&amp;#160; If you are adamant about wanting to use SOAP, then take a look.&amp;#160; If there’s sufficient comments asking for a SOAP based example, then I will try to find the time to write a post about it.&amp;#160; However, what I realized after I got it all working was that the aforementioned approach is complex and hard to follow.&amp;#160; I saw this as an opportunity to take advantage of the &lt;a href="http://www.asp.net/web-api"&gt;ASP.NET Web API&lt;/a&gt;.&amp;#160; I think you’ll find the ASP.NET Web API approach more optimal for this scenario because:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We want as efficient communication as possible between CRM Online and the Windows Azure web role.&amp;#160; REST+JSON is the most efficient way I know. &lt;/li&gt;    &lt;li&gt;ASP.NET Web API makes it really easy to use JSON as the serialization format.&lt;/li&gt;    &lt;li&gt;It’s pretty easy to implement basic authentication for ASP.NET Web API based services.&lt;/li&gt;    &lt;li&gt;Basic authentication can be used from a sandbox plugin&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Before watching this walkthrough, make sure you go through or at least understand the following ASP.NET Web API walkthroughs:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api" href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api"&gt;http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations" href="http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations"&gt;http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client" href="http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client"&gt;http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.asp.net/web-api/overview/security/basic-authentication" href="http://www.asp.net/web-api/overview/security/basic-authentication"&gt;http://www.asp.net/web-api/overview/security/basic-authentication&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Watch the following video once you’ve gotten up to speed using ASP.NET Web API:&lt;/p&gt; &lt;iframe height="315" src="http://www.youtube.com/embed/za97srwf7fI" frameborder="0" width="420" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;   &lt;p&gt;The video won’t make much sense if you don’t spend the time understanding ASP.NET Web API.&amp;#160; The code sample I show in the video is available here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://sdrv.ms/15LCSax" href="http://sdrv.ms/15LCSax"&gt;http://sdrv.ms/15LCSax&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10401842" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=EkOJlnTAUtg:EAsmIIig_ZI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=EkOJlnTAUtg:EAsmIIig_ZI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=EkOJlnTAUtg:EAsmIIig_ZI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=EkOJlnTAUtg:EAsmIIig_ZI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=EkOJlnTAUtg:EAsmIIig_ZI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=EkOJlnTAUtg:EAsmIIig_ZI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/EkOJlnTAUtg" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Window+Azure/">Window Azure</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/03/13/authenticating-to-an-azure-hosted-web-service-from-crm-online-sandbox-code.aspx</feedburner:origLink></item><item><title>Microsoft CRM Enterprise Academy</title><link>http://feedproxy.google.com/~r/devkeydet/~3/ivMhnDw4dGA/microsoft-crm-enterprise-academy.aspx</link><pubDate>Tue, 12 Mar 2013 20:18:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10401733</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10401733</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/03/12/microsoft-crm-enterprise-academy.aspx#comments</comments><description>&lt;p&gt;I work with enterprise customers and have been involved in a number of enterprise implementations of Dynamics CRM.&amp;#160; One of the #1 things I get asked all the time is “where is the enterprise CRM training?”&amp;#160; The Microsoft CRM Enterprise Academy is a 5-day instructor-led training which provides 300 level Advanced Development and Advanced Infrastructure content for Microsoft Dynamics CRM 2011 to help address the unique needs of enterprise customers.&amp;#160; Go to &lt;a href="http://regonline.com/CRM2013"&gt;http://regonline.com/CRM2013&lt;/a&gt; for full details and registration information.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10401733" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=ivMhnDw4dGA:UCaF1OjWSPU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=ivMhnDw4dGA:UCaF1OjWSPU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=ivMhnDw4dGA:UCaF1OjWSPU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=ivMhnDw4dGA:UCaF1OjWSPU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=ivMhnDw4dGA:UCaF1OjWSPU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=ivMhnDw4dGA:UCaF1OjWSPU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/ivMhnDw4dGA" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/03/12/microsoft-crm-enterprise-academy.aspx</feedburner:origLink></item><item><title>Virtual Convergence 2013</title><link>http://feedproxy.google.com/~r/devkeydet/~3/4f2aqnqv9hs/virtual-convergence-2013.aspx</link><pubDate>Tue, 12 Mar 2013 19:40:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10401720</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10401720</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/03/12/virtual-convergence-2013.aspx#comments</comments><description>&lt;p&gt;Two days ago, the Convergence team announced Virtual Convergence 2013:&lt;/p&gt;  &lt;p&gt;&lt;a title="https://twitter.com/MSFTConvergence/status/310740576477782016" href="https://twitter.com/MSFTConvergence/status/310740576477782016"&gt;https://twitter.com/MSFTConvergence/status/310740576477782016&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you aren’t familiar with Convergence, it is similar to the likes of past technical conferences like PDC/MIX or current ones like TechEd and //build/, but exclusively focused on the Dynamics business at Microsoft.&amp;#160; I am delighted to see that people who couldn’t attend the conference in person can get access to the content for FREE.&amp;#160; Mark your calendars and follow the link to register.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10401720" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=4f2aqnqv9hs:njy2bzXk05o:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=4f2aqnqv9hs:njy2bzXk05o:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=4f2aqnqv9hs:njy2bzXk05o:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=4f2aqnqv9hs:njy2bzXk05o:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=4f2aqnqv9hs:njy2bzXk05o:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=4f2aqnqv9hs:njy2bzXk05o:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/4f2aqnqv9hs" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/03/12/virtual-convergence-2013.aspx</feedburner:origLink></item><item><title>REMINDER: I constantly update my dev tips n tricks deck</title><link>http://feedproxy.google.com/~r/devkeydet/~3/3-MGU7bEDfQ/reminder-i-constantly-update-my-dev-tips-n-tricks-deck.aspx</link><pubDate>Fri, 08 Mar 2013 17:47:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10400729</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10400729</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/03/08/reminder-i-constantly-update-my-dev-tips-n-tricks-deck.aspx#comments</comments><description>&lt;p&gt;I’ve been tweaking my tips n tricks deck over the last few months based on new findings, thoughts, etc.&amp;#160; Just wanted to remind people to reference the skydrive version vs. downloading it and saving it locally.&amp;#160; That way you always see the latest version.&lt;/p&gt; &lt;iframe height="327" src="https://skydrive.live.com/embed?cid=1F72DA7294089597&amp;amp;resid=1F72DA7294089597%2116514&amp;amp;authkey=AEBBOSRow2v0URM&amp;amp;em=2" frameborder="0" width="402" scrolling="no"&gt;&lt;/iframe&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10400729" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=3-MGU7bEDfQ:B3rlbrNW4zA:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=3-MGU7bEDfQ:B3rlbrNW4zA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=3-MGU7bEDfQ:B3rlbrNW4zA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=3-MGU7bEDfQ:B3rlbrNW4zA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=3-MGU7bEDfQ:B3rlbrNW4zA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=3-MGU7bEDfQ:B3rlbrNW4zA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/3-MGU7bEDfQ" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Visual+Studio+2012/">Visual Studio 2012</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/03/08/reminder-i-constantly-update-my-dev-tips-n-tricks-deck.aspx</feedburner:origLink></item><item><title>Calling CRM from ASP.NET using impersonation to ActOnBehalfOf the logged in user</title><link>http://feedproxy.google.com/~r/devkeydet/~3/BqcqQd2N6aE/calling-crm-from-asp-net-using-impersonation-to-actonbehalfof-the-logged-in-user.aspx</link><pubDate>Tue, 19 Feb 2013 18:26:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10395294</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10395294</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/02/19/calling-crm-from-asp-net-using-impersonation-to-actonbehalfof-the-logged-in-user.aspx#comments</comments><description>&lt;p&gt;Sometimes you need to run ASP.NET code outside of Dynamics CRM to achieve your goals.&amp;#160; This usually manifests itself either as a page embedded in CRMs main content area which is accessible via a link in the sitemap similar to the following:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/6318.image_5F00_5F82CBC6.png"&gt;&lt;img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-97-44-metablogapi/5736.image_5F00_thumb_5F00_523C42B3.png" width="644" height="285" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Another place this is often used is embedding external content through an IFrame in a CRM form.&amp;#160; The general approach is covered in the SDK:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dkdt.me/wnIFhy"&gt;Implement Single Sign-on from an ASPX Webpage or IFRAME&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dkdt.me/yCsVBF"&gt;Walkthrough: Single Sign-on from a Custom Web Page&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Of course, your code will usually need to call back into Dynamics CRM through the organization (web) service to do things like CRUD on CRM data, etc.&amp;#160; In this scenario, you want CRM to execute code under the context of the logged in user.&amp;#160; The CRM SDK covers how to do this here:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/gg334744.aspx"&gt;Impersonate Another User&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/gg309629.aspx"&gt;Sample: Impersonate Using the ActOnBehalfOf Privilege&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;See my &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-series.aspx"&gt;CRM Online &amp;amp; Windows Azure Series&lt;/a&gt; post for a walkthrough of the Single Sign On (SSO) configuration.&amp;#160; The goal of this post is to bring all of these concepts together in as simple of a “hello world” style code sample as possible.&amp;#160; The sample code is actually the code for the embedded page in the screenshot above (called ActOnBehalfOf.aspx).&amp;#160; The solution is made up of an ASP.NET web form, some code behind the web form, and a helper class I built.&amp;#160; In order to get this code to compile, you are going to have to add the necessary .NET assembly references and fix some of the namespaces.&amp;#160; I’ll leave that exercise to you.&lt;/p&gt; &lt;strong&gt;ActOnBehalfOf.aspx:&lt;/strong&gt;   &lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;   &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;     &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="background-color: rgb(255, 255, 0);"&gt;&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeBehind=&amp;quot;ActOnBehalfOf.aspx.cs&amp;quot; Inherits=&amp;quot;AdfsEnabledReportViewerWebRole.ActOnBehalfOf&amp;quot; %&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;html&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;head&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;title&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;head&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;form&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;form1&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:GridView&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;GridView1&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;False&amp;quot;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Columns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;Id&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;Id&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundField&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&amp;quot;Name&amp;quot;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Columns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:GridView&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;div&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;form&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;html&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;ActOnBehalfOf.aspx.cs:&lt;/strong&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
  &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; Microsoft.Xrm.Client;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; Microsoft.Xrm.Sdk.Client;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; AdfsEnabledReportViewerWebRole&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;partial&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; ActOnBehalfOf : System.Web.UI.Page&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;             var contextConnection = ActOnBehalfOfHelper.CreateContextAndConnection();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;             CrmConnection conn = contextConnection.Connection;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;             OrganizationServiceContext ctx = contextConnection.Context;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;             &lt;span style="color: rgb(0, 128, 0);"&gt;// CallierId is what forces CRM to execute the API calls within the security context of the CRM User&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;             conn.CallerId = ActOnBehalfOfHelper.GetCallerId();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum19" style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;             var accountQuery = from a &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; ctx.CreateQuery&amp;lt;Account&amp;gt;()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum20" style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;                         select &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Account&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum21" style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;                         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum22" style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;                             Id = a.Id,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum23" style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;                             Name = a.Name&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum24" style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;                         };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum25" style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum26" style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;             var accounts = accountQuery.ToList();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum27" style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum28" style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;             GridView1.DataSource = accounts;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum29" style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;             GridView1.DataBind();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum30" style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span id="lnum31" style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span id="lnum32" style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you’ve reviewed the resources in this post, then &lt;strong&gt;ActOnBehalfOf.aspx&lt;/strong&gt; and &lt;strong&gt;ActOnBehalfOf.aspx.cs&lt;/strong&gt; should be pretty self explanatory.&amp;#160; It’s a page with a &lt;strong&gt;GridView&lt;/strong&gt;.&amp;#160; The code behind queries CRM for data using the organization service.&amp;#160; Note that &lt;strong&gt;Account&lt;/strong&gt; from line 19 comes from a class file where I used crmsvcutil.exe to generate the class.&amp;#160; I always use &lt;a href="http://erikpool.blogspot.com/2011/03/filtering-generated-entities-with.html"&gt;Erik Pool’s approach&lt;/a&gt; to only generate classes I need in my code.&amp;#160; I digress.&amp;#160; The code sets the &lt;strong&gt;CallerId&lt;/strong&gt; property of the &lt;strong&gt;CrmConnection&lt;/strong&gt; object instance before executing the code.&amp;#160; By doing this, CRM will execute all calls made to through the &lt;strong&gt;OrganizationServiceContext&lt;/strong&gt; instance as the CRM user based on the &lt;strong&gt;CallerId&lt;/strong&gt; value passed in.&amp;#160; &lt;strong&gt;CallerId&lt;/strong&gt; is the GUID of the CRM user who needs to be impersonated.&amp;#160; The &lt;strong&gt;ActOnBehalfOfHelper&lt;/strong&gt; does the real work to get the proper GUID based on the claims available to the ASP.NET page.&amp;#160; Specifically, it uses the &lt;strong&gt;UPN&lt;/strong&gt; claim value to find the CRM user.&amp;#160; Once the CRM user is found, the code returns the Id of the CRM user as a GUID.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ActOnBehalfOfHelper.cs:&lt;/strong&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
  &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System.Web;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; Microsoft.IdentityModel.Claims;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; Microsoft.Xrm.Client;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; Microsoft.Xrm.Client.Services;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; Microsoft.Xrm.Sdk.Client;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; AdfsEnabledReportViewerWebRole&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; ActOnBehalfOfHelper&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// ReSharper disable InconsistentNaming&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;const&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; CRM_CALLERID = &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;CRM_CALLERID&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// ReSharper restore InconsistentNaming&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; ContextConnection CreateContextAndConnection()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            var contextConnection = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ContextConnection();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// Connect to CRM with a single named user (i.e. system account / trusted subsystem model) who has the ActOnBehalfOf privelege&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            contextConnection.Connection =&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                CrmConnection.Parse(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Url=[YOUR_ORG_URL];Username=[YOUR_USERNAME];Password=[YOUR_PASSWORD]&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            contextConnection.Context =&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; OrganizationServiceContext(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; OrganizationService(contextConnection.Connection));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; contextConnection;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; Guid GetCallerId()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            Guid callerId;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            var contextConnection = CreateContextAndConnection();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            var ctx = contextConnection.Context;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// NOTE: I am caching the CallerId to minimize calls to the CRM Organization Service.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// For production code, you should not store the CallerId in plain text in a cookie.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// Malicious code, once authenticated, can change the cookie value and execute as another caller.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// You could apply encryption when creating the cookie and decryption when reading &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// the cookie value:&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;//              http://msdn.microsoft.com/en-us/library/windowsazure/hh697511.aspx&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// You could even encrypt/decrypt the cookie name to obfuscate the purpose of the cookie.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// Alternatively, find a different approach to cache the CallerId value (ASP.NET Session for example)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// or simply don't cache the CallerId.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            HttpCookie callerIdCookie = HttpContext.Current.Request.Cookies[CRM_CALLERID];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// If the cookie exists, reuse the Guid string value to execute the call as the current user&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 128, 0);"&gt;// If not, then query CRM to get the Guid of the authenticated user based on the upn claim&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (callerIdCookie == &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                ClaimCollection claims = ((IClaimsIdentity) HttpContext.Current.User.Identity).Claims;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                IEnumerable&amp;lt;Claim&amp;gt; claimQuery = from c &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; claims&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                                                &lt;span style="color: rgb(0, 0, 255);"&gt;where&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                                                    c.ClaimType ==&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                                                    &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                                                select c;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                Claim upnClaim = claimQuery.FirstOrDefault();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                var userQuery = from user &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; ctx.CreateQuery&amp;lt;SystemUser&amp;gt;()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                                &lt;span style="color: rgb(0, 0, 255);"&gt;where&lt;/span&gt; user.DomainName == upnClaim.Value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                                select user.SystemUserId.Value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                callerId = userQuery.FirstOrDefault();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (callerId == Guid.Empty)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                    &lt;span style="color: rgb(0, 128, 0);"&gt;// Send HTTP status code of 403&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                    &lt;span style="color: rgb(0, 128, 0);"&gt;// See http://en.wikipedia.org/wiki/List_of_HTTP_status_codes&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                    HttpContext.Current.Response.StatusCode = 403;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                    HttpContext.Current.Response.End();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; callerIdString = callerId.ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                HttpContext.Current.Response.Cookies.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; HttpCookie(CRM_CALLERID, callerIdString));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                callerId = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Guid(callerIdCookie.Value);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; callerId;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; ContextConnection&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; CrmConnection Connection { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OrganizationServiceContext Context { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Note the comments in the code.&amp;#160; I am doing some caching of the user GUID in a cookie.&amp;#160; Right now, the cookie and cookie value is in plain text.&amp;#160; As I state, this is done for simplicity of the sample.&amp;#160; Make sure you read the comments and make the proper adjustments to protect access to the &lt;strong&gt;CallerID&lt;/strong&gt; GUID from malicious code/callers.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10395294" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=BqcqQd2N6aE:oDFrVd0wwWg:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=BqcqQd2N6aE:oDFrVd0wwWg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=BqcqQd2N6aE:oDFrVd0wwWg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=BqcqQd2N6aE:oDFrVd0wwWg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=BqcqQd2N6aE:oDFrVd0wwWg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=BqcqQd2N6aE:oDFrVd0wwWg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/BqcqQd2N6aE" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/ASP-NET/">ASP.NET</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Window+Azure/">Window Azure</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/02/19/calling-crm-from-asp-net-using-impersonation-to-actonbehalfof-the-logged-in-user.aspx</feedburner:origLink></item><item><title>A primer in Extended CRM Development</title><link>http://feedproxy.google.com/~r/devkeydet/~3/cHnJly640Bk/a-primer-in-extended-crm-development.aspx</link><pubDate>Mon, 18 Feb 2013 14:23:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10394863</guid><dc:creator>keydet</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.msdn.com/b/devkeydet/rsscomments.aspx?WeblogPostID=10394863</wfw:commentRss><comments>http://blogs.msdn.com/b/devkeydet/archive/2013/02/18/a-primer-in-extended-crm-development.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;UPDATE (06MAY2013):&lt;/strong&gt; If you like the idea of implementing more functionality using point and click configuration (like in Part II) without having to write code (like in Part III), then you might want to have a look at &lt;a href="http://www.north52.com/formulamanager.html"&gt;North 52 Formula Manager&lt;/a&gt;.&amp;#160; I have a blog post about it &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2013/04/25/north-52-formula-manager.aspx"&gt;here&lt;/a&gt;.&amp;#160; Like I say in the post, I get nothing from the makers of the addon by making you aware of it.&amp;#160; However, I am a big fan of the it.&amp;#160; I think it’s a significant time saver enabling you to quickly implement functionality that would otherwise require code.&amp;#160; You can decide for yourself after you have evaluated it.&lt;/p&gt;  &lt;p&gt;Dynamics CRM 2011 offers a powerful platform for building line of business applications.&amp;#160; These applications are often referred to as Extended CRM applications or XRM Framework applications because they leverage Dynamics CRM 2011 capabilities beyond the typical customer relationship management (CRM) scenarios.&amp;#160; Since I work with US Government, Healthcare, and Education customers and partners, I spend the majority of my time focused on XRM.&amp;#160; I’ve used &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2011/10/21/my-crash-course-in-dynamics-crm-2011-development.aspx"&gt;My “crash course” in Dynamics CRM 2011 Development&lt;/a&gt; post as starter resource for folks who want to learn more.&amp;#160; However, sometimes I get the following feedback: “That’s great, but can you give me the short version?&amp;#160; I want the primer, not the deep dive.”&amp;#160; This post is my attempt to do just that.&amp;#160; To learn the fundamentals of XRM, do the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Watch my XRM in a Nutshell series:&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;Part I: Defining the Data-centric Business Application built using Dynamics CRM (22:16)&lt;/li&gt;      &lt;li&gt;&lt;iframe height="315" src="http://www.youtube.com/embed/XbmYhAy3ouM" frameborder="0" width="420" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;/li&gt;      &lt;li&gt;Part II: Building the Data-centric Business Application using Dynamics CRM (53:24)&lt;/li&gt;      &lt;li&gt;&lt;iframe height="315" src="http://www.youtube.com/embed/gzD-91ZE8OM" frameborder="0" width="420" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;/li&gt;      &lt;li&gt;Part III: Extending the Data-centric Business Application with the Dynamics CRM SDK (51:20)&lt;/li&gt;      &lt;li&gt;&lt;iframe height="315" src="http://www.youtube.com/embed/dItzJrZi4cw" frameborder="0" width="420" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;After watching these videos, the next step would be to read the &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=14364"&gt;Building Business Applications with Microsoft Dynamics CRM 2011&lt;/a&gt; whitepaper.&amp;#160; Next, you can dig deeper using my &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2011/10/21/my-crash-course-in-dynamics-crm-2011-development.aspx"&gt;My “crash course” in Dynamics CRM 2011 Development&lt;/a&gt; post.&amp;#160; &lt;/p&gt;  &lt;p&gt;In Part II, I show modifying the Site Map and Ribbon using my favorite community tools:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://dkdt.me/TxS9XB" href="http://dkdt.me/TxS9XB"&gt;http://dkdt.me/TxS9XB&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In Part III, I talk about the integrated external wed application with SSO scenario.&amp;#160; However, I don’t show a demo of it.&amp;#160; I cover examples of this scenario as part of my &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-series.aspx"&gt;CRM Online &amp;amp; Windows Azure Series&lt;/a&gt;.&amp;#160;&amp;#160; Specifically in the &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-configuring-single-sign-on-sso.aspx"&gt;Configuring Single Sign On (SSO)&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/b/devkeydet/archive/2013/02/19/calling-crm-from-asp-net-using-impersonation-to-actonbehalfof-the-logged-in-user.aspx"&gt;Calling CRM from ASP.NET using impersonation to ActOnBehalfOf the logged in user&lt;/a&gt; posts.&lt;/p&gt;  &lt;p&gt;Finally, if you like these kinds of videos, then you might like How to &lt;a href="http://www.youtube.com/watch?v=hY51Te9XxUE"&gt;Customize Microsoft Dynamics CRM 2011 Online&lt;/a&gt; which is in a similar vein as my videos.&amp;#160; There's a little bit of overlap, but I think you’ll still find the content useful.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/devkeydet"&gt;@devkeydet&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10394863" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=cHnJly640Bk:EVdTyeeyEkE:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=cHnJly640Bk:EVdTyeeyEkE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=cHnJly640Bk:EVdTyeeyEkE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=cHnJly640Bk:EVdTyeeyEkE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?i=cHnJly640Bk:EVdTyeeyEkE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/devkeydet?a=cHnJly640Bk:EVdTyeeyEkE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/devkeydet?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devkeydet/~4/cHnJly640Bk" height="1" width="1"/&gt;</description><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/Dynamics/">Dynamics</category><category domain="http://blogs.msdn.com/b/devkeydet/archive/tags/CRM/">CRM</category><feedburner:origLink>http://blogs.msdn.com/b/devkeydet/archive/2013/02/18/a-primer-in-extended-crm-development.aspx</feedburner:origLink></item></channel></rss>
