<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hans Rasmussen &#187; CRM</title>
	<atom:link href="http://www.hansrasmussen.com/tag/crm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hansrasmussen.com</link>
	<description>info@hansrasmussen.com, +46 (0)723 207008</description>
	<lastBuildDate>Wed, 01 Feb 2012 11:59:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CRM Authentication</title>
		<link>http://www.hansrasmussen.com/2010/02/crm-authentication/</link>
		<comments>http://www.hansrasmussen.com/2010/02/crm-authentication/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 23:47:49 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Webservice]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/2010/02/crm-authentication/</guid>
		<description><![CDATA[One good way of Authenticating against CRM Webservice is not tell CRM which internally defined system user account you wish to authenticate against. I found this good article from Microsoft about how to lookup the system user account based on the GUID that it receives in CRM after you have told CRM that you wish [...]]]></description>
			<content:encoded><![CDATA[<p>One good way of Authenticating against CRM Webservice is not tell CRM which internally defined system user account you wish to authenticate against. I found this good article from Microsoft about how to lookup the system user account based on the GUID that it receives in CRM after you have told CRM that you wish to create a user for this account.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/cc151052.aspx">http://msdn.microsoft.com/en-us/library/cc151052.aspx</a></p>
<p>//extract from the link above</p>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using<span style="font-size: x-small;"> System;</span></span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"> </span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></span></span></div>
<p><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></p>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using<span style="font-size: x-small;"> System.Web.Services.Protocols;</span></span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"> </span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></span></span></div>
<p></span></span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></p>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using<span style="font-size: x-small;"> System.Text;</span></span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"> </span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></span></span></div>
<p></span></span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></p>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using<span style="font-size: x-small;"> System.Net;</span></span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"> </span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></span></span></div>
<p></span></span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></p>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using<span style="font-size: x-small;"> System.Xml;</span></span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">namespace</span></span><span style="font-size: x-small;"> Microsoft.Crm.Sdk.Reference</span></span></span></div>
<div><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></span></span></div>
<p></span></span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"></p>
<div><span style="font-size: x-small;">{</span></div>
<div><span style="font-size: x-small;"><span style="color: #008000; font-size: x-small;"><span style="color: #008000; font-size: x-small;">// Microsoft Dynamics CRM namespaces</span></span></span></div>
<div><span style="font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using</span></span><span style="font-size: x-small;"> CrmSdk;</span></span></div>
<p></span></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">using</span></span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">CrmSdk.Discovery;</span></div>
<div><span style="font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">public</span></span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">class</span></span><span style="font-size: x-small;"> </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">Impersonation</span></span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<div><span style="font-size: x-small;"> </span></div>
<p><span style="font-size: x-small;"> </p>
<p></span></p>
<div><span style="font-size: x-small;">{</span></div>
<div><span style="font-size: x-small;">[<span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">STAThread</span></span><span style="font-size: x-small;">]</span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">public</span></span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">static</span></span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">void</span></span><span style="font-size: x-small;"> Main(</span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">string</span></span><span style="font-size: x-small;">[] args)</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">{</span></div>
<div><span style="font-size: x-small;"><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CrmAuthenticationToken</span></span><span style="font-size: x-small;"> token = </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CrmAuthenticationToken</span></span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">();</span></div>
<div><span style="font-size: x-small;">token.AuthenticationType = 0; <span style="color: #008000; font-size: x-small;"><span style="color: #008000; font-size: x-small;">// Use Active Directory authentication.</span></span></span></div>
<div><span style="font-size: x-small;"><span style="font-size: x-small;">token.OrganizationName = </span><span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;AdventureWorksCycle&#8221;</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<p><span style="font-size: x-small;"> </p>
<p></span></p>
<div><span style="font-size: x-small;"><span style="color: #008000; font-size: x-small;"><span style="color: #008000; font-size: x-small;">// Use the global user ID of the system user that is to be impersonated.</span></span></span></div>
<div><span style="font-size: x-small;"><span style="font-size: x-small;">token.CallerId = </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">Guid</span></span><span style="font-size: x-small;">(</span><span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;94092D6F-B367-DC11-9C93-0003FFDFCE28&#8243;</span></span><span style="font-size: x-small;">);</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">CrmService crmService = <span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> CrmService();crmService.Url = </span></span></div>
<div><span style="font-size: x-small;"><span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;http://localhost/MSCRMServices/2007/CrmService.asmx&#8221;</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">crmService.CrmAuthenticationTokenValue = token;</span></div>
<div><span style="font-size: x-small;">crmService.Credentials = System.Net.<span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CredentialCache</span></span><span style="font-size: x-small;">.DefaultCredentials;</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;"><span style="color: #008000; font-size: x-small;"><span style="color: #008000; font-size: x-small;">// Create a new account owned by the impersonated user.</span></span></span></div>
<div><span style="font-size: x-small;"><span style="font-size: x-small;">account account = </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> account();</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">account.name = <span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;Fabrikam&#8221;</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">Guid</span></span><span style="font-size: x-small;"> accountid = crmService.Create(account);</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">}</span></div>
<div><span style="font-size: x-small;">}</span></div>
<div><span style="font-size: x-small;">}</span></div>
<p></span><span style="font-size: x-small;">// my own code comes here</p>
<p></span></p>
<p>The other way is of course to authenticate youself by providing this information to CRM Web service.</p>
<div><span style="font-size: x-small;"><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CrmService</span></span><span style="font-size: x-small;"> service = </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">null</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<div><span style="font-size: x-small;"></span></div>
<p><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">service = <span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CrmService</span></span><span style="font-size: x-small;">();</span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">service.Url = <span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;http://crm/MSCrmServices/2007/CrmService.asmx&#8221;</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;"><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CrmAuthenticationToken</span></span><span style="font-size: x-small;"> token = </span><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">CrmAuthenticationToken</span></span><span style="font-size: x-small;">();</span></span></div>
<div><span style="font-size: x-small;"> </span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">token.AuthenticationType = 0;</span></div>
<div><span style="font-size: x-small;">token.OrganizationName = <span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;putyourorganizationnamehere&#8221;</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">System.Net.<span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">ICredentials</span></span><span style="font-size: x-small;"> myCredentials;myCredentials = </span></span></div>
<div><span style="font-size: x-small;"><span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">new</span></span><span style="font-size: x-small;"> </span><span style="color: #2b91af; font-size: x-small;"><span style="color: #2b91af; font-size: x-small;">NetworkCredential</span></span><span style="font-size: x-small;">(</span><span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;useraccount&#8221;</span></span><span style="font-size: x-small;">, </span><span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;password****&#8221;</span></span><span style="font-size: x-small;">, </span><span style="color: #a31515; font-size: x-small;"><span style="color: #a31515; font-size: x-small;">&#8220;domain&#8221;</span></span><span style="font-size: x-small;">);</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">service.Credentials = myCredentials;</span></div>
<div><span style="font-size: x-small;">service.PreAuthenticate = <span style="color: #0000ff; font-size: x-small;"><span style="color: #0000ff; font-size: x-small;">true</span></span><span style="font-size: x-small;">;</span></span></div>
<div><span style="font-size: x-small;"></span></div>
<p></span><span style="font-size: x-small;"></p>
<div><span style="font-size: x-small;">service.CrmAuthenticationTokenValue = token;</span></div>
<div><span style="font-size: x-small;">// do your stuff on service object (same as the above example)</span></div>
<div><span style="font-size: x-small;">// Create a new account owned by the impersonated user.</span></div>
<p></span><span style="font-size: x-small;">account account = new account();</p>
<p>account.name = &#8220;Fabrikam&#8221;;</p>
<p>Guid accountid = crmService.Create(account);</p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/crm-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM Web reference vs CRM SDK</title>
		<link>http://www.hansrasmussen.com/2010/02/crm-web-reference-vs-crm-sdk/</link>
		<comments>http://www.hansrasmussen.com/2010/02/crm-web-reference-vs-crm-sdk/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 23:21:11 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Webservice]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=24</guid>
		<description><![CDATA[While working in a project where we integrate with CRM, I noticed how important it is not to mix the ways you can integrate with. Either you create a reference to the CRM Web service in your Visual Studio project and the proxy classes are generated. Or you can reference microsoft.crm.sdk.dll and microsoft.crm.sdktypeproxy.dll that exists&#38;nbsp;in [...]]]></description>
			<content:encoded><![CDATA[<p>While working in a project where we integrate with CRM, I noticed how important it is not to mix the ways you can integrate with.</p>
<p>Either you create a reference to the CRM Web service in your Visual Studio project and the proxy classes are generated.</p>
<p>Or you can reference microsoft.crm.sdk.dll and microsoft.crm.sdktypeproxy.dll that exists&amp;nbsp;in the CRM SDK.</p>
<p>You will soon notice that if you create a Request object, or maybe a BusinessEntity, DynamicEntity they are not compatible with eachother, and furthermore they might not even have the same methods and properties.</p>
<p>My recommendation is to use the CRM SDK only and never create a Web reference from within Visual Studio. The CRM SDK objects have more friendly properties and methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/crm-web-reference-vs-crm-sdk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

