<?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>Musings of a technophile &#187; Server Administration</title>
	<atom:link href="http://www.omegaprojex.com/index.php/tag/server-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.omegaprojex.com</link>
	<description>Just another blog from a computer nerd</description>
	<lastBuildDate>Mon, 19 Jul 2010 15:39:20 +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>How to install Nagios NRPE on Ubuntu</title>
		<link>http://www.omegaprojex.com/index.php/2010/05/27/how-to-install-nagios-nrpe-on-ubuntu/</link>
		<comments>http://www.omegaprojex.com/index.php/2010/05/27/how-to-install-nagios-nrpe-on-ubuntu/#comments</comments>
		<pubDate>Thu, 27 May 2010 20:10:46 +0000</pubDate>
		<dc:creator>ElementZero</dc:creator>
				<category><![CDATA[Computer Troubleshooting]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Server Administration]]></category>

		<guid isPermaLink="false">http://www.omegaprojex.com/?p=709</guid>
		<description><![CDATA[First, you need to install the nagios-nrpe-server. There is a nagios-nrpe-plugin but that&#8217;s not what you need because that is just the plugin and you need this daemon (Linux equivalent of a Windows Service for all you Windows guys). sudo apt-get install nagios-nrpe-server next, we should check and make sure that the service is actually [...]]]></description>
			<content:encoded><![CDATA[<p>First, you need to install the nagios-nrpe-server.  There is a nagios-nrpe-plugin but that&#8217;s not what you need because that is just the plugin and you need this daemon (Linux equivalent of a Windows Service for all you Windows guys).</p>
<p><code>sudo apt-get install nagios-nrpe-server</code></p>
<p>next, we should check and make sure that the service is actually running.  We can do this two ways<br />
<code>sudo ps -Al | grep nrpe</code></p>
<p>This will show a line where the process is started.  If it just comes back without stating anything something is wrong. Another check is to make sure you machine is listening on the nrpe port</p>
<p><code>netstat -an | grep 5666</code></p>
<p>Next, we need to set up the Nagios server to be able to check our machine.</p>
<p><code>sudo nano /etc/nagios/nrpe.cfg</code></p>
<p>and change</p>
<p><code>allowed_hosts=127.0.0.1</code></p>
<p>to</p>
<p><code>allowed_hosts=127.0.0.1,x.x.x.x</code></p>
<p>where &#8220;x.x.x.x&#8221; is the ip address of your nagios server.  Now restart the nrep daemon so it reloads the settings</p>
<p><code>sudo /etc/init.d/nagios-nrpe-server restart</code></p>
<p>Now go on the Nagios server and run the following command</p>
<p><code>/usr/local/nagios/libexec/check_nrpe -H y.y.y.y</code></p>
<p>where &#8220;y.y.y.y&#8221; is the ip address of the machine you just installed nrpe on.  If it works it will respond with the version of NRPE you just installed on the machine.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omegaprojex.com/index.php/2010/05/27/how-to-install-nagios-nrpe-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uninstalling Symantec Endpoint Protection from a corporate network</title>
		<link>http://www.omegaprojex.com/index.php/2009/03/19/uninstalling-symantec-endpoint-protection-from-a-corporate-network/</link>
		<comments>http://www.omegaprojex.com/index.php/2009/03/19/uninstalling-symantec-endpoint-protection-from-a-corporate-network/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 15:13:56 +0000</pubDate>
		<dc:creator>ElementZero</dc:creator>
				<category><![CDATA[Computer Troubleshooting]]></category>
		<category><![CDATA[Server Administration]]></category>

		<guid isPermaLink="false">http://www.omegaprojex.com/?p=570</guid>
		<description><![CDATA[My company is getting rid of Symantec Anti-virus. The final kick in the shins was the new software they brought out called &#8220;Symantec Endpoint Protection&#8221;. I&#8217;m not exactly sure what Symantec was thinking when they brought out this product, but the old Symantec Corporate Server was much easier to administer. The new product just seems [...]]]></description>
			<content:encoded><![CDATA[<p>My company is getting rid of Symantec Anti-virus.  The final kick in the shins was the new software they brought out called &#8220;Symantec Endpoint Protection&#8221;.  I&#8217;m not exactly sure what Symantec was thinking when they brought out this product, but the old Symantec Corporate Server was much easier to administer.  The new product just seems to go out of your way to make itself difficult &#8211; from installing to reviewing what sort of viruses are found.  Anyways, couple that with the 92% virus detection rate that Symantec supposedly has, and you wind up with one heck of a crappy product.</p>
<p>After some research, I found that there is basically two products that are currently the best for Anti-virus: NOD32, and Kaspersky.  The are VERY similar &#8211; both have something like a 99.8% detection rate, and both leave a very small footprint.  Supposedly NOD32 is just a bit less overhead than Kaspersky, but the latter is easier to administer.  Seeing that I would rather be able to tell what my anti-virus program is doing in a corporate environment that get a marginal 1% increase in performance, we went with Kaspersky.  Let me say that I don&#8217;t regret it one bit as it has already detected over 100 viruses, trojans, and other spyware that Symantec apparently had let slip by.</p>
<p>In any case, the uninstallation of Symantec was quite a chore.  I found a few articles on how to remove it using some Symantec tools &#8211; but the tools (just like the Antivirus product) were either not present or didn&#8217;t function properly.  Next I found an article on how to manually remove Symantec by running the uninstall wizard from a command prompt.  After reviewing how this worked for a bit, I wrote a short vb script that basically finds the registry key for the Symantec Endpoint Protection, and then issues the command to uninstall the program.  It also leaves entries into the Application event log on what the script is currently doing.  </p>
<p>Be aware that as soon as the uninstall is completed, the computer will reboot (it took about 2-3 minutes on average for the uninstall to complete). Note also that sometimes the script can say that it failed to remove the program, I think that just happens because the computer reboots before it can send the &#8220;ok&#8221; back to the uninstall script (Basically as long as the shield is gone, it&#8217;s removed).  </p>
<p>Once you have the script, you simply set it up to run as a script to run through Group Policy.  Create a new Group Policy and then do Computer Configuration&#8211;>Windows Settings&#8211;>Scripts&#8211;>Startup.  Then just add the script.  This will make the uninstallation of Symantec occur the next time the computers under that Group Policy are started up.  You probably should send an email to those users though and inform them that you are removing Symantec and that upon the next reboot of their computer it wil automatically reboot again after two to three minutes of starting up (again, since the Symantec reboots the machine after it is uninstalled).</p>
<p>One last note &#8211; make sure you remove the uninstall password from the program, otherwise the uninstall script will fail to uninstall the program.</p>
<p>Anyways, hopefully this can help someone else &#8211; I found it rather useful myself.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span>
&nbsp;
<span style="color: #000080;">const</span> HKEY_LOCAL_MACHINE = &amp;H80000002
&nbsp;
<span style="color: #000080;">dim</span> ProductName, ProductKey
&nbsp;
<span style="color: #008000;">'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color: #000080;">sub</span> GetSymantecProductKey()
&nbsp;
<span style="color: #000080;">dim</span> oReg, sPath, aKeys, sName, sKey
<span style="color: #000080;">Set</span> oReg = GetObject(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv&quot;</span>)
&nbsp;
sPath = <span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall&quot;</span>
oReg.EnumKey HKEY_LOCAL_MACHINE, sPath, aKeys
&nbsp;
<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> sKey <span style="color: #000080;">in</span> aKeys
	oReg.GetStringValue HKEY_LOCAL_MACHINE, sPath &amp; <span style="color: #800000;">&quot;\&quot;</span> &amp; sKey, <span style="color: #800000;">&quot;DisplayName&quot;</span>, sName
	<span style="color: #000080;">If</span> <span style="color: #000080;">Not</span> IsNull(sName) <span style="color: #000080;">Then</span> 
		<span style="color: #000080;">if</span> (sName = <span style="color: #800000;">&quot;Symantec Endpoint Protection&quot;</span>) <span style="color: #000080;">then</span>
			ProductKey = sKey
			ProductName = sName
		<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
	<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
<span style="color: #000080;">Next</span>
&nbsp;
<span style="color: #000080;">end</span> <span style="color: #000080;">sub</span>
&nbsp;
<span style="color: #008000;">'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color: #000080;">sub</span> RemoveSymantec(key, name)
&nbsp;
<span style="color: #000080;">dim</span> cmd, objShell, iReturn
cmd = <span style="color: #800000;">&quot;C:\windows\system32\msiexec.exe /q/x &quot;</span> &amp; key
&nbsp;
<span style="color: #000080;">set</span> objShell = wscript.createObject(<span style="color: #800000;">&quot;wscript.shell&quot;</span>)
&nbsp;
objShell.LogEvent 0, <span style="color: #800000;">&quot;Removing the program [&quot;</span> &amp; name &amp; <span style="color: #800000;">&quot;] under Product Key [&quot;</span> &amp; key &amp; <span style="color: #800000;">&quot;]&quot;</span> &amp; vbCrLf &amp; <span style="color: #800000;">&quot;Executing command: &quot;</span> &amp; vbCrLf &amp; cmd
&nbsp;
iReturn=objShell.Run(cmd,1,<span style="color: #000080;">TRUE</span>)
&nbsp;
<span style="color: #000080;">if</span> (iReturn = 0) <span style="color: #000080;">then</span>
	objShell.LogEvent 0, <span style="color: #800000;">&quot;Program [&quot;</span> &amp; name &amp; <span style="color: #800000;">&quot;] was successfully removed&quot;</span>
<span style="color: #000080;">else</span>
	objShell.LogEvent 0, <span style="color: #800000;">&quot;Failed to remove the program [&quot;</span> &amp; name &amp; <span style="color: #800000;">&quot;].&quot;</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
<span style="color: #000080;">Set</span> objShell = <span style="color: #000080;">Nothing</span>  
&nbsp;
<span style="color: #000080;">end</span> <span style="color: #000080;">sub</span>
<span style="color: #008000;">'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span>
ProductKey = <span style="color: #800000;">&quot;&quot;</span>
ProductName = <span style="color: #800000;">&quot;&quot;</span>
&nbsp;
<span style="color: #000080;">call</span> GetSymantecProductKey()
<span style="color: #000080;">if</span> <span style="color: #000080;">Not</span> (ProductKey = <span style="color: #800000;">&quot;&quot;</span>) <span style="color: #000080;">then</span>
	<span style="color: #000080;">call</span> RemoveSymantec(ProductKey, ProductName)
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.omegaprojex.com/index.php/2009/03/19/uninstalling-symantec-endpoint-protection-from-a-corporate-network/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Encrypting Web.Config connection strings with ASP.NET 2.0</title>
		<link>http://www.omegaprojex.com/index.php/2009/01/29/encrypting-webconfig-connection-strings-with-aspnet-20/</link>
		<comments>http://www.omegaprojex.com/index.php/2009/01/29/encrypting-webconfig-connection-strings-with-aspnet-20/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 19:20:58 +0000</pubDate>
		<dc:creator>ElementZero</dc:creator>
				<category><![CDATA[Computer Troubleshooting]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Server Administration]]></category>

		<guid isPermaLink="false">http://www.omegaprojex.com/?p=404</guid>
		<description><![CDATA[One of the greatest things in security of your web application is the encryption of the connection strings to the database. If the database connection strings are compromised, then an attacker could gain access to your database and cause unforeseen damage. In order to avoid this, Microsoft has created best practices and instruments for encrypting [...]]]></description>
			<content:encoded><![CDATA[<p>One of the greatest things in security of your web application is the encryption of the connection strings to the database. If the database connection strings are compromised, then an attacker could gain access to your database and cause unforeseen damage. In order to avoid this, Microsoft has created best practices and instruments for encrypting your connection strings in ASP.NET 2.0. This documentation may be found <a href="http://msdn.microsoft.com/en-us/library/ms998283.aspx">here</a>. I wrote this article to attempt to summarize (a.k.a. simplify) the Microsoft documentation, as well as going into further detail about how to configure your web.config and access the connection strings. Just think of this as the &#8220;Cliff&#8217;s Notes&#8221; to the Microsoft article.</p>
<div style="border:1px solid;border-color:#AAAAAA;background-color:#EEEEEE;padding-left:5px;">
<a href="#step1" style="color:navy;">Step 1: Creating a Key Container</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#step1b" style="color:navy;">1b) Removing a key collection</a><br />
<a href="#step2" style="color:navy;">Step 2: Setting up a provider to point to the key container in your web.config</a><br />
<a href="#step3" style="color:navy;">Step 3: Moving your connection strings into a different configuration file</a><br />
<a href="#step4" style="color:navy;">Step 4: Encrypting your connection strings</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#step4b" style="color:navy;">1b) Decrypting your connectionstrings.config</a><br />
<a href="#step5" style="color:navy;">Step 5: Give ASP.NET access to the private key</a><br />
<a href="#step6" style="color:navy;">Step 6: (Optional where applicable) Exporting the private keys to a different server</a><br />
<a href="#step7" style="color:navy;">Step 7: Accessing the connection strings within the web application</a><br />
<a href="#faq" style="color:navy;">F.A.Q.</a>
</div>
<h3><a name="step1">Step 1: Creating a Key Container</a></h3>
<p>In order to secure your web.config, you will first need to create a key container in order to hold the private keys for the encrypted material. This is done with the following command line </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pc "MyConnectionStrings" -exp
</pre>
<p>where &#8220;MyConnectionStrings&#8221; is the name of the key container you wish to create. After creating a key container, you can now modify your web.config to support the encrypted sections.</p>
<p><strong style="font-size:1.2em;"><a name="step1b">Removing a key collection</a></strong></p>
<p>At any point you can also remove a key collection, however doing this will mean that your web application will not be able to decrypt your connection strings anymore, and you will not be able to decrypt the connection strings file yourself for changes (see section 4.1).</p>
<p>The command to remove a key collection is </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pz "MyConnectionStrings"
</pre>
<h3><a name="step2">Step 2: Setting up the web.config</a></h3>
<p>In order to let ASP.NET know about the encryption provider (a.k.a. &#8211; which private keys to use to read the encrypted data), you must add the following section into your web.config under the <configuration> section.</p>
<pre class="wikitext">
&lt;configProtectedData defaultProvider="MyProvider"&gt;
	&lt;providers&gt;
		&lt;add name="MyDBProvider"
		type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
		keyContainerName="MyConnectionStrings" cspProviderName=""
		useMachineContainer="true" useOAEP="false" /&gt;
	&lt;/providers&gt;
&lt;/configProtectedData&gt;
</pre>
<p>The key things to note are the <strong>defaultProvider=&#8221;MyProvider&#8221;</strong>, the <strong>name=&#8221;MyDBProvider&#8221;</strong> and the <strong>keyContainerName=&#8221;MyConnectionStrings&#8221;</strong>.  The Provider name can be whatever you wish, and you may have multiple providers if you wish.  The provider can be set in code on the ConnectionManager.ConnectionStrings().Provider, but if a default one is specified via the &#8220;defaultProvider&#8221; attribute, this does not need to be specified.  Normally you would only use multiple providers if you want to have your connection strings split into multiple documents. <strong>Just as a note &#8211; other things can be encrypted in the web.config besides the connection strings section, in which case multiple providers may be useful as well.</strong>  The keyContainerName <em>MUST</em> be the same name as the key container name you used in Step 1.</p>
<h3><a name="step3">Step 3: Move connection strings into a different configuration file</a></h3>
<p>Now that we have done this, we can encrypt our connection strings. Before we do this though, I would advise moving your connection strings out to an external file. The reason is a) All the connection strings will be kept separate from your web.config settings and b) The encryption tool parses and re-writes the web.config file, and if you have done any special formatting to make your web.config look nice, that formatting may be completely removed.</p>
<p>Doing this is rather simple, all you have to do is create another configuration file for your project (we will be using &#8220;ConnectionStrings.config&#8221; ) and moving your &lt;connectionStrings&gt; settings to that file. So before doing this you may have </p>
<p><strong>Web.config</strong></p>
<pre class="wikitext">
&lt;configuration&gt;
  ...
	&lt;connectionStrings&gt;
		&lt;clear/&gt;
		&lt;add name="MyDBConn"
			connectionString="Data Source=MySQLSvr;Initial Catalog=AdventureWorks;User Id=MyUser;Password=MyPass;"
			providerName="System.Data.SqlClient" /&gt;
        &lt;/connectionStrings&gt;
...
&lt;/configuration&gt;
</pre>
<p>Now you will have<br />
<strong>Web.config</strong></p>
<pre class="wikitext">
&lt;configuration&gt;
...
        &lt;connectionStrings configSource="ConnectionStrings.config"&gt;&lt;/connectionStrings&gt;
...
&lt;/configuration&gt;
</pre>
<p><strong>ConnectionStrings.config</strong></p>
<pre class="wikitext">
&lt;connectionStrings&gt;
	&lt;clear/&gt;
	&lt;add name="MyDBConn"
		connectionString="Data Source=MySQLSvr;Initial Catalog=AdventureWorks;User Id=MyUser;Password=MyPass;"
		providerName="System.Data.SqlClient" /&gt;
        &lt;/connectionStrings&gt;
&lt;/connectionStrings&gt;
</pre>
<h3><a name="step4">Step 4: Encrypting your connection strings</a></h3>
<p>Next you need to encrypt the file where you are keeping the connection strings. This is done with the following command </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" "PATH"
</pre>
<p>Where &#8220;PATH&#8221; is the full path to the folder where your web.config is stored. i.e. &#8220;C:\inetpub\wwwroot&#8221;. It does not matter where the &#8220;connectionstrings.config&#8221; file is found as the web.config now has the file location of the connectionstrings.config in it, and the program will follow that path to the external file. The best idea is still to put the connectionstring.config file in the same directory as the web.config though. After doing this, you should be able to open the ConnectionStrings.config and see that the information has changed to some encrypted data. </p>
<p><strong style="font-size:1.2em;"><a name="step4b">Decrypting your connectionstrings.config</a></strong></p>
<p>Should the need arise for some changes to come to your connectionstrings, you can simply decrypt the file by executing the command </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pdf "connectionStrings" "PATH"
</pre>
<h3><a name="step5">Step 5: Give ASP.NET access to the private key</a></h3>
<p>The next command to run is to give the ASP.NET service access to the private key for it to be able to decipher the web.config file. By default the &#8220;NT Authority\Network Service&#8221; is the owner of the ASP.NET worker process, however this can be changed so you may need to grant the permissions to a different account instead. Giving access is done using the following commands: </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pa "MyConnectionStrings" "NT Authority\Network Service"
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pa "MyConnectionStrings" "ASPNET"
</pre>
<p>Again, the &#8220;MyConnectionStrings&#8221; <em>MUST</em> be the name of the key container that you named in Step 1. At this point your application should now have access to use the ConnectionStrings.config in it&#8217;s encrypted state.</p>
<h3><a name="step6">Step 6: (Optional where applicable) Exporting the private keys to a different server</a></h3>
<p>One final thing to note is that if you are running the application on some instance where the application will need to be run on multiple web servers with the same ConnectionStrings.config, you will need to export the private key container so that the same file can be used on different machines. This is accomplished via the following command </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -px "MyConnectionStrings" "C:\CustomKeys.xml" -pri
</pre>
<p>After copying the file over to the other server, you would run the command </p>
<pre class="wikitext">
c:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pi "MyConnectionStrings" "C:\CustomKeys.xml"
</pre>
<p>to import the keys. I believe you will still need to redo Step 5 again in order to grant permissions. </p>
<h3><a name="step7">Step 7: Accessing the connection strings within the web application</a></h3>
<p>The first thing to do in order to access the connection strings is you will need to add a reference to the project to System.Configuration. Although you can access some classes and objects in System.Configuration without adding a reference, the ASP.NET 2.0 connection strings configuration manager (which we will need) is not part of them. Once you add the reference, you simply add </p>
<p><strong>VB.NET</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> MyConnStr <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> System.<span style="color: #0000FF;">Configuration</span>.<span style="color: #0000FF;">ConfigurationManager</span>.<span style="color: #0000FF;">ConnectionStrings</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MyDBConn&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ConnectionString</span></pre></div></div>

<p><strong>C#</strong></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">string</span> MyConnStr <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span>.<span style="color: #0000FF;">ConfigurationManager</span>.<span style="color: #0000FF;">ConnectionStrings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;MyDBConn&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ConnectionString</span></pre></div></div>

<p>to access the connection string, where MyDBConn is the name you gave the connection string. Note that is you have multiple providers or the provider for the connection strings is not the same as the default provider, you will need to add </p>
<p><strong>VB.NET</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> DBConn <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> System.<span style="color: #0000FF;">Configuration</span>.<span style="color: #0000FF;">ConnectionStringSettings</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MyDBConn&quot;</span><span style="color: #000000;">&#41;</span>
DBConn.<span style="color: #0000FF;">ProviderName</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;MyProvider&quot;</span>
<span style="color: #0600FF;">Dim</span> MyConnStr <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> DBConn.<span style="color: #0000FF;">ConnectionString</span></pre></td></tr></table></div>

<p><strong>C#</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span>.<span style="color: #0000FF;">ConnectionStringSettings</span> DBConn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span>.<span style="color: #0000FF;">ConnectionStringSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;MyDBConn&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
DBConn.<span style="color: #0000FF;">ProviderName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;MyProvider&quot;</span>
<span style="color: #FF0000;">string</span> MyConnStr <span style="color: #008000;">=</span> DBConn.<span style="color: #0000FF;">ConnectionString</span></pre></td></tr></table></div>

<h3><a name="faq">F.A.Q</a></h3>
<p><strong>Q: I would like to add/update/remove a connection string in the file and I&#8217;ve already encrypted the file, how do I do this?  I have multiple web servers</strong><br />
A: If you just a single web server, all you need to do is <a href="step4b"decrypt the file</a>, change it how you need, and then <a href="step4">encrypt the file</a> again.  If you have multiple web servers, you will need to perform this on one of your servers, and then you can just copy that file to the other servers as the other servers will already have the key and know how to read the encrypted file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omegaprojex.com/index.php/2009/01/29/encrypting-webconfig-connection-strings-with-aspnet-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving shares and users Home folders to a new server</title>
		<link>http://www.omegaprojex.com/index.php/2008/11/10/moving-shares-and-users-home-folders-to-a-new-server/</link>
		<comments>http://www.omegaprojex.com/index.php/2008/11/10/moving-shares-and-users-home-folders-to-a-new-server/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 14:39:52 +0000</pubDate>
		<dc:creator>ElementZero</dc:creator>
				<category><![CDATA[Computer Troubleshooting]]></category>
		<category><![CDATA[Server Administration]]></category>

		<guid isPermaLink="false">http://www.omegaprojex.com/?p=163</guid>
		<description><![CDATA[The company I work for has many windows shares on the network, each one being used for a different department. They take up a lot of room as they have accumulated much stuff over the years, and also one of the shares is for housing users home directories. In order to better handle the space [...]]]></description>
			<content:encoded><![CDATA[<p>The company I work for has many windows shares on the network, each one being used for a different department.  They take up a lot of room as they have accumulated much stuff over the years, and also one of the shares is for housing users home directories.  In order to better handle the space needs, we bought a new drive array that starts at 1 terabyte and can be expanded from there. I now needed to move all the data from the one server to another.</p>
<p>Getting started, we run a robocopy script first, which will copy over all the data.  Robocopy is a Microsoft tool for copying files with all sorts of options for permissions and retrying, etc.  <strong>If you are a system administrator, I suggest you get used to this tool.</strong>  You have to get it in a windows resource kit (download from Microsoft) for pre-Vista Windows machines, but Microsoft included it in Windows 2008 and Vista already.  Anyways, the exact robocopy command I used was&#8230;</p>
<p>&#8220;C:\robocopy.exe&#8221; &#8220;E:\DataShares&#8221; &#8220;\\newserver\h$\Data Shares&#8221; /Z /R:5 /COPYALL /MIR /FP /LOG+:E:\DataShares\DataShares.log /TEE /XF DataShares.log</p>
<p>Which will basically copy all the files, mirroring the directory structure, retry 5 times if there is a failure, and write it out to a log file.  This also copied the security permissions so that those remain intact.  Note that if you have a local user on the server with permissions, these will not copy over as the local user does not exist on the server you are moving to (and no, you cannot just re-create the same user name and expect it to work, you would need to copy over the exact guid user id, which to date I have not done so I don&#8217;t know if it&#8217;s possible).  A complete listing of robocopy commands can be found <a href="http://technet.microsoft.com/en-us/library/cc733145.aspx">here</a>.</p>
<p>You can do this during work hours as it shouldn&#8217;t effect anything.  Some things may fail if they are in use, but that&#8217;s OK as we&#8217;ll get them later.  When it comes time to do the actual move over, you write down the permissions on each of the shares, then stop sharing the folders.  This will knock off any computer who is using a file inside those shares.  Run the same robocopy script again, and this time it will only copy over new files or files that have been updated.  For me, it took 7 hours to do the initial run through, but only 12 minutes to get the &#8220;incremental&#8221; update to all those files (600GB) &#8211; minimizing how long it took to do the actual move over.  Once it&#8217;s done you should have 0 failures.  If you have failures at this point, either free the locks (via server reboot or something) and/or make sure that you have permissions to all the folders with the user account you are running robocopy under (normally I find the latter is the problem though).  Make sure you continue to run the robocopy script over and over until you have 0 failures, otherwise that means you are still missing files!  After all the folders are copied successfully, you go to the new server and set back up the shares, using the same permissions you wrote down before.  Next you edit any logon scripts that map drives to point to the new server.</p>
<p>The last thing to worry about is the users home directories.  Since these are stored in Active Directory, you cannot just edit one text file like the logon scripts and hope to be done with it.  You basically have two options A) Manually go to each user and edit the home directory B) use a tool and do all of them in one fell swoop.  Obviously B is the better choice here.  The tool we will use is called ADModify.NET, which is written by Microsoft.  It is available for download <a href="http://www.codeplex.com/admodify">here</a>.  It&#8217;s a pretty simple tool, you just start ADModify.exe, and then click &#8220;Modify attributes&#8221;.  Pick your domain with the users you want to modify from the drop down list (make sure to pick the DC= entry, not the CN= entry).  Then pick a domain controller &#8211; doesn&#8217;t matter which one, but preferably the one you consider you &#8220;main&#8221; DC, or one that has a global catalog.  Uncheck everything except for &#8220;Show Only: Users&#8221; and uncheck &#8220;Show containers only&#8221;.  Also check &#8220;Traverese Subcontainers (Subtree Search) at the bottom&#8221;.  Now hit the Green arrow button to loa the list.  Traverse the directory containers until you get to the folder containing the users you want to modify, then hit &#8220;Add To List>&#8221; at the bottom.  Hold Ctrl and/or shift and select all the users, then hit &#8220;Next>>&#8221;.  Now you will be at the normal Active Directory screen.  Navigate to the &#8220;Profile&#8221; tab.  Here you have the options to change the users home folder.  Check the box next to &#8220;Connect&#8221; and change the drive letter to that of your choosing.  Next you will want to change the path to the new path of your users&#8217; home directory.  For my company, we use a simple \\server\Home\UserAccountName structure.  In this instance, where I want to modify multiple entries based off the user name, you put the path as</p>
<p>\\server\Home\%&#8217;sAMAccountName&#8217;%</p>
<p>The percent sign&#8217;s represent a variable, which will map the users account name when you hit continue.  After you have it set up as you want, hit &#8220;Go!&#8221;.  The script will run, and tell you the results, as well as write a little xml log file for your review later.  Double check your changes in Active Directory Users and Computers, and then you&#8217;re all set.  Note that you may want to test this on your account first just to make sure that you have the path right.</p>
<p>I decided to do this change at night time when it would effect the least amount of people, and I sent out an email saying that when users came in the next day (Monday) they would all need to reboot their computers or else things might not work correctly (as some programs are mapped to the shares, and also the logon scripts would need to be re-run).  I also made sure to tell them to save and close anything they had open when they left the office for the last time before Sunday night, as I would be moving the shares and anything they didn&#8217;t save would be lost.</p>
<p>And that&#8217;s it &#8211; now I have all my shares and home directories running on a new machine, with minimal downtime and all permissions intact.  The users aren&#8217;t even aware there was a change except for the fact that I made them reboot. <img src="http://www.omegaprojex.com/wp-content/plugins/wp-smiley-switcher/noktahhitam/icon_smile.gif" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.omegaprojex.com/index.php/2008/11/10/moving-shares-and-users-home-folders-to-a-new-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
