<?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>Shawson&#039;s Code Blog &#187; Networking</title>
	<atom:link href="http://codeblog.shawson.co.uk/category/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeblog.shawson.co.uk</link>
	<description>development notes for my failing memory</description>
	<lastBuildDate>Wed, 01 Feb 2012 11:00:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Netgear ReadyNAS Duo command line shut down utility</title>
		<link>http://codeblog.shawson.co.uk/netgear-readynas-duo-command-line-shut-down-utility/</link>
		<comments>http://codeblog.shawson.co.uk/netgear-readynas-duo-command-line-shut-down-utility/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 21:20:45 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://codeblog.shawson.co.uk/?p=1082</guid>
		<description><![CDATA[So I finished the backup app and compiled it for anyone who wants it- it&#8217;s used from the command prompt like so; ShutdownNASBox -h &#60;hostname&#62; -u &#60;username&#62; -p &#60;password&#62; eg. ShutdownNASBox -h backup -u admin -p abc123 If you run the tool with administrator privileges, it will log to the Windows Event Log on the System [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/asp-net-roles-and-membership-installed-to-local-sql-express-2008-mdf-file/' rel='bookmark' title='ASP.net Roles and Membership installed to local SQL Express 2008 MDF file'>ASP.net Roles and Membership installed to local SQL Express 2008 MDF file</a></li>
<li><a href='http://codeblog.shawson.co.uk/automatic-shutdown-of-my-netgear-readynas-duo-network-storage-server/' rel='bookmark' title='Automatic NAS Box shutdown &#8211; How to POST the shutdown command over SSL with HTTP authentication from a dot net Console app (Part 1/2)'>Automatic NAS Box shutdown &#8211; How to POST the shutdown command over SSL with HTTP authentication from a dot net Console app (Part 1/2)</a></li>
<li><a href='http://codeblog.shawson.co.uk/my-shiny-new-blog/' rel='bookmark' title='My shiny new blog'>My shiny new blog</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>So I finished the backup app and compiled it for anyone who wants it- it&#8217;s used from the command prompt like so;<br />
ShutdownNASBox -h &lt;hostname&gt; -u &lt;username&gt; -p &lt;password&gt;</p>
<p>eg.</p>
<p>ShutdownNASBox -h backup -u admin -p abc123</p>
<p>If you run the tool with administrator privileges, it will log to the Windows Event Log on the System tab.</p>
<p><a href="http://codeblog.shawson.co.uk/storage/ShutdownNASBox.zip">You can download it here</a> (note you will need <a href="http://www.microsoft.com/download/en/details.aspx?id=17851">dot net framework 4 installed</a>)</p>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/asp-net-roles-and-membership-installed-to-local-sql-express-2008-mdf-file/' rel='bookmark' title='ASP.net Roles and Membership installed to local SQL Express 2008 MDF file'>ASP.net Roles and Membership installed to local SQL Express 2008 MDF file</a></li>
<li><a href='http://codeblog.shawson.co.uk/automatic-shutdown-of-my-netgear-readynas-duo-network-storage-server/' rel='bookmark' title='Automatic NAS Box shutdown &#8211; How to POST the shutdown command over SSL with HTTP authentication from a dot net Console app (Part 1/2)'>Automatic NAS Box shutdown &#8211; How to POST the shutdown command over SSL with HTTP authentication from a dot net Console app (Part 1/2)</a></li>
<li><a href='http://codeblog.shawson.co.uk/my-shiny-new-blog/' rel='bookmark' title='My shiny new blog'>My shiny new blog</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/netgear-readynas-duo-command-line-shut-down-utility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatic NAS Box shutdown &#8211; How to POST the shutdown command over SSL with HTTP authentication from a dot net Console app (Part 1/2)</title>
		<link>http://codeblog.shawson.co.uk/automatic-shutdown-of-my-netgear-readynas-duo-network-storage-server/</link>
		<comments>http://codeblog.shawson.co.uk/automatic-shutdown-of-my-netgear-readynas-duo-network-storage-server/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 11:38:56 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Post]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[WebClient]]></category>

		<guid isPermaLink="false">http://codeblog.shawson.co.uk/?p=1036</guid>
		<description><![CDATA[I recently purchased a Netgear ReadyNAS Duo RAIDed network storage box for general backup of my &#8216;stuff and things&#8217;, which sit&#8217;s on my desk and runs off the same power as my PC.  A couple of times now I&#8217;ve booted the box up to run a backup, then forgot to shut it down, then shut [...]


Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/netgear-readynas-duo-command-line-shut-down-utility/' rel='bookmark' title='Netgear ReadyNAS Duo command line shut down utility'>Netgear ReadyNAS Duo command line shut down utility</a></li>
<li><a href='http://codeblog.shawson.co.uk/pages-jump-to-the-top-on-post-back-in-aspnet/' rel='bookmark' title='Pages jump to the top on post back in asp.net'>Pages jump to the top on post back in asp.net</a></li>
<li><a href='http://codeblog.shawson.co.uk/mvc-strongly-typed-view-returns-a-null-model-on-post-back/' rel='bookmark' title='MVC strongly typed view returns a null model on post back'>MVC strongly typed view returns a null model on post back</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>I recently purchased a <a href="http://www.readynas.com/?cat=3" target="_blank">Netgear ReadyNAS Duo</a> RAIDed network storage box for general backup of my &#8216;stuff and things&#8217;, which sit&#8217;s on my desk and runs off the same power as my PC.  A couple of times now I&#8217;ve booted the box up to run a backup, then forgot to shut it down, then shut down my PC, flick the switch at the wall and then realise.  When I boot everything back up in a day or so, the NAS box has to do a full system check and maybe rebuild the RAID array if theres a problem etc etc &#8211; it&#8217;s a pain.</p>
<p>So I thought I would set about automating the NAS box shut down with my PC shut down which turned out to be pretty easy.  The NAS box is controller via a web UI- my box has the host name &#8220;BACKUP&#8221; so I can get to it over the browser on http://BACKUP/.  This uses basic HTTP authentication asking me to login, and also use&#8217;s https (which my browser always warns me about because it&#8217;s not from a trusts CA or whatever- so I just ignore the warnings and continue).  From the web UI you can go to the system tab and select shut down and the box goes down.  I figured as this is going to be a simple web call, it should be easy enough to write a simple console app which makes the same call which can be fired on Windows shutdown- so I fired up <a href="http://getfirebug.com/" target="_blank">Firebug</a>, opened the &#8220;Net&#8221; tab, which allows you to inspect all http calls made, and triggered a shut down.  It&#8217;s probably worth noting at this point that the techniques used here could probably be applied to pretty much any other networked device with a web based UI (most routers, firewalls, switches, printers, media boxes etc) so this should hopefully be quite useful.</p>
<p style="text-align: center;"><a href="http://codeblog.shawson.co.uk/wp-content/uploads/2011/07/netgear-frontview.jpg"><img class="aligncenter size-large wp-image-1039" title="netgear-frontview" src="http://codeblog.shawson.co.uk/wp-content/uploads/2011/07/netgear-frontview-981x1024.jpg" alt="" width="550" height="574" /></a></p>
<p style="text-align: left;">Sure enough the HTTPS POST made to a file called get_handler on the root could be seen, with the POST data string;</p>
<p style="text-align: center;"><a href="http://codeblog.shawson.co.uk/wp-content/uploads/2011/07/firebug_post.jpg"><img class="aligncenter size-large wp-image-1043" title="firebug_post" src="http://codeblog.shawson.co.uk/wp-content/uploads/2011/07/firebug_post-1024x565.jpg" alt="" width="574" height="317" /></a></p>
<p style="text-align: left;">As we can see from firebug, the data sent is;</p>
<p style="text-align: left;"><code>PAGE=System&amp;OUTER_TAB=tab_shutdown&amp;INNER_TAB=NONE&amp;shutdown_option1=1&amp;command=poweroff&amp;OPERATION=set</code></p>
<p style="text-align: left;">So six key value pairs separated by ampersands.  The code itself is pretty simple using WebClient class (System.Net namespace)- however there are a couple of complications, which as it happens are fairly common things to run into, so a good opportunity to give some example code for future reference;</p>
<ul>
<li>
<h2>We need to perform our Form Post over SSL</h2>
</li>
<li>
<h2>The SSL certificate of the server we are posting to will never be valid!</h2>
</li>
<li>
<h2>We must carry out our form post while supplying basic HTTP authentication credentials</h2>
</li>
</ul>
<p>I created a new Console application and added the following code;</p>
<pre class="brush: c-sharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections.Specialized;

namespace ShutdownNASBox
{
    class Program
    {
        static void Main(string[] args)
        {
            using (WebClient client = new WebClient())
            {
                // add the basic http authentication username &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; password
                client.Credentials = new NetworkCredential(&quot;admin&quot;, &quot;abc123&quot;);

                // register the face that the connection uses SSL
                // (otherwise it defaults to TLS and you get an exception)
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

                // set it to effectivly ignore the SSL certificate
                ServicePointManager.ServerCertificateValidationCallback =
                                                        delegate { return true; };

                // build a NameValueCollection which holds those 6 values we saw
                // being posted when we used firebug
                NameValueCollection c = new NameValueCollection();
                c.Add(&quot;PAGE&quot;, &quot;System&quot;);
                c.Add(&quot;OUTER_TAB&quot;, &quot;tab_shutdown&quot;);
                c.Add(&quot;INNER_TAB&quot;, &quot;NONE&quot;);
                c.Add(&quot;shutdown_option1&quot;, &quot;1&quot;);
                c.Add(&quot;command&quot;, &quot;poweroff&quot;);
                c.Add(&quot;OPERATION&quot;, &quot;set&quot;);

                try
                {
                    // Post the data!  This will return as a byte array
                    byte[] bytes =
                    client.UploadValues(&quot;https://backup/get_handler&quot;, c);

                    // convert the byte array into text we can read!
                    string result = Encoding.ASCII.GetString(bytes);

                    Console.Write(&quot;Shutdown Message Sent&quot;);
                    Console.Write(result);

                }
                catch (Exception e)
                {
                    Console.Write(&quot;Shutdown Message Send Failure!&quot;);
                    Console.Write(e.ToString());
                }
            }
        }
    }
}
</pre>
<p>And that&#8217;s all there is to it!  An obvious and easy upgrade would be to make this parametrized and maybe get it to write to the windows log on failure.</p>
<p>In <a href="http://codeblog.shawson.co.uk/automatic-nas-box-shutdown-how-to-execute-applications-on-windows-shutdown-part-22/">part two</a> I shall do a quick post on how to schedule tasks to run on shut down in Windows 7.</p>
<p><a href="http://codeblog.shawson.co.uk/netgear-readynas-duo-command-line-shut-down-utility/">You can see the finished app, with the above recommended improvements already implemented,  here</a></p>


<p>Related posts:<ul><li><a href='http://codeblog.shawson.co.uk/netgear-readynas-duo-command-line-shut-down-utility/' rel='bookmark' title='Netgear ReadyNAS Duo command line shut down utility'>Netgear ReadyNAS Duo command line shut down utility</a></li>
<li><a href='http://codeblog.shawson.co.uk/pages-jump-to-the-top-on-post-back-in-aspnet/' rel='bookmark' title='Pages jump to the top on post back in asp.net'>Pages jump to the top on post back in asp.net</a></li>
<li><a href='http://codeblog.shawson.co.uk/mvc-strongly-typed-view-returns-a-null-model-on-post-back/' rel='bookmark' title='MVC strongly typed view returns a null model on post back'>MVC strongly typed view returns a null model on post back</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/automatic-shutdown-of-my-netgear-readynas-duo-network-storage-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VPN Problems with Vista</title>
		<link>http://codeblog.shawson.co.uk/vpn-problems-with-vista/</link>
		<comments>http://codeblog.shawson.co.uk/vpn-problems-with-vista/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 18:21:08 +0000</pubDate>
		<dc:creator>shawson</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.shawson.co.uk/codeblog/?p=230</guid>
		<description><![CDATA[Error 741: The local computer does not support the required data encryption type I recently had this problem trying to connect to my work&#8217;s VPN connection, which I had previously connected to with no problems under XP.  Apparently this is due to the security standard in Vista being too high for our old school CHAP [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<blockquote>
<h1>Error 741: The local computer does not support the required data encryption type</h1>
</blockquote>
<p><div id="attachment_231" class="wp-caption alignright" style="width: 448px"><img class="size-full wp-image-231" title="Vista VPN Error" src="http://www.shawson.co.uk/codeblog/wp-content/uploads/2009/07/error.jpg" alt="Vista VPN Error" width="438" height="308" /><p class="wp-caption-text">Vista VPN Error</p></div></p>
<p>I recently had this problem trying to connect to my work&#8217;s VPN connection, which I had previously connected to with no problems under XP.  Apparently this is due to the security standard in Vista being too high for our old school CHAP VPN connection- the fix;</p>
<ol>
<li>Right click the VPN connection and go to properties</li>
<li>Click the security tab</li>
<li>click the &#8220;Advanced (custom settings)&#8221; radio button, then click the settings button</li>
<li>Select &#8220;Optional encryption&#8221; from the Data Encryption drop down</li>
<li>Select the &#8220;Allow these protocols&#8221; radio button, and make sure &#8220;Challenge Handshake Authentication Protocol (CHAP)&#8221; is ticked, as well as &#8220;Microsoft CHAP Version 2 (MS-CHAP v2)</li>
<li>hit ok, then ok in the parent window and connect!</li>
</ol>
<p><div id="attachment_232" class="wp-caption alignright" style="width: 624px"><img class="size-full wp-image-232  " title="Vista VPN Error - Fix" src="http://www.shawson.co.uk/codeblog/wp-content/uploads/2009/07/fix.jpg" alt="Vista VPN Error - Fix" width="614" /><p class="wp-caption-text">Vista VPN Error - Fix</p></div></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://codeblog.shawson.co.uk/vpn-problems-with-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

