<?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</title>
	<atom:link href="http://www.hansrasmussen.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hansrasmussen.com</link>
	<description>info@hansrasmussen.com, +46 (0)760480046</description>
	<lastBuildDate>Wed, 19 May 2010 20:58:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Validation with jQuery validator plugin</title>
		<link>http://www.hansrasmussen.com/2010/05/validation-with-jquery-validator-plugin/</link>
		<comments>http://www.hansrasmussen.com/2010/05/validation-with-jquery-validator-plugin/#comments</comments>
		<pubDate>Wed, 19 May 2010 20:56:49 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=776</guid>
		<description><![CDATA[Reference
http://docs.jquery.com/Plugins/Validation/
 
Setup
A reference to jQuery validator plugin
&#60;script type=&#8221;text/javascript&#8221; src=&#8221;http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js&#8221;&#62;&#60;/script&#62;
 
A reference to jQuery
&#60;script type=&#8221;text/javascript&#8221; src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8221;&#62;&#60;/script&#62;
 
Configuration – simple on class and attribute level
It is possible to declare your validation rules in various ways. It is suggested primarily to try it on class and attribute level and secondary using dependency-callback.
 
Example class and attribute rules:
&#60;input id=&#8221;cemail&#8221; name=&#8221;email&#8221; size=&#8221;25&#8243; class=&#8221;required email&#8221; [...]]]></description>
			<content:encoded><![CDATA[<h2><strong><em><span style="font-size: medium;">Reference</span></em></strong></h2>
<p><a href="http://docs.jquery.com/Plugins/Validation/"><span style="text-decoration: underline;"><span style="font-size: small;">http://docs.jquery.com/Plugins/Validation/</span></span></a></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Setup</span></em></strong></h2>
<p><span style="font-size: small;">A reference to </span><span style="font-size: small;">jQuery</span><span style="font-size: small;"> validator</span><span style="font-size: small;"> plugin</span><br />
<span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">script</span> <span style="font-size: x-small;">type</span><span style="font-size: x-small;">=&#8221;text/javascript&#8221;</span> <span style="font-size: x-small;">src</span><span style="font-size: x-small;">=&#8221;http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js&#8221;&gt;&lt;/</span><span style="font-size: x-small;">script</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">A reference to jQuery</span><br />
<span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">script</span> <span style="font-size: x-small;">type</span><span style="font-size: x-small;">=&#8221;text/javascript&#8221;</span> <span style="font-size: x-small;">src</span><span style="font-size: x-small;">=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8221;&gt;&lt;/</span><span style="font-size: x-small;">script</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration</span></em></strong><strong><em><span style="font-size: medium;"> – simple on class and attribute level</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to declare your validation rules in various ways. It is suggested </span><span style="font-size: small;">primarily</span><span style="font-size: small;"> to try it on </span><span style="font-size: small;">class and attribute level and secondary using dependency-callback.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">Example class and attribute rules:</span></p>
<p><span style="font-size: small;">&lt;input id=&#8221;cemail&#8221; name=&#8221;email&#8221; size=&#8221;25&#8243; </span><strong><span style="font-size: small;">class=&#8221;required email&#8221;</span></strong> <strong><span style="font-size: small;">minlength=&#8221;2&#8243;</span></strong><strong><span style="font-size: small;"> title=”</span></strong><strong><span style="font-size: small;">Required or not correct format.</span></strong><strong><span style="font-size: small;">”</span></strong><span style="font-size: small;"> /&gt;</span></p>
<p><span style="font-size: small;">/* this would check that email is entered, that at least 2 characters are typed and also that email validation rule */</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is registered by</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate();</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">A list of available validators can be found here </span><a href="http://docs.jquery.com/Plugins/Validation/#List_of_built-in_Validation_methods"><span style="text-decoration: underline;"><span style="font-size: small;">http://docs.jquery.com/Plugins/Validation/#List_of_built-in_Validation_methods</span></span></a></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">There are also custom validation rules that can be implemented by including additional-methods.js (when you download the plugin validation package).</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">If you don’t specify any validation messages you will get standard validation messages so it would be a nice thing to specify your own.</span><span style="font-size: small;"> The title attribute is available for a standard message, however if you need to customize the message for each different type of validation error, check later advanced topic on how to customization validate()</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – custom messages</span></em></strong></h2>
<p><span style="font-size: small;">To specify your own messages you pass it into your form validation rules</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is changed to</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><strong><span style="font-size: small;">{</span></strong></p>
<p><strong><span style="font-size: small;">   messages: {</span></strong></p>
<p><strong><span style="font-size: small;">     email: {</span></strong></p>
<p><strong><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></strong></p>
<p><strong><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></strong></p>
<p><strong><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></strong></p>
<p><strong><span style="font-size: small;">     }</span></strong></p>
<p><strong><span style="font-size: small;">   }</span></strong></p>
<p><strong><span style="font-size: small;">}</span></strong><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – </span></em></strong><strong><em><span style="font-size: medium;">specify rules for validate()</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to define </span><span style="font-size: small;">your own rules by sending on more options </span><span style="font-size: small;">for</span><span style="font-size: small;"> validate()</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">Example class and attribute rules:</span></p>
<p><span style="font-size: small;">&lt;input id=&#8221;cemail&#8221; name=&#8221;email&#8221; size=&#8221;25&#8243; /&gt;</span></p>
<p><span style="font-size: small;">/* notice that we now removed the class and attribute rules from the input element  */</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is then changed to use</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><strong><span style="font-size: small;">{</span></strong></p>
<p><strong><span style="font-size: small;">   rules: {</span></strong></p>
<p><strong><span style="font-size: small;">     email: {</span></strong></p>
<p><strong><span style="font-size: small;">       required: true,</span></strong></p>
<p><strong><span style="font-size: small;">       email: true</span></strong><strong><span style="font-size: small;">,</span></strong></p>
<p><strong><span style="font-size: small;">       </span></strong><strong><span style="font-size: small;">minlength</span></strong><strong><span style="font-size: small;">: </span></strong><strong><span style="font-size: small;">2</span></strong></p>
<p><strong><span style="font-size: small;">     }</span></strong></p>
<p><strong><span style="font-size: small;">   }</span></strong><strong><span style="font-size: small;">,</span></strong></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><strong><span style="font-size: small;">   }</span></strong></p>
<p><strong><span style="font-size: small;">}</span></strong><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – validation using dependency expression</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to define limit validation for a specific expression (such as #object:checked, #object:filled, #object.visible)</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is then changed to use</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><span style="font-size: small;">   rules: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><strong><span style="font-size: small;">       required: “#identifyofmycheckbox:checked”,</span></strong></p>
<p><span style="font-size: small;">       email: true,</span></p>
<p><span style="font-size: small;">       minlength: 2</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   },</span></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   }</span></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Configuration – validation using dependency callback</span></em></strong></h2>
<p><span style="font-size: small;">It is possible to define limit validation using your own functions. This enables even more complex checks such as ajax-calls to perform server side checks.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">The validation on the form is then changed to use</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><span style="font-size: small;">   rules: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><strong><span style="font-size: small;">       required: function(element) {</span></strong></p>
<p><strong><span style="font-size: small;">        return </span></strong><strong><span style="font-size: small;">getValidationIsEmailNeededFromServer()</span></strong><strong><span style="font-size: small;">;</span></strong></p>
<p><strong><span style="font-size: small;">      },</span></strong></p>
<p><span style="font-size: small;">       email: true,</span></p>
<p><span style="font-size: small;">       minlength: 2</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   },</span></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   }</span></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;">  &lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">It is also possible to use the addMethod() to register any custom checks to the validator</span></p>
<p><span style="font-size: small;">  &lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><span style="font-size: small;">   rules: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: true,</span></p>
<p><span style="font-size: small;">       email: true,</span></p>
<p><span style="font-size: small;">       minlength: 2</span><span style="font-size: small;">,</span><br />
<strong><span style="font-size: small;">       duplicate: true</span></strong><br />
<span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   },</span></p>
<p><span style="font-size: small;">   messages: {</span></p>
<p><span style="font-size: small;">     email: {</span></p>
<p><span style="font-size: small;">       required: &#8220;We need your email address to contact you&#8221;,</span></p>
<p><span style="font-size: small;">       email: &#8220;Your email address must be in the format of name@domain.com&#8221;,</span></p>
<p><span style="font-size: small;">       minlength: jQuery.format(&#8220;At least {0} characters required!&#8221;)</span></p>
<p><span style="font-size: small;">     }</span></p>
<p><span style="font-size: small;">   }</span></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;"> </span></p>
<p><strong><span style="font-size: small;">    jQuery.validator.addMethod(&#8220;duplicate&#8221;, function(value, element, params) {</span></strong></p>
<p><strong><span style="font-size: small;">        return checkUniqueEmail(value) {</span></strong></p>
<p><strong><span style="font-size: small;">    }, jQuery.format(&#8220;Email is not unique.&#8221;));</span></strong></p>
<p><span style="font-size: small;">  </span><span style="font-size: small;">&lt;/script&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<h2><strong><em><span style="font-size: medium;">Placement of errors</span></em></strong></h2>
<p><span style="font-size: small;">By default jQuery validator injects the error messages just next to the control that does not validate. It also adds an error class on each element that does not validate. Therefore it is easy to style elements and give an invalid &lt;input&gt; element a red border when it is invalid.</span></p>
<p><span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">style</span> <span style="font-size: x-small;">type</span><span style="font-size: x-small;">=&#8221;text/css&#8221;&gt;</span></p>
<p><span style="font-size: x-small;">input.error { border: 1px solid red; }</span></p>
<p><span style="font-size: x-small;">input.error:focus { border: 1px solid red; }</span></p>
<p><span style="font-size: x-small;">&lt;/</span><span style="font-size: x-small;">style</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">If you want to override the placement of errors next to your invalid control you can specify the errorPlacement</span><span style="font-size: small;"> function.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">&lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><strong><span style="font-size: small;">    errorPlacement: function(error, element) { </span></strong></p>
<p><strong><span style="font-size: small;">        error.insertBefore(element); </span></strong></p>
<p><strong><span style="font-size: small;">    } </span></strong></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">However in some situations this would mess up your design and therefore you might use a summary instead. To pinpoint a specific area where you’d like to have your summary displayed you can use an errorLabelContainer and even define if you’d like to wrap your elements with a specific tag.</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">&lt;script&gt;</span></p>
<p><span style="font-size: small;">  $(document).ready(function(){</span></p>
<p><span style="font-size: small;">    $(&#8220;#aspnetForm&#8221;).validate(</span></p>
<p><span style="font-size: small;">{</span></p>
<p><strong><span style="font-size: small;">    error</span></strong><strong><span style="font-size: small;">LabelContainer</span></strong><strong><span style="font-size: small;">: </span></strong><strong><span style="font-size: small;">“#ErrorBox”,</span></strong></p>
<p><strong><span style="font-size: small;">    </span></strong><strong><span style="font-size: small;">wrapper</span></strong><strong><span style="font-size: small;">: </span></strong><strong><span style="font-size: small;">“li”</span></strong></p>
<p><span style="font-size: small;">}</span><br />
<span style="font-size: small;">      </span><span style="font-size: small;">);</span></p>
<p><span style="font-size: small;">  });</span></p>
<p><span style="font-size: small;"> </span></p>
<p><span style="font-size: small;">/*</span></p>
<p><span style="font-size: small;">In your html you need to have your error box defined, since you reference it in your javascript</span></p>
<p><span style="font-size: small;">*/</span></p>
<p><span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">div&gt;</span><span style="font-size: x-small;">&lt;</span><span style="font-size: x-small;">ul</span> <span style="font-size: x-small;">id</span><span style="font-size: x-small;">=&#8221;ErrorBox&#8221;&gt;&lt;/</span><span style="font-size: x-small;">ul</span><span style="font-size: x-small;">&gt;&lt;/</span><span style="font-size: x-small;">div</span><span style="font-size: x-small;">&gt;</span></p>
<p><span style="font-size: small;"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/05/validation-with-jquery-validator-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Live Writer with WordPress</title>
		<link>http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/</link>
		<comments>http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 00:27:18 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Setup]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Windows Live Writer]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/</guid>
		<description><![CDATA[ 
I use WordPress as a blogging tool. Instead of logging into the administration system I can easily create my blog entries in a desktop program and publish my entry if XML-RPC and Atom Publishing Protocol settings are enabled in your WordPress blog (Settings –&#62; Writing)
I use Windows Live Writer and my blog is in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hansrasmussen.com/wp-content/uploads/2010/03/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.hansrasmussen.com/wp-content/uploads/2010/03/image_thumb.png" width="244" height="221" /></a> </p>
<p>I use WordPress as a blogging tool. Instead of logging into the administration system I can easily create my blog entries in a desktop program and publish my entry if XML-RPC and Atom Publishing Protocol settings are enabled in your WordPress blog (Settings –&gt; Writing)</p>
<p>I use Windows Live Writer and my blog is in a hosted environment and therefore I can not configure server myself since configuration is shared among all users.</p>
<p>I noticed using WordPress 2.9.2 that I could not use any desktop program to remotely publish correctly formatted posts anymore. &lt;&gt; and &amp; characters were removed from my posts and therefore rendered incorrectly. I found out that it is was caused by an incorrect usage of a library, LibXML2, associated with PHP (the scripting engine WordPress use). </p>
<p>To correct this problem in a hosted environment you can download a plug-in that will help you take care of this problem. <a title="http://core.trac.wordpress.org/ticket/7771" href="http://core.trac.wordpress.org/ticket/7771">http://core.trac.wordpress.org/ticket/7771</a></p>
<p>The plugin can be located here <a title="http://josephscott.org/code/wordpress/plugin-libxml2-fix/" href="http://josephscott.org/code/wordpress/plugin-libxml2-fix/">http://josephscott.org/code/wordpress/plugin-libxml2-fix/</a></p>
<p>If you still have problems (which I had), you can try to downgrade the library one version further by editing the plugin file libxml2-fix.php</p>
<p>Replace:</p>
<p>if (    <br />&#160;&#160;&#160; LIBXML_DOTTED_VERSION == &#8216;2.6.27&#8242; </p>
<p>With: </p>
<p>if (    <br />&#160;&#160;&#160; LIBXML_DOTTED_VERSION ==<strong> &#8216;2.6.26&#8242;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/03/windows-live-writer-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS SQL Server &#8211; Principal &#8220;username&#8221; is not able to access the database &#8220;db&#8221; under the current security context</title>
		<link>http://www.hansrasmussen.com/2010/03/ms-sql-server-principal-username-is-not-able-to-access-the-database-db-under-the-current-security-context/</link>
		<comments>http://www.hansrasmussen.com/2010/03/ms-sql-server-principal-username-is-not-able-to-access-the-database-db-under-the-current-security-context/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 09:20:36 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=693</guid>
		<description><![CDATA[Error:
The server principal &#8220;username&#8221; is not able to access the database &#8220;dbname&#8221; under the current security context.
.Net SqlClient Data Provider in SQL Server Management Studio.
Reason:
This is because the MS SQL Server is attempting to execute a T-SQL query to retrieve a list of databases along with additional information about those databases. One of those pieces [...]]]></description>
			<content:encoded><![CDATA[<p>Error:<br />
The server principal &#8220;username&#8221; is not able to access the database &#8220;dbname&#8221; under the current security context.<br />
.Net SqlClient Data Provider in SQL Server Management Studio.</p>
<p>Reason:<br />
This is because the MS SQL Server is attempting to execute a T-SQL query to retrieve a list of databases along with additional information about those databases. One of those pieces of information is &#8220;Collation&#8221;, which you will not have permission to action for all databases as you&#8217;re in a shared hosting environment and you only have access to your database alone.</p>
<p>Solution:<br />
Step 1: In Object Explorer, click Databases<br />
Step 2: Display Object Explorer Details (F7) or View &gt; Object Explorer Details<br />
Step 3: Right click the column headers and de-select &#8220;Collation&#8221;<br />
Step 4: Refresh Databases.</p>
<p>Reference:<br />
<a href="http://www.kf7.co.uk/sql-server-principal-not-able-access-database.aspx">http://www.kf7.co.uk/sql-server-principal-not-able-access-database.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/03/ms-sql-server-principal-username-is-not-able-to-access-the-database-db-under-the-current-security-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sabang Bay / Puerto Galera / Philippines</title>
		<link>http://www.hansrasmussen.com/2010/02/sabang-bay-puerto-galera-philippines/</link>
		<comments>http://www.hansrasmussen.com/2010/02/sabang-bay-puerto-galera-philippines/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:06:26 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[diving]]></category>
		<category><![CDATA[philippines]]></category>
		<category><![CDATA[puerto galera]]></category>
		<category><![CDATA[sabang]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=689</guid>
		<description><![CDATA[I have some friends in Philippines, that have a great diving center. Björn and Alice are their names and can be reached at http://www.abwonderdive.com. They have posted this video on YouTube that shows off a bit what can be seen. Unfortunately our own pictures were not that great, I don&#8217;t even recall which underwater camera [...]]]></description>
			<content:encoded><![CDATA[<p>I have some friends in Philippines, that have a great diving center. Björn and Alice are their names and can be reached at <a href="http://www.abwonderdive.com">http://www.abwonderdive.com</a>. They have posted this video on YouTube that shows off a bit what can be seen. Unfortunately our own pictures were not that great, I don&#8217;t even recall which underwater camera we had or maybe if we just borrowed one.</p>
<p><span class="youtube">
<object width="540" height="450">
<param name="movie" value="http://www.youtube.com/v/-EBxReP_BkE&amp;rel=1&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=1&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/-EBxReP_BkE&amp;rel=1&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=1&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="540" height="450"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=-EBxReP_BkE&fmt=18">www.youtube.com/watch?v=-EBxReP_BkE</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/sabang-bay-puerto-galera-philippines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vacation South Africa, Mocambique, Swaziland</title>
		<link>http://www.hansrasmussen.com/2010/02/vacation-south-africa-mocambique-swaziland/</link>
		<comments>http://www.hansrasmussen.com/2010/02/vacation-south-africa-mocambique-swaziland/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 23:03:27 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Mocambique]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[South Africa]]></category>
		<category><![CDATA[Swaziland]]></category>
		<category><![CDATA[vacation]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=372</guid>
		<description><![CDATA[
December 27, 2009 &#8211; January 13, 2010 I was on a fantastic trip to South Africa, Mocambique and Swaziland. A total of 3000 km was spent driving to the different destinations (you should see them pinned in one of the images that represents the map). The wildlife is amazing and the people are superfriendly. I&#8217;d like to share [...]]]></description>
			<content:encoded><![CDATA[<p>
<!-- SlidePress Gallery 1.3.8 [vacation2010southafrica] -->

<div class="slidepress-gallery">
	<div id="ssp_g_vacation2010southafrica">
		<p>This SlideShowPro photo gallery requires the Flash Player plugin and a web browser with JavaScript enabled.</p>	</div>
</div>
<script type="text/javascript">
var flashvars = {
		paramXMLPath: "http://www.hansrasmussen.com/wp-content/plugins/slidepress/tools/param.php?gid=vacation2010southafrica",
	initialURL: escape(document.location),
  useExternalInterface : true
}
var params = {
	base: ".",
	quality: "best",
	bgcolor: "#121212",
	wmode: "transparent",
	allowfullscreen: "true",
	allowScriptAccess: "always"
}
var attributes = {}
swfobject.embedSWF("http://www.hansrasmussen.com/wp-content/uploads/slidepress/flash/slideshowpro.swf", "ssp_g_vacation2010southafrica", "540", "450", "9.0.0", false, flashvars, params, attributes);
</script>

<!-- SlidePress Gallery ends --></p>
<div style="display: none;"><a href="http://www.hansrasmussen.com/wp-content/uploads/2010/02/Day04-05.jpg"><img class="alignright size-medium wp-image-429" title="Day04-05" src="http://www.hansrasmussen.com/wp-content/uploads/2010/02/Day04-05-200x300.jpg" alt="" width="200" height="300" /></a></div>
<p>December 27, 2009 &#8211; January 13, 2010 I was on a fantastic trip to South Africa, Mocambique and Swaziland. A total of 3000 km was spent driving to the different destinations (you should see them pinned in one of the images that represents the map). The wildlife is amazing and the people are superfriendly. I&#8217;d like to share some of my images from this trip and hope you will enjoy them. Definately a trip worth remembering.</p>
<p>The only setback was that the diving in Mocambique was somewhat disappointing considering the other spots I have visited. On the other hand there are not many other dive sites that have the same opportunities to enjoy Whale Sharks and Manta Rays.</p>
<p><a href="http://www.hansrasmussen.com/wp-content/uploads/2010/02/Day04-05.jpg"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/vacation-south-africa-mocambique-swaziland/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Diving in Egypt</title>
		<link>http://www.hansrasmussen.com/2010/02/diving-in-egypt/</link>
		<comments>http://www.hansrasmussen.com/2010/02/diving-in-egypt/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 00:22:52 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Dahab]]></category>
		<category><![CDATA[diving]]></category>
		<category><![CDATA[Egypt]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Sharm El Sheikh]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=553</guid>
		<description><![CDATA[
Some friends (Rita and Rene) arranged a diving trip to Sharm El Sheikh in Egypt for a week in November 2008. We had a lovely time diving at some various spots including Ras Mohammad national park and Dahab.

]]></description>
			<content:encoded><![CDATA[<p>
<!-- SlidePress Gallery 1.3.8 [vacation2008egypt] -->

<div class="slidepress-gallery">
	<div id="ssp_g_vacation2008egypt">
		<p>This SlideShowPro photo gallery requires the Flash Player plugin and a web browser with JavaScript enabled.</p>	</div>
</div>
<script type="text/javascript">
var flashvars = {
		paramXMLPath: "http://www.hansrasmussen.com/wp-content/plugins/slidepress/tools/param.php?gid=vacation2008egypt",
	initialURL: escape(document.location),
  useExternalInterface : true
}
var params = {
	base: ".",
	quality: "best",
	bgcolor: "#121212",
	wmode: "transparent",
	allowfullscreen: "true",
	allowScriptAccess: "always"
}
var attributes = {}
swfobject.embedSWF("http://www.hansrasmussen.com/wp-content/uploads/slidepress/flash/slideshowpro.swf", "ssp_g_vacation2008egypt", "540", "450", "9.0.0", false, flashvars, params, attributes);
</script>

<!-- SlidePress Gallery ends --></p>
<p>Some friends (Rita and Rene) arranged a diving trip to Sharm El Sheikh in Egypt for a week in November 2008. We had a lovely time diving at some various spots including Ras Mohammad national park and Dahab.</p>
<div style="display: none;"><a href="http://www.hansrasmussen.com/wp-content/uploads/2010/02/001.jpg"><img class="alignright size-medium wp-image-574" title="001" src="http://www.hansrasmussen.com/wp-content/uploads/2010/02/001-300x225.jpg" alt="" width="300" height="225" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/diving-in-egypt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diving in Maldives, Kuredu</title>
		<link>http://www.hansrasmussen.com/2010/02/diving-in-maldives-kuredu/</link>
		<comments>http://www.hansrasmussen.com/2010/02/diving-in-maldives-kuredu/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 00:01:07 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[diving]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Kuredu]]></category>
		<category><![CDATA[Maldives]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=604</guid>
		<description><![CDATA[
In April 2008 we made a diving trip to Maldives and the island Kuredu. Kuredu is in the Lhaviyani Atoll a bit north of Male airport. The diving was quite nice although I heard from Christian that there are much more life in other more southern atolls (probably due to overfishing where the islands are [...]]]></description>
			<content:encoded><![CDATA[<p>
<!-- SlidePress Gallery 1.3.8 [vacation2008maldives] -->

<div class="slidepress-gallery">
	<div id="ssp_g_vacation2008maldives">
		<p>This SlideShowPro photo gallery requires the Flash Player plugin and a web browser with JavaScript enabled.</p>	</div>
</div>
<script type="text/javascript">
var flashvars = {
		paramXMLPath: "http://www.hansrasmussen.com/wp-content/plugins/slidepress/tools/param.php?gid=vacation2008maldives",
	initialURL: escape(document.location),
  useExternalInterface : true
}
var params = {
	base: ".",
	quality: "best",
	bgcolor: "#121212",
	wmode: "transparent",
	allowfullscreen: "true",
	allowScriptAccess: "always"
}
var attributes = {}
swfobject.embedSWF("http://www.hansrasmussen.com/wp-content/uploads/slidepress/flash/slideshowpro.swf", "ssp_g_vacation2008maldives", "540", "450", "9.0.0", false, flashvars, params, attributes);
</script>

<!-- SlidePress Gallery ends --></p>
<p>In April 2008 we made a diving trip to Maldives and the island Kuredu. Kuredu is in the Lhaviyani Atoll a bit north of Male airport. The diving was quite nice although I heard from Christian that there are much more life in other more southern atolls (probably due to overfishing where the islands are more populated). Although you don&#8217;t have to dive to get some nice views (we saw the most just by snorkling on the outter rief). This was also the first time I got to see a Manta Ray. If you wish to travel there you can book a stay at <a href="http://www.kuredu.com">http://www.kuredu.com</a>
<div style="display:none;"><a href="http://www.hansrasmussen.com/wp-content/uploads/2010/02/IMG_0115.jpg"><img class="alignright size-medium wp-image-620" title="IMG_0115" src="http://www.hansrasmussen.com/wp-content/uploads/2010/02/IMG_0115-300x225.jpg" alt="" width="300" height="225" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/diving-in-maldives-kuredu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding local maildrop when using CDOSYS</title>
		<link>http://www.hansrasmussen.com/2010/02/avoiding-local-maildrop-when-using-cdosys/</link>
		<comments>http://www.hansrasmussen.com/2010/02/avoiding-local-maildrop-when-using-cdosys/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 23:48:10 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[CDOSYS]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/2010/02/avoiding-local-maildrop-when-using-cdosys/</guid>
		<description><![CDATA[I experienced strange problems with some ASP scripts at a clients hosted web server. The script sends e-mails after completed execution and occasionally (quite often) some of the e-mails are not delivered or are delivered much later than expected. When running in a hosted environment it is also very hard to track as you have [...]]]></description>
			<content:encoded><![CDATA[<p>I experienced strange problems with some ASP scripts at a clients hosted web server. The script sends e-mails after completed execution and occasionally (quite often) some of the e-mails are not delivered or are delivered much later than expected. When running in a hosted environment it is also very hard to track as you have very limited access to the server itself. After digging in some Microsoft documentation I noticed that it is possible to direct the traffic to the SMTP server of your choice instead. CDOSYS will execute a little bit slower but now I have the opportunity to target the e-mail to the SMTP server of my choice.</p>
<p>    Set oCdoMail = Server.CreateObject(&#8220;CDO.Message&#8221;)</p>
<p>    Set oCdoConf = Server.CreateObject(&#8220;CDO.Configuration&#8221;)</p>
<p>    sConfURL = &#8220;<a href="http://schemas.microsoft.com/cdo/configuration/">http://schemas.microsoft.com/cdo/configuration/</a>&#8221;</p>
<p>    with oCdoConf</p>
<p>      .Fields.Item(sConfURL &amp; &#8220;sendusing&#8221;) = 2</p>
<p>      .Fields.Item(sConfURL &amp; &#8220;smtpserver&#8221;) = &#8220;smtp.themailserverofyourchoice.com&#8221;</p>
<p>      .Fields.Item(sConfURL &amp; &#8220;smtpserverport&#8221;) = 25</p>
<p>      .Fields.Item(sConfURL &amp; &#8220;smtpauthenticate&#8221;) = 1 </p>
<p>      .Fields.Item(sConfURL &amp; &#8220;sendusername&#8221;) = &#8220;<a href="mailto:accountname@themailserverofyourchoice.com">accountname@themailserverofyourchoice.com</a>&#8220; </p>
<p>      .Fields.Item(sConfURL &amp; &#8220;sendpassword&#8221;) = &#8220;verysecretpassword&#8221; </p>
<p>      .Fields.Update</p>
<p>    end with</p>
<p> oCdoMail.From = &#8221;<a href="mailto:fromemail@someserver.com">fromemail@someserver.com</a>&#8221;</p>
<p> oCdoMail.To = &#8221;<a href="mailto:toemail@someserver.com">toemail@someserver.com</a>&#8221;</p>
<p> oCdoMail.Subject = &#8221;Subjct of the message&#8221;</p>
<p> oCdoMail.HTMLBody = &#8220;Some message including some HTML coding&#8221;</p>
<p> oCdoMail.Configuration = oCdoConf</p>
<p> oCdoMail.Send</p>
<p> Set oCdoConf = Nothing</p>
<p> Set oCdoMail = Nothing</p>
<p><a href="http://support.microsoft.com/kb/555287">http://support.microsoft.com/kb/555287</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/avoiding-local-maildrop-when-using-cdosys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Encoding in your Visual Studio project</title>
		<link>http://www.hansrasmussen.com/2010/02/encoding-in-your-visual-studio-project/</link>
		<comments>http://www.hansrasmussen.com/2010/02/encoding-in-your-visual-studio-project/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 23:47:26 +0000</pubDate>
		<dc:creator>Hans Rasmussen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://www.hansrasmussen.com/?p=50</guid>
		<description><![CDATA[Have you experienced problems in your Visual Studio projects that no matter which encoding you try to use in your pages &#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;iso-8859-1&#8243;?&#62; for XML or &#60;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243; /&#62; but still you have problems solving swedish characters such as å, å and ö when posting information to external webservice etc.
 Try and configure your [...]]]></description>
			<content:encoded><![CDATA[<p>Have you experienced problems in your Visual Studio projects that no matter which encoding you try to use in your pages &lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;iso-8859-1&#8243;?&gt; for XML or &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243; /&gt; but still you have problems solving swedish characters such as å, å and ö when posting information to external webservice etc.</p>
<p> Try and configure your application&#8217;s web.config file and add encoding to your globalization element and now things are working way better.</p>
<p> &lt;system.web&gt;</p>
<p>    &lt;globalization</p>
<p>               fileEncoding=&#8221;iso-8859-1&#8243;</p>
<p>               requestEncoding=&#8221;iso-8859-1&#8243;</p>
<p>               responseEncoding=&#8221;iso-8859-1&#8243;</p>
<p>        /&gt;</p>
<p>&lt;/system.web&gt;</p>
<p> This behavior to determine encoding is probably the reason why a WebForm intitially contains no information about encoding at all.</p>
<p>&lt;%@ Page Language=&#8221;C#&#8221; AutoEventWireup=&#8221;true&#8221; CodeBehind=&#8221;WebForm1.aspx.cs&#8221; Inherits=&#8221;WebForm1&#8243; %&gt;</p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&#8220;&gt;</p>
<p>&lt;html xmlns=&#8221;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&#8221; &gt;</p>
<p>&lt;head runat=&#8221;server&#8221;&gt;</p>
<p>    &lt;title&gt;Untitled Page&lt;/title&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>    &lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;</p>
<p>    &lt;div&gt;</p>
<p>    &lt;/div&gt;</p>
<p>    &lt;/form&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>More information can be found on <a href="http://msdn.microsoft.com/en-us/library/ydkak5b9(VS.71).aspx" target="_blank">Microsoft Website regarding Globalization</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hansrasmussen.com/2010/02/encoding-in-your-visual-studio-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
