<?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>CleverWorkarounds &#187; WEBDAV</title>
	<atom:link href="http://www.cleverworkarounds.com/category/infrastructure/webdav/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cleverworkarounds.com</link>
	<description>After much frustration, it seems DEFAULT is the way to go...</description>
	<lastBuildDate>Mon, 07 Jun 2010 10:20:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>SharePoint for Cisco Fanboys (and developers) -Part 3</title>
		<link>http://www.cleverworkarounds.com/2008/01/26/sharepoint-for-cisco-fanboys-and-developers-part-3/</link>
		<comments>http://www.cleverworkarounds.com/2008/01/26/sharepoint-for-cisco-fanboys-and-developers-part-3/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 23:59:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WEBDAV]]></category>

		<guid isPermaLink="false">http://www.cleverworkarounds.com/2008/01/26/sharepoint-for-cisco-fanboys-and-developers-part-3/</guid>
		<description><![CDATA[As I write this series, it is getting less and less about Cisco and more and more about SharePoint. This article is definitely developer centric, but since Cisco guys tend to be interested in the guts of the detail, I decided to keep going . If you read my articles I tend to take the [...]<p class="tags">No Tags</p>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-6551570212921028";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_ui_features = "rc:6";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<p>As I write this series, it is getting less and less about Cisco and more and more about SharePoint. This article is definitely developer centric, but since Cisco guys tend to be interested in the guts of the detail, I decided to keep going <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>If you read my articles I tend to take the piss out of IT role stereotypes just to make it more entertaining reading. Sales guys and IT Managers tend to cop it the most, but I also like to have a dig at the expense of the nerds too. Cisco nerds on the whole are a great bunch, but I have to say, the scariest nerd I have ever met drank Cisco kool-aid in jumbo size!</p>
<p>If you have gotten to this article after reading the first two and you are scoffing at my audacity to suggest you TFTP your configs into SharePoint, chances are most people think you&#8217;re scary! If you are hitting this series of articles for the first time, go back and read <a href="http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/">part 1</a> and <a href="http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/">part 2</a> before being scary!</p>
<p>Seriously now, I thought that this would be a 2 part set of articles, but I got all bogged down in the methods of getting files into SharePoint. The WEBDAV based methods described in the previous article is easy to do, but ultimately is not the recommended method. So now, we will look at the &#8216;proper&#8217; ways to do it and see if they are worth the effort. They work okay, but are more complex and I&#8217;m not convinced that the governance issues are necessarily worth it for many readers.</p>
<p>Degree of difficulty for this article is varied.</p>
<p>CleverWorkArounds Coffee requirement rating (for an application developer): <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image7.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb7.png" width="25" border="0"/></a>&nbsp;</p>
<p>CleverWorkArounds Coffee requirement rating (for a non developer): <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image8.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb8.png" width="25" border="0"/></a>&nbsp; <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image9.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb9.png" width="25" border="0"/></a> <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image10.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb10.png" width="25" border="0"/></a>&nbsp;<a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image8.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb8.png" width="25" border="0"/></a></p>
<p><span id="more-403"></span></p>
<h2>How can we we *not* use WEBDAV?</h2>
<p>If we are using methods other than WEBDAV, then how are our existing applications supposed to work? I mean, all they know is the windows networking API. So, unless the other methods are implemented as a redirector (as described in more detail in the &#8220;WEBDAV Interlude&#8221; section of my <a href="http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/">first article</a>), how can they use any other API?</p>
<p>The answer is, they can&#8217;t! So we are leaving the world of freeware and cheap TFTP servers and writing our own one!</p>
<p>&#8220;What? I&#8217;m no coder&#8221;, you say? That&#8217;s okay, nor am I&#8230; but stick with me anyway. </p>
<p>Okay, how about we modify someone else&#8217;s open source TFTP Server to work with SharePoint via non WEBDAV methods? </p>
<p>Fortunately for us, such a TFTP server does exist. In addition to being conveniently modifiable (got to love open source), it is multithreaded, very well written and easy to understand and extend.&nbsp; Kudos to the author. If you write a few scripts here and there, it should be enough for this article.</p>
<p>So let&#8217;s take a closer look. If you already know visual studio you can skip the next section and move to the section entitled &#8220;Examining the Code&#8221;. Otherwise let&#8217;s keep going getting this TFTP Server compiled!</p>
<h2>Getting TFTPUTIL compiled</h2>
<p>Head on over to <a title="http://sourceforge.net/projects/tftputil" href="http://sourceforge.net/projects/tftputil">http://sourceforge.net/projects/tftputil</a> and <a href="http://sourceforge.net/project/showfiles.php?group_id=154247&amp;package_id=171337&amp;release_id=466365">download</a> the latest release. Crank out Visual Studio 2005 and take a look at it.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image30.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb30.png" width="222" border="0"/></a> </p>
<p>This server is implemented as a class, so you have to write your own little program to make use of this class by creating a TFTP server object. You do by adding a new project to your Visual Studio workspace. But before we do that, how about we deal with a pre-requisite component.</p>
<p>The TFTPUtil class makes use of a library of useful functions called <a href="http://sourceforge.net/projects/nspring">NSpring</a>. You will want to download this. Grab the nspring.dll, and then tell Visual Studio how to find it by choose &#8220;Add Reference&#8221; from the &#8220;Project&#8221; menu, . At the resulting dialog box, go to the &#8220;Browse&#8221; tab and navigate to where you downloaded nspring.dll. (Best to put into C:\WINDOWS\SYSTEM32 or use the same folder where the TFTPutil code lives).</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image31.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="378" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb31.png" width="468" border="0"/></a> </p>
<p>Right, we are all set! You could compile and build TFTPUtil.DLL right now, but it would not do you a lot of good because it&#8217;s a class and does not run on its own. It needs to be *invoked*. This means we need to create a little application that creates an *instance* of the TFTPUtil class. Right click on the project and choose &#8220;Add New project&#8221; as shown below.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image32.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="184" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb32.png" width="244" border="0"/></a> </p>
<p>For our purposes, we create a new &#8220;Console Application&#8221; project and call it myTFTPServer or something meaningful to you. This will be a small EXE file that uses the TFTPUtil class to create a TFTP server.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image33.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="413" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb33.png" width="644" border="0"/></a> </p>
<p>Now, right click on the newly created project and choose &#8220;Set up Startup Project&#8221;</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image34.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="99" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb34.png" width="217" border="0"/></a> </p>
<p>Next step, we need to tell this new console application project how to find the TFTPUtil class. From the Project menu, choose &#8220;Add Reference&#8221;. At the resulting dialog box, go to the &#8220;Project&#8221; tab and you will see the open TFTPUtil project. </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image35.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="124" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb35.png" width="384" border="0"/></a> </p>
<p>Right, that should be it! Your Visual studio should look something similar to this</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image36.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="382" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb36.png" width="217" border="0"/></a> </p>
<h2>Creating a basic TFTP server</h2>
<p>This is a well written TFTP server. Everything is very nicely modular and easy to understand without getting into too much complexity.</p>
<p>So first up, here is the 5 lines of code of your console application to get the TFTP server working. Add this to the code section of the <strong>static void Main(string[] args)</strong> method.</p>
<pre class="csharpcode"><span class="kwrd">using</span> TFTPUtil;

TFTPServer myTFTP = <span class="kwrd">new</span> TFTPServer();
myTFTP.Path= <span class="str">"C:\TEMP"</span>;
myTFTP.AllowWRQ = <span class="kwrd">true</span>;
myTFTP.AllowWRQOverwrite = <span class="kwrd">true</span>;
myTFTP.StartListener(); 
</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Those 5 lines create a new TFTP server object, set the destination folder, allow it to receive files, overwrite received files and start the TFTP server. If you now compile and build this solution you will end up with the files TFTPutil.DLL and myTFTPServer.EXE.</p>
<p>You should be able to test it now. (By default, files will be uploaded to the folder the EXE is run from unless you specify a path).</p>
<h2>Examining the code</h2>
<p>Now let&#8217;s look at the area of the TFTP server where we need to add some code. It is in TFTPServerProcess.css in a method called &#8220;ProcessDataGram&#8221;</p>
<p>If you examine this method, you will see the following code (just search for it):</p>
<pre class="csharpcode" style="width: 656px; height: 93px">AddMsg(Level.Info, <span class="str">"Successfully received file "</span> + State.Filename + <span class="str">" ("</span> + State.Filesize.ToString() + <span class="str">" bytes) from "</span> + State.RemoteIPAddress + <span class="str">" in "</span> + TotalTime.ToString() + <span class="str">" seconds ("</span> + (Rate).ToString() + <span class="str">" bytes/sec)."</span>);
<span class="rem">//This is the last block so go ahead and setup to delete state</span>
State.Close(); </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>We will make some fairly basic modifications to the server in this section, so that the file is uploaded to SharePoint.
</p>
<p>There are several methods that can be used to get files into SharePoint. We will do this first by using the most obvious way: The SharePoint SDK.</p>
<p>&nbsp;</p>
<p><iframe style="border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none" border="0" marginwidth="0" marginheight="0" src="http://rcm.amazon.com/e/cm?t=cleverwo-20&amp;o=1&amp;p=48&amp;l=st1&amp;mode=books&amp;search=sharepoint%20development&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" frameborder="0" width="99%" scrolling="no" height="90"></iframe></p>
<h2>&nbsp;</h2>
<h2>Modification example #1 &#8211; The SharePoint SDK</h2>
<p>The SharePoint SDK is definitely the easiest way to upload a file, but there are several caveats:</p>
<ul>
<li>The TFTP server MUST run on a server that is a member of the SharePoint farm
</li>
<li>The TFTP service account MUST have administrative privileges on the server and SQL access</li>
</ul>
<p>That second requirement in particular just plain sucks. After going to the trouble in part 1 to set up low privileged account &#8220;tftp service&#8221; with &#8220;contribute&#8221; access to a document library, we now find that we need to grant the account significantly more privileges than before. My security nazi Cisco readers will read that and say &#8220;no way will I do that&#8221;, and I would concur. But fortunately for my readers (and unfortunately for me) I only discovered that caveat AFTER I had gotten it working. So I will show you the code changes anyway.</p>
<p>So, first up I will tell you what we will do. The aforementioned ProcessDataGram uses a class called <strong>State</strong> that is used to write the file to the file system. Then later the method Close() closes the file that has been uploaded.</p>
<p>So what we will do, is upload the file to SharePoint just after State.Close(). This means the file is still downloaded to the local file system and then <strong>copied</strong> to SharePoint. Therefore, the local file system is now simply a temporary place for the file to be stored, prior to it be uploaded to SharePoint.</p>
<p>To do this, we will change how TFTPUTIL handles the PATH property. Recall in my basic TFTP console application example code I could set the path via: </p>
<pre class="csharpcode">myTFTP.Path = <span class="str">"C:\TEMP"</span>;</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>So let&#8217;s change this behaviour so that if Path contains the string &#8220;http://&#8221;, we assume it is a SharePoint path, rather than a file system path. Therefore we set the internal file path to %TEMP% so we can still capture the file, but then we will upload it to the http:// specified SharePoint site.</p>
<p>Path is a property of the TFTPUtil class that is defined in TFTPServer.cs. We will make a minor change to the Path property, because it performs a check that will always fail when a SharePoint URL is supplied.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">string</span> Path
{
    get
    {
        <span class="kwrd">return</span> FullPath;
    }
    set
    <strong>{
        <span class="kwrd">if</span> (<span class="kwrd">value</span>.Contains(<span class="str">"http://"</span>)) {
            FullPath = <span class="kwrd">value</span>;
        } <span class="kwrd">else</span>
        {</strong>
        <span class="kwrd">if</span> (System.IO.Directory.Exists(<span class="kwrd">value</span>))
            FullPath = <span class="kwrd">value</span>;
        <strong>}</strong>
    }
} </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Now we turn our attention to the TFTPServerProcess.cs file where we have to modify the TFTPServerProcess class. We will add two more properties to the TFTPServerProcess class. Find the declaration for FullPath and then add the two lines in bold below it.</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">string</span> FullPath = System.IO.Directory.GetCurrentDirectory();
<strong><span class="kwrd">private</span> <span class="kwrd">string</span> TempPath = System.IO.Directory.GetCurrentDirectory();
<span class="kwrd">private</span> <span class="kwrd">bool</span> IsSharePoint = <span class="kwrd">false</span>; // If <span class="kwrd">this</span> <span class="kwrd">is</span> a sharepoint site</strong> </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Also while we are here, add a reference to the SharePoint dll.</p>
<pre class="csharpcode"><span class="kwrd">using</span> Microsoft.SharePoint; </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>You will find the Microsoft.SharePoint.DLL in C:\Program Files\Common Files\Microsoft Shared\web server extensions on most installations.
</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image37.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="262" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb37.png" width="328" border="0"/></a> </p>
<p>Next, we need to add some basic logic to the code where the TFTPServerProcess class is initialised. It is an overloaded class so it is declared twice. To keep it simple, I have added the code to each declaration. If this is a Sharepoint path, it copies the supplied path to a variable called TempPath, and then puts the path of %TEMP% into the FullPath. This is deliberately done so that minimal code changes elsewhere are required (ie the rest of the class expects a variable called FullPath to point to a filesystem, not SharePoint).</p>
<p>Thus, it looks like this (bold):</p>
<p>Declaration 1:</p>
<pre class="csharpcode"><span class="kwrd">public</span> TFTPServerProcess() 

<strong><span class="kwrd">if</span> (FullPath.Contains(<span class="str">"http://"</span>))
{
    IsSharePoint = <span class="kwrd">true</span>;
    TempPath = FullPath;
    FullPath = Path.GetTempPath();
}
</strong>
</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Declaration 2:</p>
<pre class="csharpcode"><span class="kwrd">public</span> TFTPServerProcess(<span class="kwrd">string</span> FilePath,
    Level LoggingLevel,
    Level DisplayLevel,
    <span class="kwrd">bool</span> AllowRRQ,
    <span class="kwrd">bool</span> AllowWRQ,
    <span class="kwrd">bool</span> AllowWRQOverwrite,
    <span class="kwrd">bool</span> AllowTFTPOptions,
    <span class="kwrd">bool</span> CheckReadWriteState,
    <span class="kwrd">int</span> ResendInterval,
    <span class="kwrd">int</span> TimeoutInterval,
    Logger logger,
    IPAddress srvaddr)
{ 

    <strong><span class="kwrd">if</span> (FilePath.Contains(<span class="str">"http://"</span>))
    {
        IsSharePoint = <span class="kwrd">true</span>;
        TempPath = FilePath;
        FullPath = Path.GetTempPath();
    }
    <span class="kwrd">else</span>
    {
        FullPath = FilePath;
    }
</strong>
</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Finally, we add some code just after the State.Close() method as shown earlier. This takes the downloaded file from %TEMP%, uploads it to SharePoint and then deletes the file from %TEMP%.</p>
<pre class="csharpcode">State.Close();
<span class="kwrd">if</span> (IsSharePoint)
{
    <span class="rem">// Now we add this newly downloaded file to the document library</span>
    <span class="kwrd">try</span>
    {
        SPSite DestSite = <span class="kwrd">new</span> SPSite(TempPath);
        SPWeb DestWeb = DestSite.OpenWeb();
        DestWeb.AllowUnsafeUpdates = <span class="kwrd">true</span>;
        SPFileCollection files = DestWeb.Files;
        FileStream destFile = File.OpenRead(FullPath + <span class="str">@"/"</span> + State.Filename);
        <span class="kwrd">string</span> destFileURL = TempPath + <span class="str">"/"</span> + State.Filename;
        Hashtable MetaDataTable = <span class="kwrd">new</span> Hashtable();
        SPFile destSPFile = files.Add(destFileURL, destFile, MetaDataTable, <span class="kwrd">true</span>);
        destFile.Close();
        <span class="rem">// clean up temp file</span>
        File.Delete(FullPath + <span class="str">@"/"</span> + State.Filename);
    }
    <span class="kwrd">catch</span> (Exception ex)
    {
        AddMsg(Level.Verbose, <span class="str">"Problem opening SharePoint site"</span> + TempPath);
        AddMsg(Level.Debug, <span class="str">"Exception: "</span> + ex.Message + <span class="str">"\n"</span> + ex.StackTrace);
    }
}
<span class="rem">//This is the last block so go ahead and setup to delete state</span>
StopListener(); </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Note the HashTable MetaDataTable line. Even though we are not setting any metadata values, I have left in HashTable code because it illustrates how this method allows you to code in the setting of metadata columns in a document library. For example, imagine that the SharePoint document library has a column called &#8220;DeviceType&#8221;. Your code could say, write the string &#8220;Cisco&#8221; or &#8220;Linksys&#8221; to the DeviceType column when the file is uploaded.
</p>
<p>So let&#8217;s try it out shall we?</p>
<p>Modify your console application to fix the path variable to a SharePoint doc library and then build the solution.&nbsp; </p>
<pre class="csharpcode">TFTPServer myTFTP = <span class="kwrd">new</span> TFTPServer();
myTFTP.AllowWRQ = <span class="kwrd">true</span>;
myTFTP.AllowWRQOverwrite = <span class="kwrd">true</span>;
myTFTP.Path = <span class="str">"http://tidemo/tftp/backups"</span>;
myTFTP.StartListener(); </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Test the solution and you get a fairly unexciting console window.
</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image38.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb38.png" width="644" border="0"/></a> </p>
<p>Now we attempt an upload.</p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 put c:\myfile.txt<br />Transfer successful: 43552 bytes in 1 second, 43552 bytes/s </font>
</p>
<p><font face="Courier">[snip it all working swimmingly]</font></p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 put c:\myfile.txt<br />Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image39.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="266" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb39.png" width="644" border="0"/></a> </p>
<p>Also, this time around, none of the locking/access errors <a href="http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/">seen</a> with the WEBDAV based methods &#8211; WOHOO!. Running this as a service also works fine, using the same freeware utility I used in the last post (<a href="http://www.kcmultimedia.com/smaster/">ServiceInstaller</a> ). Just compile the solution and then use ServiceInstaller as I described for TFTPD32 in the <a href="http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/">previous post</a>.</p>
<p>Remember what I said before though, the &#8220;tftp service&#8221; account MUST have the following privileges on the server: </p>
<ul>
<li>The user is a server farm administrator.
</li>
<li>The user has Read and Write permissions on the content database.
</li>
<li>The user is a site collection administrator.
</li>
<li>The user has permissions to access the Windows SharePoint Services site or the SharePoint Server 2007 site through which the code iterates.</li>
</ul>
<p>Read more at KB Article <a href="http://support.microsoft.com/kb/935751">935751</a>, but the fundamental issue is that we are not running this code as the IIS process, but rather a separate user account. <em>&#8220;If code is executed from a custom Windows-based application or from a custom console application, the code path does not use the Web context that is hosted by the Microsoft Internet Information Services (IIS) application pool. Therefore, specific user permissions are required in SharePoint Server 2007 and in the back-end data source&#8221;</em></p>
<h2>Conclusion</h2>
<p>The requirement for administrator level privileges sucks. It is not a showstopper, but it sucks nonetheless. So the next post, we will turn our attention to the Webservices methods of uploading data and see if they are any better. Then (finally!) we will get onto more interesting topics like making use of workflow and integrating it with other useful information.</p>
<p>If you are wondering whether you can download my changes and test for yourself, not yet <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . I&#8217;m going to contact the author of the TFTPUtil project first, and I have to perform more debugging <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . So right now you will have to do it yourself.</p>
<p>Thanks for reading.</p>
<p>Paul</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6551570212921028";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_ui_features = "rc:6";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p class="tags">No Tags</p>]]></content:encoded>
			<wfw:commentRss>http://www.cleverworkarounds.com/2008/01/26/sharepoint-for-cisco-fanboys-and-developers-part-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>SharePoint for Cisco Fanboys (darn WEBDAV) &#8211; Part 2</title>
		<link>http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/</link>
		<comments>http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 15:03:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WEBDAV]]></category>

		<guid isPermaLink="false">http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/</guid>
		<description><![CDATA[Here I am back again, illustrating some of the interesting possibilities that SharePoint offers for Cisco people. To recap my last post, I showed you a little perl script I wrote to get an IOS router or switch to dump its current configuration to a TFTP server. I then used one of several freeware TFTP [...]<p class="tags">No Tags</p>]]></description>
			<content:encoded><![CDATA[<p><!--adsense-->
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image11.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 20px 15px 0px; border-right-width: 0px" height="244" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb11.png" width="76" align="left" border="0"/></a>Here I am back again, illustrating some of the interesting possibilities that SharePoint offers for Cisco people.</p>
<p>To recap my <a href="http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/">last post</a>, I showed you a little perl script I wrote to get an IOS router or switch to dump its current configuration to a TFTP server. I then used one of several freeware TFTP servers to show how you can have a TFTP server save the captured file into a version enabled document library.</p>
<p>I then hit a snag in relation to using a Windows Service to do this task. In this article we will delve into this issue in more detail. In addition, I ended up delving much deeper than I intended. So, like my branding series, this is going to turn into a multi-part series too, covering some application development, configuration, security and governance issues. How many parts it will end up being is anybody&#8217;s guess!</p>
<p>This is a technically oriented series of articles for the most part, so for you people who like the <a href="http://www.cleverworkarounds.com/2007/11/25/learn-to-talk-to-your-cfo-in-their-language-part-2/">governance</a> and <a href="http://www.cleverworkarounds.com/2007/11/17/learn-to-talk-to-your-cfo-in-their-language-part-1/">finance</a> stuff, you may not get too much out of this one. Although this article (part 2) focuses on my issues and observations with the Windows WEBDAV client, if you are one of these people who have &#8216;special&#8217; feelings when you see those pretty blue Cisco boxes like the image above, then you may find some useful content here. <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>SharePoint developers and architects may also find this of interest.</p>
<p><span id="more-382"></span></p>
<p>Now I previously mentioned that I tried three TFTP servers in writing this article and had some problems. They were:</p>
<ul>
<li><a href="http://www.tftp-server.com/">WinAgents TFTP</a> (Commercial)  </li>
<li><a href="http://www.solarwinds.com/products/freetools/free_tftp_server.aspx">SolarWinds TFTP Server</a> (Freeware &#8211; Registration required)  </li>
<li><a href="http://tftpd32.jounin.net/">TFTPD32 TFTP Server</a> (Freeware)</li>
</ul>
<p>And let&#8217;s not forget good old <a href="http://kin.klever.net/pumpkin/">PUMPKIN</a>, just to make one of my CCIE friends, who read the first post and suggested I use it as an alternative, happy (although he forgets that years ago I was the one who told him about Pumpkin in the first place <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )</p>
<p>Let&#8217;s review their capabilities and cover the issues encountered with each. As we go, we will get to see the uglier side of WEBDAV.</p>
<h2>WinAgents TFTP</h2>
<p>I&#8217;ve used this product several times in the past. At the time it was pretty much the only product that would natively run as a Windows service. It is not free, but buying it won&#8217;t exactly break the bank. It has a nice GUI, good logging and the ability to set up virtual folders to different underlying locations. Below is the main configuration screen and the screen where multiple locations can be configured.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image12.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="337" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb12.png" width="404" border="0"/></a> </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image13.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="202" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb13.png" width="397" border="0"/></a> </p>
<p>You would think that the above ability to virtualise folders would make this product an obvious choice for front-ending to SharePoint, because it could co-exist with native filesystem, <a href="http://www.microsoft.com/windowsserver2003/technologies/storage/dfs/default.mspx">DFS</a> and 3rd party SMB based resources like those provided by <a href="http://us1.samba.org/samba/">samba</a>.</p>
<p>You would be right, but the latest version is let down by one stupid design flaw. When you send a file to a WinAgents TFTP server that already exists, it will <strong>delete </strong>the original file and then copy the new file to the virtual folder. It may on the surface seem no different to simply overwriting a file &#8211; but there is a big difference in a SharePoint site. </p>
<p>All files in a SharePoint document library have a unique ID. It is a built-in column and can be made visible by modifying a document library view as shown below.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image14.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="105" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb14.png" width="244" border="0"/></a>&nbsp; <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image15.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="173" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb15.png" width="244" border="0"/></a> </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image16.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="103" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb16.png" width="644" border="0"/></a> </p>
<p>By deleting the file in SharePoint, that file is now put into the recycle bin. When you upload a file of the same name, SharePoint treats it as a <strong>new file</strong> and allocates it a <strong>new ID</strong>. Therefore, there is no version history at all. Each upload is deleting the previous version and uploading a new file.</p>
<p>This obviously blows away any potential to use WinAgents TFTP as a SharePoint integrated TFTP server <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> .</p>
<p><strong>CleverWorkarounds Rating: They probably thought it was a good idea at the time.</strong></p>
<h2>Solarwinds</h2>
<p>So instead, let&#8217;s now turn our attention to the SolarWinds TFTP product. This one is free and also very easy to use. Like the WinAgents product, it can be run as a service out of the box, but it is not as comprehensive as its commercial competitor in terms of logging, granular security filtering and folder virtualisation. </p>
<p>Unlike its commercial cousin, however, it does not delete files before uploading, and therefore plays nice with SharePoint version control. That, combined with natively running as a windows service, makes it the obvious contender to be the SharePoint TFTP server of choice.</p>
<p>The GUI is basic yet functional. There is a status screen and a configuration screen that allows you to set the TFTP Root directory as shown below.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image17.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb17.png" width="484" border="0"/></a>&nbsp;</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image18.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="252" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb18.png" width="354" border="0"/></a> </p>
<p>In the screen-shot above, you will notice that the TFTP Server root directory is <a href="file://\\tidemo\tftp\backups">\\tidemo\tftp\backups</a>. As I explained in the first post, this is the WEBDAV UNC equivalent of the SharePoint site <a href="http://tidemo/tftp">http://tidemo/tftp</a> and the document library called backups.</p>
<p>If you recall in the <a href="http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/">first post</a>, we created a user account called &#8216;tftp service&#8217;. This account has been granted access to the <a href="http://tidemo/tftp/backups">http://tidemo/tftp/backups</a> library. So, we need to set the credentials of the WinAgents TFTP service to run as that user. Therefore, when files are received by TFTP clients, the server will be able to write to the library. Below is my screen capture of my configured TFTP server.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image19.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="395" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb19.png" width="354" border="0"/></a>&nbsp;</p>
<p>There was one other task I also had to do to test this setup. SolarWinds is a little bit naughty in that it logs to its installation folder. (&#8216;tsk &#8216;tsk will never get a designed for XP gold logo). Being good practitioners of IT security, the &#8216;tftp service&#8217; account is a domain user with no system privileges, and only has READ access to this folder by default. Changing configuration parameters (such as the UNC TFTP root) also would not be saved, because the TFTP server would not be able to write to its own configuration file when running as the &#8216;tftp service&#8217; account..</p>
<p>So the permissions of the SolarWinds installation folder has been modified so that the &#8216;tftp service&#8217; account has WRITE access as shown below.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image20.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="319" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb20.png" width="454" border="0"/></a>&nbsp; </p>
<p>So I started the service fine, and ran a test! Wohoo we have our file!!</p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font>  </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image5.png"><img height="145" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb5.png" width="700" border="0"/></a>  </p>
<p>So I tried it again a few times and hit a snag after some successful retries&#8230;  </p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p><font face="Courier">[snip many successful reattempts]</font></p>
<p><font face="Courier">C:\TFTP 192.168.134.129 put myfile.txt<br />Error on server : The process cannot access the file &#8216;\\tidemo\tftp\backups\myfile.txt&#8217; because it is being used by another process.<br />Connect request failed </font> </p>
<p>This was odd. Suddenly I was unable to copy a new version of the file to TFTP. I was running many repeat tests, so perhaps there was some sort of temporary file lock causing a problem? So I waited for a bit and then was able to transfer successfully again as shown below.  </p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p>But it wasn&#8217;t long before I got another and more severe error.  </p>
<p><font face="Courier">C:\TFTP 192.168.134.129 put c:\myfile.txt<br />Error on server : The network path was not found. </font> </p>
<p><font face="Courier">Connect request failed </font> </p>
<p>The TFTP server log showed this error and ominous stack trace&#8230;  </p>
<p><font face="Courier">2008-01-23 21:49:53,102 [6] WARN&nbsp; TFTPServer.Service.TransmissionPut &#8211; Exception caught while trying to open file for reading.<br />System.IO.IOException: The network path was not found. </font> </p>
<p><font face="Courier">&nbsp;&nbsp; at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)<br />&nbsp;&nbsp; at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)<br />&nbsp;&nbsp; at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)<br />&nbsp;&nbsp; at TFTPServer.Service.TransmissionPut.Begin(RequestPacket firstPacket)</font>  </p>
<p>Network path not found? What the hell was going on here? It worked a minute ago!  </p>
<p>Eventlogs came up blank, and I tried an IISRESET. Still no-go. Restarted the TFTP service and I was able to transfer again. However, it didn&#8217;t take long for the problem to re-appear.  </p>
<p>I tried all of the suggestions on Mark Muller&#8217;s <a href="http://blogs.tamtam.nl/mart/SharepointExplorerViewProblems.aspx">blog article</a> with no success.  </p>
<p>I found two sites of interest and one seemed close to this issue. The first was <a href="http://www.codeprof.com/dev-archive/184/328-1203-1847682.shtm">here</a>, where a developer was having the identical problem, and a Microsoft employee suggested not to rely on WEBDAV &#8220;especially when using services&#8221;. The second one was a confidence building quote from Microsoft themselves. They made an admission in their <a href="http://www.microsoft.com/downloads/details.aspx?familyid=c523ac7a-5724-48be-b973-641e805588f4&amp;displaylang=en">WEBDAV Whitepaper</a> regarding the Web Client service. &#8220;The Web Client Service in Windows XP and Windows Server 2003 does not function correctly if you stop it then start it again without restarting the computer. <strong>Although a bug has been opened on this problem, the changes required to fix it are too large for a hotfix or a service pack and have therefore been delayed until a future major release of Windows&#8221;</strong>  </p>
<p>Are you freakin SERIOUS!?!  </p>
<p>Anyway, I decided that before I go off on a Microsoft bashing rant, I&#8217;d better double check that this problem was with SolarWinds TFTP or the obviously rock solid and stable WEBDAV client.  </p>
<p><strong>CleverWorkAround Rating (SolarWinds TFTP) &#8211; Judgement reserved till later</strong><br />
<h2>TFTPD32 TFTP Server</h2>
</p>
<p>TFTPD32 is more than just a TFTP server. It also provides DHCP, Syslog and SNTP services as part of the deal. Unlike the previous two TFTP servers, it does not run as a windows service out of the box, but it can be easily made to.</p>
<p>Cisco have also decided that this is their recommended TFTP server as well, not a bad endorsement, eh!</p>
<p>If we focus on the TFTP server functionality only, it is basically the same as SolarWinds <strong>without</strong> the windows service bit. So WinAgents still wins for overall ease of use and granularity but as discussed it was a waste of time with SharePoint.</p>
<p>Once again there is a main status screen, showing you current activity, as well as a configuration screen where you set the TFTP server root UNC path.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image21.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="294" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb21.png" width="354" border="0"/></a> </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image22.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb22.png" width="343" border="0"/></a>  </p>
<p>So given that we had all of the WEBDAV stability problems with SolarWinds, this TFTP server allows us to test two scenarios. Since it can be run as standalone, we can run it interactively as our &#8216;tftp service&#8217; account and test it. Then, we can use a 3rd party tool to make it run as a Windows Service, and compare notes.  </p>
<p>So first up, let&#8217;s run it interactively as rtftp service&#8217; account. This is achieved by RIGHT clicking on the TFTPD32.EXE file and choosing RUN-AS from the menu options. When prompted, enter the credentials of the &#8216;tftp service&#8217; account.  </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image23.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb23.png" width="244" border="0"/></a>&nbsp; <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image24.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="199" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb24.png" width="244" border="0"/></a>  </p>
<p>If you want absolute assurance that TFTPD32.EXE is being run by the &#8216;tftp user&#8217; then look for the process in &#8220;task manager&#8221; and check the &#8220;User Name&#8221; column.  </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image25.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="272" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb25.png" width="498" border="0"/></a>  </p>
<p>So, here we go!  </p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p><font face="Courier">[snip many successful reattempts]</font></p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p>Now occasionally I received the error below, but unlike when using SolarWinds, running as a windows service using &#8216;ttp service&#8217; user credentials, it would always happen once and subsequent attempts would be fine.  </p>
<p><font face="Courier">C:\TFTP 192.168.134.129 put myfile.txt<br />Error on server : Access violation<br />Connect request failed</font>  </p>
<p>Just to prove that it was much more reliable, we now look at the version history in SharePoint for the file myfile.txt  </p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image26.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="289" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb26.png" width="545" border="0"/></a>  </p>
<p><strong>CleverWorkArounds Rating: Not flawless, but reliable</strong>  </p>
<p>So we have ascertained that running TFTPD32 works pretty well when run interactively as &#8216;tftp service&#8217; . Now we have to run TFTPD32 as a service and compare <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
<h3></h3>
<h2>TFTPD32 as a windows service</h2>
</p>
<p>There are many utilities out there to run a regular EXE file as a Windows Service. One of the most popular ones is SVRANY from the Windows 200x resource kit. However I used the freeware <a href="http://www.kcmultimedia.com/smaster/">ServiceInstaller</a> because it had a nice GUI <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Using it is mind numbingly simple. Run the application and fill in the form as shown below and click the &#8216;Install&#8217; button. Once installed, you can then change the service credentials to &#8216;tftp service&#8217; the same way we did it for SolarWinds.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image27.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="224" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb27.png" width="244" border="0"/></a> <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image28.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="152" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb28.png" width="304" border="0"/></a></p>
<p>Start the service, and check in Task manager that TFTPD32.EXE is running. (When running as a service you will not see the status screen).</p>
<h2>The moment of Truth!</h2>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p><font face="Courier">[snip many successful reattempts]</font></p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font>  </p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p>Like when running interactively, I still received the occasional&nbsp; &#8216;Access Violation&#8217; error but always recovered. Again to prove that I ran lots of TFTP commands, the version history is now up to 204 <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image29.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="234" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb29.png" width="483" border="0"/></a>  </p>
<p><strong>CleverWorkArounds Ratings (TFTPD32 as a service) &#8211; The best of the WEBDAV TFTP bunch</strong>  </p>
<p><strong>CleverWorkArounds Ratings (SolarWInds) &#8211; Looks like it might be part your fault after all!</strong>  </p>
<p><strong>CleverWorkArounds Ratings (WEBDAV) &#8211; It&#8217;s definitely your fault!</strong>  </p>
<p><strong></strong>&nbsp;<br />
<h2>Conclusion</h2>
</p>
<p>So after these tests, it seems that running TFTPD32 as a Windows Service is no less reliable than running it interactively. Perhaps then there is an issue with the way that SolarWinds use the windows networking API&#8217;s to write files. SolarWinds is a .NET application and TFTPD32 isn&#8217;t. Therefore, they may well be using different API&#8217;s under the hood.</p>
<p>I wasn&#8217;t satisfied with all of this though. Although we have achieved our goal of TFTP to a version controlled document library, the whole unreliable WEBDAV thing left me with a bad taste and I decided to go down a different path. What more could I do, you ask? How about write my own TFTP server? <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>The <a href="http://www.cleverworkarounds.com/2008/01/26/sharepoint-for-cisco-fanboys-and-developers-part-3/">next</a> 2 posts in this series will cover getting TFTP files into SharePoint via *non* WEBDAV methods. We will examine their reliability and examine a little of SharePoint web services and the SDK. </p>
<p>The fifth article will leave the issues of getting the files *into* SharePoint, and instead focus on what we can do with them once they are there! (Workflows, metadata and the like). </p>
<p>The final article (I suspect it will be the final anyway but i won&#8217;t know &#8217;til I write the next two), will tie it all together in terms of governance. Thus, it will be a little similar to the branding series where the last article was largely non technical in focus and audience.</p>
<p>I hope you&#8217;ve enjoyed this little journey and didn&#8217;t find it too pointless <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p><!--adsense--></p>
<p class="tags">No Tags</p>]]></content:encoded>
			<wfw:commentRss>http://www.cleverworkarounds.com/2008/01/24/sharepoint-for-cisco-fanboys-darn-webdav-part-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SharePoint for Cisco Fanboys &#8211; Part 1</title>
		<link>http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/</link>
		<comments>http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 00:15:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Collaboration]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WEBDAV]]></category>

		<guid isPermaLink="false">http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/</guid>
		<description><![CDATA[Cisco nerds! This series is just for you! I know that you think you&#8217;re way too cool for collaborative portals, especially a Microsoft one at that. Instead you are more interested in delving into the IOS command line, to perform arcane arts such as debugging that OSPF route redistribution into BGP or getting off on [...]<p class="tags">No Tags</p>]]></description>
			<content:encoded><![CDATA[<p><iframe style="border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none" border="0" marginwidth="0" marginheight="0" src="http://rcm.amazon.com/e/cm?t=cleverwo-20&amp;o=1&amp;p=13&amp;l=st1&amp;mode=books&amp;search=cisco&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" frameborder="0" width="468" scrolling="no" height="60"></iframe></p>
<p>Cisco nerds! This series is just for you! I know that you think you&#8217;re way too cool for collaborative portals, especially a Microsoft one at that. Instead you are more interested in delving into the IOS command line, to perform arcane arts such as debugging that <a href="http://en.wikipedia.org/wiki/Open_Shortest_Path_First">OSPF</a> route redistribution into <a href="http://en.wikipedia.org/wiki/Border_gateway_protocol">BGP</a> or getting off on planning and implementing a large scale <a href="http://en.wikipedia.org/wiki/Dmvpn">DMVPN</a> solution. Maybe you&#8217;re into <a href="http://en.wikipedia.org/wiki/Quality_of_service">QOS</a> and VOIP and simply dig all of those <a href="http://en.wikipedia.org/wiki/Differentiated_services">DSCP-COS</a> mappings, class and policy maps and the like.</p>
<p>Although packets, cells and frames are your world, *nix is cool, <a href="http://www.nagios.org/">Nagios</a> is your idea of a portal and anything remotely connected to Microsoft fills you with contempt and is beneath you right? <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Well if this is you, I do understand your point of view because I was you once, but after some therapy, I&#8217;m now out of rehab and doing just fine!</p>
<p>Having Cisco/general networking expertise will help you with this article, so depending on who you are, the amount of caffeine required to follow this will vary:</p>
<p>CleverWorkArounds Coffee requirement rating (for a CCNP or CCIE): <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image7.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb7.png" width="25" border="0"/></a>&nbsp;</p>
<p>CleverWorkArounds Coffee requirement rating (for a non Cisco person or CCNA <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ): <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image8.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb8.png" width="25" border="0"/></a>&nbsp; <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image9.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb9.png" width="25" border="0"/></a> <a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image10.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="25" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb10.png" width="25" border="0"/></a></p>
</p>
<p><span id="more-335"></span></p>
<p>Okay Cisco gurus, if there is anything about SharePoint that you guys need to know about, it is the power of the document library.</p>
<p>Unlike a regular file system, a SharePoint document library has a powerful version control mechanism that can make your life easier, as well as play nice with the rest of your colleagues (whom you despise because they don&#8217;t understand or appreciate you <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>So I am first going to show you an example of how you can leverage SharePoint to do something quite useful with Cisco gear, and then in the next post of this series I will expand further into general IT infrastructure admin benefits.</p>
<h2>The Cisco bit..</h2>
<p>(Non Cisco people, your eyes will glaze over &#8211; but try anyway!)</p>
<p>Back around 2000/2001 when I was a full time network manager, I wrote a perl script that used <a href="http://en.wikipedia.org/wiki/SNMP">SNMP</a> to instruct a router to dump its configuration to a TFTP server. I had a <a href="http://en.wikipedia.org/wiki/Cron">cron</a> job that ran this script daily, and it would tell all of our switches and routers to write their current configuration to TFTP. It was nothing special &#8211; many Cisco network professionals do the same thing.</p>
<p>(Before you ask, I *know* there are tools and new methods to do this nowadays, but back then the choices were more limited)</p>
<p>Anyway, here is a snippet of the script in question. I know it&#8217;s not great but it did the job&#8230;</p>
<p><font face="Courier">use Net::SNMP; </font></p>
<p><font face="Courier">($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;<br />@Days = (&#8220;Sunday&#8221;, &#8220;Monday&#8221;, &#8220;Tuesday&#8221;, &#8220;Wednesday&#8221;, &#8220;Thursday&#8221;, &#8220;Friday&#8221;, &#8220;Saturday&#8221;);<br />$day = $Days[$wday];</font></p>
<p><font face="Courier"># Now call the procedure to do the deed!<br />&amp;backup_configs(&#8220;192.168.16.1&#8243;,&#8221;RWSNMPcommunity&#8221;);<br />&amp;backup_configs(&#8220;192.168.16.2&#8243;,&#8221;RWSNMPcommunity&#8221;);</font></p>
<p>The above code simply grabbed the date and then called the main function, passing the IP of the router and the SNMP community string for Read/Write access. The routine below, used SNMP SET commands to tell the router the location of the TFTP server, the name of the configuration file being written, and then told the device to execute the request.</p>
<p><font face="Courier">sub backup_configs {<br />&nbsp;&nbsp;&nbsp; ($ipaddr, $cs) = @_;<br />&nbsp;&nbsp;&nbsp; ($s, $error) = Net::SNMP-&gt;session( -hostname&nbsp; =&gt; $ipaddr,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -community =&gt; $cs,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -debug =&gt; &#8217;1&#8242; ); </font></p>
<p><font face="Courier">&nbsp;&nbsp;&nbsp; $hnh = $s-&gt;get_request(&#8220;.1.3.6.1.2.1.1.5.0&#8243;);<br />&nbsp;&nbsp;&nbsp; $hostname = $hnh-&gt;{&#8220;.1.3.6.1.2.1.1.5.0&#8243;}; </font></p>
<p><font face="Courier">&nbsp;&nbsp;&nbsp; $filename = &#8220;\\router-configs\\&#8221; . $day . &#8220;\\&#8221; . $hostname . &#8220;.cfg&#8221;;<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.2.667&#8243;, INTEGER, 1);<br />&nbsp;&nbsp;&nbsp; # Set the source to startup-config<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.3.667&#8243;, INTEGER, 4);<br />&nbsp;&nbsp;&nbsp; # Set the destination to tftp<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.4.667&#8243;, INTEGER, 1);<br />&nbsp;&nbsp;&nbsp; # Set TFTP IP Address<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.5.667&#8243;, IPADDRESS,&#8221;192.168.18.5&#8243;);<br />&nbsp;&nbsp;&nbsp; # Set destination file name<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1x.1.6.667&#8243;, OCTET_STRING,&#8221;$filename&#8221;);<br />&nbsp;&nbsp;&nbsp; # Set it off!<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.14.667&#8243;, INTEGER, 1);<br />&nbsp;&nbsp;&nbsp; $done = false;<br />&nbsp;&nbsp;&nbsp; $counter = 0;<br />&nbsp;&nbsp;&nbsp; while ($done eq false) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $check = $s-&gt;get_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.10.667&#8243;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($check-&gt;{&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.10.667&#8243;} == 3) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $done = true;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $counter++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($counter &gt; 500) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $done = true;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; if ($counter &gt; 500) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &#8220;$date:A problem occured &#8211; it looks like the attempt failed\n&#8221;;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; # Clear the config!\n&#8221;;<br />&nbsp;&nbsp;&nbsp; $s-&gt;set_request(&#8220;.1.3.6.1.4.1.9.9.96.1.1.1.1.14.667&#8243;, INTEGER, 6);<br />&nbsp;&nbsp;&nbsp; #close the snmp session<br />&nbsp;&nbsp;&nbsp; $s-&gt;close; </font></p>
<p><font face="Courier">}</font></p>
<p>Now, I know there is a lot of ugly SNMP stuff in my above code and many readers are thinking, WTF!? You can safely ignore most of the code. However there is one bit that I do want to bring your attention to.</p>
<p><font face="Courier">&nbsp;&nbsp;&nbsp; $hostname = $hnh-&gt;{&#8220;.1.3.6.1.2.1.1.5.0&#8243;}; </font></p>
<p><font face="Courier">&nbsp;&nbsp;&nbsp; $filename = &#8220;\\router-configs\\&#8221; . $day . &#8220;\\&#8221; . $hostname . &#8220;.cfg&#8221;;<br /></font></p>
<h6><font face="Courier"></font></h6>
<p>Looking closely at this, you can see that I am setting the filename based around the name of the Cisco device (retrieved from SNMP) and the day of the week the script is run ($day). This is because when I backed up the configuration of the router, I wanted to keep multiple versions. For simplicity, I opted to keep 7 days worth of configuration dumps. So by using the day of the week in the file path, I ended up with config backups like this.</p>
<ul>
<li>router-configs/monday/mycorerouter.cfg  </li>
<li>router-configs/monday/myedgerouter.cfg  </li>
<li>router-configs/tuesday/mycorerouter.cfg  </li>
<li>router-configs/tuesday/myedgerouter.cfg </li>
</ul>
<p>So, provided the path router-configs/&lt;day of the week&gt; exists on my TFTP box, I end up with a single file for each cisco device in each day of the week directory.</p>
<p>Neat, eh?</p>
<p>&nbsp;</p>
<h2>Yeah it&#8217;s neat, so why integrate TFTP with SharePoint?</h2>
<p>Version control and workflow, my skeptical Cisco friends, that&#8217;s why! The easiest way to explain is to dive right into an example. So let&#8217;s do that right now!</p>
<p>There are a few TFTP servers out there for Windows (yeah we are using Windows &#8211; get over it). I <strong>used</strong> to use <a href="http://www.tftp-server.com/">WinAgents</a> TFTP server. Unfortunately though in writing this article, the most recent version of WinAgents TFTP does not work with SharePoint the way I want it to (if you run an older version it is fine). I also tried using <a href="http://www.solarwinds.com/products/freetools/free_tftp_server.aspx">SolarWinds</a> freeware (registration required) TFTP server as it runs as a windows service. Unfortunately, I had some stability problems with WEBDAV when running as a service (not SolarWinds fault) which I will explain in the next post, so I ended up using <a href="http://tftpd32.jounin.net/">TFTPD32</a> with a few modifications. (TFTPD32 is <a href="http://www.cisco.com/en/US/products/hw/routers/ps133/products_tech_note09186a00801f7735.shtml">recommended by Cisco</a> anyway).</p>
<p>What we will do is the relatively simple process of telling the TFTP server to drop files into a SharePoint document library via WEBDAV.</p>
<p><em>For reference, the TFTP server does not have to be on the same server as SharePoint when using the WEBDAV method. </em></p>
<p>The TFTPD32 Server Installation is straightforward. Once installed however, there are three additional steps that you need to perform:</p>
<ul>
<li>Create or nominate a user account to run the TFTP Service.  </li>
<li>Modify TFTP32 to run as a WIndows Service &#8211; using the credentials of a user account that has permissions to the document library that the TFTP server will dump the files to.  </li>
<li>Set the TFTP root directory to the UNC path of the SharePoint document library </li>
</ul>
<p>I am assuming that you already have a SharePoint or WSS server. On the SharePoint side, we need to create a site and a document library to hold our configuration backups, grant the TFTP server permission to it and then enable version control on that document library.</p>
<p>So in my example, the user account that is going to upload files to SharePoint is called &#8220;<strong>tftp service</strong>&#8220;. I will refer to this account frequently in the rest of this post.</p>
<p>Also in this example, the SharePoint site is <strong>http://tidemo/tftp</strong> and the document library is called &#8220;<strong>backups</strong>&#8220;</p>
<p><strong><a href="http://tidemo/tftp/backups">http://tidemo/tftp/backups</a></strong></p>
<p><strong></strong>&nbsp;</p>
<h2>Configuring SharePoint</h2>
<p>&nbsp;</p>
<p>(SharePoint people, I am covering the basics here &#8211; skip if you know it already).</p>
<p>In SharePoint, create a new, blank site to host the TFTP server files. Being a bastion of originality, in the example below I have named the site TFTP.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image0025.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="351" alt="clip_image002[5]" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image0025-thumb.jpg" width="351" border="0"/></a></p>
<p>&nbsp;</p>
<p>Now that the site has been created, we create a document library to store the files for the TFTP server. I have called it &#8220;Backups&#8221; and chosen not to use a default document template.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image0027.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="410" alt="clip_image002[7]" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image0027-thumb.jpg" width="355" border="0"/></a></p>
<p>&nbsp;</p>
<p>The next step, having created this document library, is to turn on version control. This is performed by choosing &#8220;document library settings&#8221; from the &#8220;Actions&#8221; menu.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image0029.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="124" alt="clip_image002[9]" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image0029-thumb.jpg" width="244" border="0"/></a><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image00211.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="125" alt="clip_image002[11]" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image00211-thumb.jpg" width="360" border="0"/></a></p>
<p>&nbsp;</p>
<p>In the version settings screen, choose to create major versions.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image00213.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="241" alt="clip_image002[13]" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image00213-thumb.jpg" width="367" border="0"/></a></p>
<p>&nbsp;</p>
<p>Finally, we need to grant our user &#8220;tftp service&#8221; write access to this new document library. The simplest way to do this is add &#8220;tftp service&#8221; to the members&#8217; group of the SharePoint site. This will grant them &#8216;contribute&#8217; access to the &#8220;Backups&#8221; document library. (This permission setting is just for demonstration purposes. Adjust permissions according to your specific requirements)</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="178" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb2.png" width="387" border="0"/></a>&nbsp;</p>
<p>&nbsp;</p>
<p>Right! Our doc library is ready! If at this point you open the document library via Windows Explorer as shown below, you will see that the UNC equivalent path for this example document library is <a href="file://\\TIDEMO\TFTP\BACKUPS">\\TIDEMO\TFTP\BACKUPS</a></p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image00215.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="151" alt="clip_image002[15]" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image00215-thumb.jpg" width="244" border="0"/></a></p>
<p>&nbsp;</p>
<p>If you do not see your standard windows explorer window here and a UNC path, stop here! We need to troubleshoot the windows WEBDAV service. It might pay for you to skip to the &#8220;WEBDAV interlude section coming up)</p>
<p>One thing that people often overlook with SharePoint is that document libraries have this &#8220;windows explorer&#8221; view. What is so significant about this, you ask? It is the fact that you can reach <strong>any </strong>SharePoint document library via a UNC path. You can even map a drive to a SharePoint library too. Thus the following document library:</p>
<p><strong>http://tidemo/tftp/backups</strong></p>
<p>is accessible via</p>
<p><strong>\\tidemo\tftp\backups</strong></p>
<p>As a result of this functionality, pretty much any application that deals with UNC and mapped drives (such as ROBOCOPY) can happily copy files from your PC to a SharePoint library (with a large caveat I will explain later).</p>
<p>For educational purposes, let&#8217;s look at how windows explorer view is done. (If you are not interested, skip to the next heading where we configure SolarWinds TFTP.)</p>
<h2>How is this done? A WEBDAV interlude</h2>
<p>Now SharePoint does not actually provide support for <a href="http://en.wikipedia.org/wiki/Server_message_block">SMB</a> which is what &#8216;regular&#8217; shared file systems use. The protocol that SharePoint supports is <a href="http://www.webdav.org/specs/rfc4918.html">WEBDAV</a> which stands for &#8220;Web-based Distributed Authoring and Versioning&#8221;. So, how is it that we can use Windows explorer, mapped drives and UNC paths to get to SharePoint files?</p>
<p>In Windows XP and above, Microsoft supplied a new network provider called the Windows WebDav client. (Yes, XP and above &#8211; Windows 2000 is not going to work this way for you). <em>Also, Samba people who are reading this and thinking &#8220;ooh I can use smbfs to mount a SharePoint library to *nix&#8221;, sorry it ain&#8217;t gonna work because it is not SMB.</em></p>
<p>By creating the Web Client Service as one of the built-in network providers, it is automatically queried whenever you make connection attempt to a network resource (i.e. opening Windows explorer and navigating to a mapped drive or UNC path). You can see the provider by following these steps:</p>
<ul>
<li>On the <b>Start</b> menu, right-click <b>My Network Places</b> and then click <b>Properties</b>.  </li>
<li>On the top menu bar, click <b>Advanced</b> and then click <b>Advanced Settings</b>.  </li>
<li>Click the <b>Provider Order</b> tab. </li>
</ul>
<p>You will see a dialog box with your provider order listed. Note that the Web Client Network (WebDAV) is last in the list by default.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image002.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="459" alt="clip_image002" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/clip-image002-thumb.jpg" width="408" border="0"/></a></p>
<p>&nbsp;</p>
<p>Microsoft have a detailed <a href="http://www.microsoft.com/downloads/thankyou.aspx?familyId=c523ac7a-5724-48be-b973-641e805588f4&amp;displayLang=en">whitepaper</a> on how Windows Explorer view is implemented, and it is well worth a read. (I&#8217;ve previously <a href="http://www.cleverworkarounds.com/2007/10/15/poor-windows-explorer-view-performance-in-sharepoint/">blogged</a> on quirks with it before.)</p>
<p>&nbsp;</p>
<h2>TFTP to SharePoint</h2>
<p>So, now we know that on XP and above, any application that uses the windows networking API (interpret that as refer to a mapped drive or UNC path), can get data into and out of SharePoint. So let&#8217;s run the TFTPD32 and set it to use our document library.</p>
<p>&nbsp;</p>
<h3>Configuring TFTPD32</h3>
<p>First up, grab TFTP32 and install it onto your chosen server. After successful installation run TFTP32.EXE from the installation directory.</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image3.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="341" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb3.png" width="405" border="0"/></a></p>
<p>&nbsp;</p>
<p>Click OPTIONS and now set the path to the Windows explorer view path (UNC) of your site and document library</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image4.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="110" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb4.png" width="368" border="0"/></a></p>
<p>&nbsp;</p>
<p>That is pretty much it! Now let&#8217;s test it!</p>
<p>Unfortunately, I don&#8217;t have any spare Cisco gear handy as Uncle Ebay helped me dispose of them once I stopped doing networking. So instead, I will use the built in TFTP.EXE utility built into Windows. This proves that a file can be saved to SharePoint via TFTP.</p>
<p>It works like this.</p>
<p>TFTP &lt;hostname or IP&gt; GET|PUT &lt;filename&gt;</p>
<p>eg</p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font></p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p>&nbsp;</p>
<p>The output of the above command shows &#8220;transfer successful&#8221;. So let&#8217;s go and have a peek in our document library!</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image5.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="161" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb5.png" width="775" border="0"/></a></p>
<p>Sweeeet, we have a file called &#8220;myfile&#8221;.</p>
<p>So let&#8217;s go back to TFTP and re-run the command a few times.</p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font></p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p><font face="Courier">[snip many re-executes]</font></p>
<p><font face="Courier">C:\&gt;TFTP 192.168.134.129 PUT myfile.txt</font></p>
<p><font face="Courier">Transfer successful: 43552 bytes in 1 second, 43552 bytes/s</font></p>
<p>&nbsp;</p>
<p>Now let&#8217;s take another gander in the document library. Still the one file there. However, let&#8217;s now examine the version history for the file and see if there are multiple versions?</p>
<p><a href="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image6.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="307" alt="image" src="http://www.cleverworkarounds.com/wp-content/uploads/2008/01/image-thumb6.png" width="614" border="0"/></a></p>
<p>Sweeet, we now see that there are 7 versions stored for this file!</p>
<p>&nbsp;</p>
<h2>Conclusion (and the catch&#8230;)</h2>
<p>So imagine that every day, you use the perl script example above to instruct your networking gear to copy their configuration to TFTP. Now you can simply use a standard file name convention (such as &lt;hostname&gt;-config.txt) do not need to worry about folder structure or dates within filename to ensure that multiple versions are maintained. You can go into the version history for a particular router configuration file and retrieve the one that you need.</p>
<p>Of course, all of your other important documents such as your network diagrams, SOE documentation, maintenance and support agreement details can also be placed into SharePoint document libraries and many other benefits are derived in addition to version history, such as search, workflow and easy offline storage.</p>
<p>But that is for the next post <img src='http://www.cleverworkarounds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Now for the catch &#8230; and it&#8217;s a biggie!</p>
<p>We of course, want to run our TFTP server as a windows service, so that the TFTP server does not have to be manually invoked.</p>
<p>Try as I might, I was unable to get a reliable TFTP service writing to SharePoint document library, when the TFTP server is running as a Windows Service! This majorly sucked and I was an unhappy camper!!</p>
<p>I have concluded that the WEBDAV client in WIn2003 is flakey. In the next post of this series, I will outline the problems that I had and how I eventually was able to come up with a semi-clever workaround to make it all work.</p>
<p>Bye for now!</p>
<p>Paul</p>
<p class="tags">No Tags</p>]]></content:encoded>
			<wfw:commentRss>http://www.cleverworkarounds.com/2008/01/21/sharepoint-for-cisco-fanboys-part-1/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
