<?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>108.bz &#187; Windows</title>
	<atom:link href="http://www.108.bz/posts/tag/windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.108.bz</link>
	<description>Wandering futilities...</description>
	<lastBuildDate>Fri, 27 May 2011 09:08:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Cloning DHCP reservations between Windows servers</title>
		<link>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/</link>
		<comments>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 16:01:30 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=688</guid>
		<description><![CDATA[Quick post to show you how DHCP reservations can be replicated between Windows servers. Why whould you want to do that? Because often, to achieve DHCP service high availability, DHCP scopes are equally divided between servers. When a client PC is connected to the network, it sends out a broadcast to discover which DHCP servers [...]]]></description>
			<content:encoded><![CDATA[<p>Quick post to show you how DHCP reservations can be replicated between Windows servers. Why whould you want to do that? Because often, to achieve DHCP service high availability, DHCP scopes are equally divided between servers. When a client PC is connected to the network, it sends out a broadcast to discover which DHCP servers are active on that particular ethernet segment. Depending on their number, the PC will receive one or more answer, each offering an IP address. If a client is to be assigned a fixed IP, all of those offers should bear the same IP address. Hence, DHCP reservations need to be configured the same for every DHCP server in the given scope. As far as I know, this needs to be done by hand. To speed up the process, I use <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> (see <a href="http://technet.microsoft.com/en-us/library/cc787375(WS.10).aspx">Netsh commands for DHCP</a>).</p>
<p>The command below will dump all of the reservations to a file named &#8220;reservations.txt&#8221;. <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">findstr</span> filters <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> output keeping just the info we need.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\Administrator&gt; netsh dhcp server \\dhcpsrv1 scope 10.4.0.0 dump | findstr Add.reservedip &gt; reservations.txt</div></div>
<p>Each line in &#8220;reservations.txt&#8221; should look like this:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Dhcp Server 10.4.1.1 Scope 10.4.0.0 Add reservedip 10.4.5.3 58b04576339a &quot;pcname.domain.lan&quot; &quot;Reservation Comment&quot; &quot;BOTH&quot;</div></div>
<p><span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">10.4.1.1</span> is the IP address for <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dhcpsrv1</span>, the &#8220;source&#8221; DHCP server.</p>
<p>Open &#8220;reservations.txt&#8221; in a text editor, check that everything is fine and substitute the source DHCP server IP with the target&#8217;s one (i.e.: 10.4.1.1 becomes 10.4.1.2), save the file and run:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\Administrator&gt; netsh &lt; reservations.txt<br />
netsh&gt;<br />
Changed the current scope context to 10.4.0.0 scope.<br />
<br />
Command completed successfully.<br />
netsh&gt;<br />
Command completed successfully.<br />
netsh&gt;<br />
[..]</div></div>
<p>That&#8217;s it; not a fancy trick, but it may be useful nonetheless. Just beware that, when there are thousands of clients, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">netsh</span> could take a while to complete its job (especially the &#8220;dump&#8221; step)&#8230;</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=688" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/cloning-dhcp-reservations-between-windows-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cloning an Active Directory group</title>
		<link>http://www.108.bz/posts/it/cloning-an-active-directory-group/</link>
		<comments>http://www.108.bz/posts/it/cloning-an-active-directory-group/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 12:06:10 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=617</guid>
		<description><![CDATA[Or how to use the dsquery/dsget/dsmod commands to copy all the members from an Active Directory group (source), to another one (destination). If, like me, you are on a neverending quest to click less and script more, you can solve the problem this way: Create the destination group, should it not exist. Find the source [...]]]></description>
			<content:encoded><![CDATA[<p>Or how to use the <a href="http://technet.microsoft.com/en-us/library/cc732952(WS.10).aspx">dsquery</a>/<a href="http://technet.microsoft.com/en-us/library/cc755162(WS.10).aspx">dsget</a>/<a href="http://technet.microsoft.com/en-us/library/cc732406(WS.10).aspx">dsmod</a> commands to copy all the members from an<br />
Active Directory group (<i>source</i>), to another one (<i>destination</i>).</p>
<p>If, like me, you are on a neverending quest to click less and script more, you can solve the problem this way:</p>
<ul>
<li>Create the destination group, should it not exist.</li>
<li>Find the source group&#8217;s <a href="http://en.wikipedia.org/wiki/Distinguished_Name">DN</a>:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsquery group -samid sourcegroup<br />
&quot;CN=sourcegroup,OU=Groups,DC=contoso,DC=com&quot;</div></div>
<p>&#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-samid</span>&#8221; argument is the group name whose DN you&#8217;re looking for. You can use &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">*</span>&#8221; as a wildcard.</li>
<li>Ditto for the destination group:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsquery group -samid destinationgroup<br />
&quot;CN=destinationgroup,OU=Groups,DC=contoso,DC=com&quot;&lt;/li&gt;</div></div>
<li>On with the copy itself:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsget group &quot;CN=sourcegroup,OU=Groups,DC=contoso,DC=com&quot; -members -expand | dsmod group &quot;CN=destinationgroup,OU=Groups,DC=contoso,DC=com&quot; -addmbr -c<br />
dsmod succeeded:CN=destinationgroup,OU=Groups,DC=contoso,DC=com</div></div>
<p>These are two commands: &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsget group</span>&#8221; and &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsmod group</span>&#8220;. Output from the first is piped to the second. &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-members</span>&#8221; causes the group members&#8217; DNs to be listed on standard output (one by line, quoted). &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-expand</span>&#8221; makes <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsget</span> to recursively expand the sub-groups that <i>sourcegroup</i> may hold.<br />
Conversely, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dsmod</span> modifies <i>destinationgroup</i> adding members to it.<br />
Very cool, so far. The only caveat is that the &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-c</span>&#8221; switch doesn&#8217;t work as advertised. It should copy members over <i>destinationgroup</i> even if already exist, but it doesn&#8217;t. If you need to re-sync source and dest, delete source&#8217;s contents from dest.</li>
</ul>
<p>Bonus note; here&#8217;s a quick way to discover a user&#8217;s DN given his username:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;dsquery user -samid jdoe<br />
&quot;CN=John Doe,CN=Users,DC=contoso,DC=com&quot;</div></div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=617" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/cloning-an-active-directory-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symantec Endpoint Protection &#8211; crypt32 errors</title>
		<link>http://www.108.bz/posts/it/symantec-endpoint-protection-crypt32-errors/</link>
		<comments>http://www.108.bz/posts/it/symantec-endpoint-protection-crypt32-errors/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 16:28:58 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[Symantec]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=591</guid>
		<description><![CDATA[One of the most procrastinated issues I had at a Customer&#8217;s, was the proliferation of errors like these (as shown in servers/clients Event Viewer): Event Type: Error Event Source: &#160; crypt32 Event Category: None Event ID: &#160; 8 Description: Failed auto update retrieval of third-party root list sequence number from: &#60;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt&#62; with error: This network [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most procrastinated issues I had at a Customer&#8217;s, was the proliferation of errors like these (as shown in servers/clients Event Viewer):</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Error<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 8<br />
Description:<br />
Failed auto update retrieval of third-party root list sequence number from: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt&gt; with error: This network connection does not exist.</div></div>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Error<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 11<br />
Description:<br />
Failed extract of third-party root list from auto update cab at: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab&gt; with error: A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file.</div></div>
<p>There are several posts mentioning the issue, <a href="http://www.symantec.com/connect/forums/crypt32-errors-event-viewer-after-sep-110-installation">this one</a> pointed me in the right direction. Basically, because of how SEP components communicate, Windows is triggered into updating the list of trusted root Certification Authorities. It tries to do so through the Internet using the Computer account. The latter may not have any proxy configured. Being unable to reach outside, the host gets flooded by <i>crypt32</i> errors.</p>
<p>In order to solve the issue, I decided to deploy a valid proxy configuration, for the Computer account (<i>SYSTEM</i> user), on a subset of the Domain&#8217;s hosts.<br />
One of the ways to script that is the &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">proxycfg -u</span>&#8221; command<sup class='footnote'><a href='#fn-591-1' id='fnref-591-1'>1</a></sup> that works by copying the current user proxy settings to the SYSTEM&#8217;s registry. Sounds cool but if the current user is not a member of the local Administrators group, he won&#8217;t have the necessary rights. The following script instead, can be launched via Group Policy<sup class='footnote'><a href='#fn-591-2' id='fnref-591-2'>2</a></sup> during operating system startup, and since it&#8217;s a <i>startup</i> script rather than a <i>login</i> one, it will run with administrative privileges.</p>
<p>Nothing fancy in the below source. It creates the registry key if it doesn&#8217;t exist, then sets the right value for <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">WinHttpSettings</span> which I obtained this way:</p>
<ul>
<li>use &#8220;<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">proxycfg -u</span>&#8221; on a test host</li>
<li>use the Registry editor to export the contents of <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections</span></li>
</ul>
<p>The value is of type <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">REG_BINARY</span>. Since the <a href="http://msdn.microsoft.com/en-us/library/yfdfhz1b(v=vs.85).aspx">RegWrite</a> API (method of class <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">WScript.Shell</span>) cannot deal with binary values, WMI (<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">StdRegProv</span> registry provider) needs to be used. Also, <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">SetBinaryValue</span> expects an array of decimal values, while Regedit exports them as hexadecimal digits (you&#8217;ll have to take care of the conversion yourself).</p>
<div class="codecolorer-container vb blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span><br />
<span style="color: #000080;">Const</span> HKEY_LOCAL_MACHINE = &amp;H80000002<br />
<br />
strPath = <span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections&quot;</span><br />
strKey = <span style="color: #800000;">&quot;WinHttpSettings&quot;</span><br />
strValue = <span style="color: #800000;">&quot;24,0,0,0,0,0,0,0,3,0,0,0,19,0,0,0,112,114,111,120,121,46,99,117,115,116,46,108,97,110,58,56,48,56,48,47,0,0,0,49,48,46,42,46,42,46,42,59,115,101,114,118,101,114,50,48,59,115,101,114,118,101,114,50,48,46,42,59,42,46,99,117,115,116,46,108,97,110,59,60,108,111,99,97,108,62&quot;</span><br />
strMachineName = <span style="color: #800000;">&quot;.&quot;</span><br />
<br />
arrValues = Split(strValue,<span style="color: #800000;">&quot;,&quot;</span>)<br />
strMoniker = <span style="color: #800000;">&quot;winMgmts:\\&quot;</span> &amp; strMachineName &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span><br />
<span style="color: #000080;">Set</span> oReg = GetObject(strMoniker)<br />
rv = oReg.CreateKey(HKEY_LOCAL_MACHINE, strPath)<br />
rv = oReg.SetBinaryValue(HKEY_LOCAL_MACHINE, strPath, strKey, arrValues)</div></div>
<p>If the scripts works as it should, you&#8217;ll be greeted by these events:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Information<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 7<br />
Description:<br />
Successful auto update retrieval of third-party root list sequence number from: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt&gt;</div></div>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Event Type: Information<br />
Event Source: &nbsp; crypt32<br />
Event Category: None<br />
Event ID: &nbsp; 2<br />
Description:<br />
Successful auto update retrieval of third-party root list cab from: &lt;http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab&gt;</div></div>
<p>And, hopefully, crypt32 errors will be gone for good.</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-591-1'>See <a href="http://msdn.microsoft.com/en-us/library/ms761351(v=vs.85).aspx">Using the WinHTTP Proxy Configuration Utility</a> <span class='footnotereverse'><a href='#fnref-591-1'>&#8617;</a></span></li>
<li id='fn-591-2'>Computer Configuration, Windows Settings, Scripts, Startup <span class='footnotereverse'><a href='#fnref-591-2'>&#8617;</a></span></li>
</ol>
</div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=591" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/symantec-endpoint-protection-crypt32-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From MS SQL to MySQL, realtime row copy</title>
		<link>http://www.108.bz/posts/it/from-ms-sql-to-mysql-realtime-row-copy/</link>
		<comments>http://www.108.bz/posts/it/from-ms-sql-to-mysql-realtime-row-copy/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 13:26:42 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Interoperability]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=556</guid>
		<description><![CDATA[Or: &#8220;How to call a web server from a Microsoft SQL Server Stored Procedure&#8221;. Customer has got a VoIP software PBX (Swyx). It logs incoming calls (the CDR) in a MS SQL Server database. The CDR structure is straightforward: a single table where each row is a call, indexed by CallId (transferred calls get, eventually, [...]]]></description>
			<content:encoded><![CDATA[<p>Or: &#8220;How to call a web server from a Microsoft SQL Server Stored Procedure&#8221;.<br />
Customer has got a VoIP software PBX (<a href="http://www.swyx.com/">Swyx</a>). It logs incoming calls (the <abbr title="Call Detail Record">CDR</abbr>) in a MS SQL Server database. The CDR structure is straightforward: a single table where each row is a call, indexed by <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">CallId</span> (transferred calls get, eventually, a new row and a &#8220;child CallId&#8221;).<br />
I needed to process the CDR within these specs/restrictions:</p>
<ul>
<li>Each row has to be processed as soon as it is INSERTed</li>
<li>Rows must be filtered (depending on the called number)</li>
<li>Filtered rows must be &#8220;mirrored&#8221; to a MySQL DB</li>
<li>MS SQL machine is heavily loaded and mission critical; the row-copy mechanism must be light and fast</li>
</ul>
<p>The first and second specs imply the use of triggers/stored procedures.</p>
<p>I originally thought that the &#8220;DB link&#8221;-kind of functionality could be achieved natively on MS SQL. In theory it can, via <a href="http://msdn.microsoft.com/en-us/library/aa213778(SQL.80).aspx">Linked Servers</a> (<a href="http://www.ideaexcursion.com/2009/02/25/howto-setup-sql-server-linked-server-to-mysql/">bound</a> to ODBC Data Sources). There&#8217;s a catch though: you can SELECT stuff on linked servers at will, but as soon as you try to INSERT, you&#8217;ll hit error 7391<sup class='footnote'><a href='#fn-556-1' id='fnref-556-1'>1</a></sup>. MS SQL, can&#8217;t really blame it, would like to be able to rollback any change made, even on the linked MySQL. It needs to start a (implicit, distributed) transaction on MySQL, but that&#8217;s not supported and the write fails. <a href="http://forums.mysql.com/read.php?60,209856,256141#msg-256141">This</a> workaround (forcibly switch off implicit transactions) didn&#8217;t work for me. Apparently, the Oracle OLEDB Provider is able to ignore/disable distributing transactions when the parameter <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">DistribTX=0</span> is in the provider string. MySQL&#8217;s ODBC driver doesn&#8217;t provide a similar toggle.</p>
<p>The easiest way to push data &#8220;out&#8221; of MS SQL is (arguably) through HTTP. The DB GETs a full URL, passing key/value parameters to a Web Service that outputs to MySQL.</p>
<p>On with the code, starting with the &#8220;Web Service&#8221;. What follow is a mere Perl script, useful for testing. Depending on the expected load, you may want to use a proper application server, providing MySQL DB <a href="http://en.wikipedia.org/wiki/Connection_pool">connection pooling</a>. What you should <i>really</i> do, is serve the script through HTTPS and password protect it. Without SSL, a malicious user could sniff the cleartext requests sent by the source DB, forge similar ones and litter/DOS the MySQL instance. Of course, the Web Service could output to just any supported DB, not only to MySQL.</p>
<div class="codecolorer-container perl blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span><br />
<br />
<span style="color: #000000; font-weight: bold;">use</span> DBI<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> CGI<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$DEBUG</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@FIELDS</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a><span style="color: #009900;">&#40;</span><br />
CallId<br />
OriginationNumber<br />
CalledNumber<br />
DestinationNumber<br />
StartTime<br />
ScriptConnectTime<br />
DeliveredTime<br />
ConnectTime<br />
TransferTime<br />
EndTime<br />
DisconnectReason<br />
TransferredToCallId<br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$q</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CGI<span style="color: #339933;">;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">header</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>type <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'text/plain'</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>charset <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'ISO-8859-1'</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span>expires <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'-1d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># checks</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$checkresult</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$checkmessage</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">sub</span> setcheck <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$$</span><span style="color: #0000ff;">$$</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$rrc</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rc</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rrs</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$rs</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">$$rrc</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$rc</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">$$rrs</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$rs</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">sub</span> isnumber <span style="color: #009900;">&#123;</span> <a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^[0-9]*$/i</span><span style="color: #339933;">;</span> <a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">sub</span> issane <span style="color: #009900;">&#123;</span> <a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^[a-z0-9%:\- ]*$/i</span><span style="color: #339933;">;</span> <a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
setcheck<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\$checkresult</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">\$checkmessage</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'NULL CallId'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$checkresult</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">not</span> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">param</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'CallId'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
setcheck<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\$checkresult</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">\$checkmessage</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'CallId must be a number'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$checkresult</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">not</span> isnumber<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">param</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'CallId'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@FIELDS</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; setcheck<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">\$checkresult</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #0000ff;">\$checkmessage</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;$_ value contains invalid characters&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$checkresult</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">not</span> issane<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">param</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$checkresult</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dbh</span> <span style="color: #339933;">=</span> DBI<span style="color: #339933;">-&gt;</span><span style="color: #006600;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'DBI:mysql:database=dbname'</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'dbuser'</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'password'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;KO: Error $DBI::err - $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$values</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/join.html"><span style="color: #000066;">join</span></a> <span style="color: #ff0000;">','</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> <a href="http://perldoc.perl.org/functions/map.html"><span style="color: #000066;">map</span></a> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">quote</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">param</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">param</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #ff0000;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span> <span style="color: #0000ff;">@FIELDS</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sth</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;INSERT INTO callslog VALUES ($values)&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;KO: Error $DBI::err - $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">$sth</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span> <span style="color: #b1b100;">or</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;KO: Error $DBI::err - $DBI::errstr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$DEBUG</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$_</span><span style="color: #339933;">.</span><span style="color: #ff0000;">': '</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">param</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">for</span> <span style="color: #0000ff;">@FIELDS</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;OK<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;KO: $checkmessage<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span></div></div>
<p>Next, the trigger code. It acts after each INSERT on the IpPbxCDR table. If a called number ends with the given digits, calls the Stored Procedure <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">spLogCall</span>, passing it the fields we&#8217;re interested in. I use the (commented) <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">raiserror</span>  call for debugging purposes.</p>
<div class="codecolorer-container sql blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">USE</span> <span style="color: #66cc66;">&#91;</span>ippbxlog<span style="color: #66cc66;">&#93;</span><br />
GO<br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
GO<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
GO<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TRIGGER</span> <span style="color: #66cc66;">&#91;</span>dbo<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>tr_ProcessCall<span style="color: #66cc66;">&#93;</span><br />
<span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">&#91;</span>dbo<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>IpPbxCDR<span style="color: #66cc66;">&#93;</span><br />
AFTER <span style="color: #993333; font-weight: bold;">INSERT</span><br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
BEGIN<br />
&nbsp; &nbsp; DECLARE<br />
&nbsp; &nbsp; &nbsp; &nbsp; @RightMatch nvarchar <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @CallId int<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @OriginationNumber nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @CalledNumber nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @DestinationNumber nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @StartTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @ScriptConnectTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @DeliveredTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @ConnectTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @TransferTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @EndTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @DisconnectReason nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @TransferredToCallId int<br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> @RightMatch <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'12345678'</span><br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SELECT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @CallId <span style="color: #66cc66;">=</span> CallId<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @OriginationNumber <span style="color: #66cc66;">=</span> OriginationNumber<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @CalledNumber <span style="color: #66cc66;">=</span> CalledNumber<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @DestinationNumber <span style="color: #66cc66;">=</span> DestinationNumber<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @StartTime <span style="color: #66cc66;">=</span> StartTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @ScriptConnectTime <span style="color: #66cc66;">=</span> ScriptConnectTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @DeliveredTime <span style="color: #66cc66;">=</span> DeliveredTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @ConnectTime <span style="color: #66cc66;">=</span> ConnectTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @TransferTime <span style="color: #66cc66;">=</span> TransferTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @EndTime <span style="color: #66cc66;">=</span> EndTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @DisconnectReason <span style="color: #66cc66;">=</span> DisconnectReason<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @TransferredToCallId <span style="color: #66cc66;">=</span> TransferredToCallId<br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">FROM</span> INSERTED<br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">RIGHT</span><span style="color: #66cc66;">&#40;</span>@DestinationNumber<span style="color: #66cc66;">,</span>LEN<span style="color: #66cc66;">&#40;</span>@RightMatch<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> @RightMatch<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">RIGHT</span><span style="color: #66cc66;">&#40;</span>@CalledNumber<span style="color: #66cc66;">,</span>LEN<span style="color: #66cc66;">&#40;</span>@RightMatch<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span> @RightMatch<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; BEGIN<br />
<span style="color: #808080; font-style: italic;">--raiserror('%s',16,1, @DestinationNumber)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; EXEC spLogCall<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @CallId<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @OriginationNumber<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @CalledNumber<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DestinationNumber<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @StartTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @ScriptConnectTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DeliveredTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @ConnectTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @TransferTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @EndTime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DisconnectReason<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @TransferredToCallId<br />
&nbsp; &nbsp; END<br />
END</div></div>
<p>Lastly, the Web Service contacting Stored Procedure. I use <a href="http://msdn.microsoft.com/en-us/library/ms189763.aspx"><span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">sp_OACreate</span></a> to create an OLE object of class <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">MSXML2.ServerXMLHTTP</span> passing it the contructed GET URL (address + parameters). Depending on MS SQL&#8217;s version, you may have to explicitly enable in-database OLE automation, this way:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">exec sp_configure 'show advanced options', 1<br />
go<br />
reconfigure<br />
go<br />
exec sp_configure 'Ole Automation Procedures', 1<br />
go<br />
reconfigure<br />
go</div></div>
<p>Timeouts for various operations are set to reasonably low values, we don&#8217;t want the DB to &#8220;block&#8221; for too long. And again: <i>use HTTPS</i>. Get your certificates right (on MS SQL&#8217;s server, install the root certificate for the CA who issued the cert you&#8217;re using on the web/application server) and use HTTPS.</p>
<div class="codecolorer-container sql blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">USE</span> <span style="color: #66cc66;">&#91;</span>ippbxlog<span style="color: #66cc66;">&#93;</span><br />
GO<br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
GO<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
GO<br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> PROCEDURE <span style="color: #66cc66;">&#91;</span>dbo<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>spLogCall<span style="color: #66cc66;">&#93;</span> <br />
&nbsp; &nbsp; @CallId int<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @OriginationNumber nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @CalledNumber nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @DestinationNumber nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @StartTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @ScriptConnectTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @DeliveredTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @ConnectTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @TransferTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @EndTime datetime<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @DisconnectReason nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @TransferredToCallId int<br />
<span style="color: #993333; font-weight: bold;">AS</span><br />
<br />
BEGIN<br />
DECLARE <br />
&nbsp; &nbsp; @Object int<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @hr int<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @openparams nvarchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2048</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; @responsetext varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">8000</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
EXEC @hr <span style="color: #66cc66;">=</span> sp_OACreate <span style="color: #ff0000;">'MSXML2.ServerXMLHTTP'</span><span style="color: #66cc66;">,</span> @Object out<br />
<span style="color: #993333; font-weight: bold;">IF</span> @hr <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span><br />
BEGIN<br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> CONCAT_NULL_YIELDS_NULL OFF<br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> @openparams <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'open(&quot;GET&quot;, &quot;http://10.1.1.123/ws/CDR.pl?'</span> <span style="color: #66cc66;">+</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'CallId='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CAST<span style="color: #66cc66;">&#40;</span>@CallId <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'OriginationNumber='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp;CAST<span style="color: #66cc66;">&#40;</span>@OriginationNumber <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'CalledNumber='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp; CAST<span style="color: #66cc66;">&#40;</span>@CalledNumber <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'DestinationNumber='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp;CAST<span style="color: #66cc66;">&#40;</span>@DestinationNumber <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'StartTime='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONVERT<span style="color: #66cc66;">&#40;</span>varchar<span style="color: #66cc66;">,</span> @StartTime<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'ScriptConnectTime='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp;CONVERT<span style="color: #66cc66;">&#40;</span>varchar<span style="color: #66cc66;">,</span> @ScriptConnectTime<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'DeliveredTime='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp;CONVERT<span style="color: #66cc66;">&#40;</span>varchar<span style="color: #66cc66;">,</span> @DeliveredTime<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'ConnectTime='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONVERT<span style="color: #66cc66;">&#40;</span>varchar<span style="color: #66cc66;">,</span> @ConnectTime<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'TransferTime='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp; CONVERT<span style="color: #66cc66;">&#40;</span>varchar<span style="color: #66cc66;">,</span> @TransferTime<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'EndTime='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CONVERT<span style="color: #66cc66;">&#40;</span>varchar<span style="color: #66cc66;">,</span> @EndTime<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'DisconnectReason='</span> <span style="color: #66cc66;">+</span> &nbsp; &nbsp; CAST<span style="color: #66cc66;">&#40;</span>@DisconnectReason <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #ff0000;">'&amp;'</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'TransferredToCallId='</span> <span style="color: #66cc66;">+</span> &nbsp;CAST<span style="color: #66cc66;">&#40;</span>@TransferredToCallId <span style="color: #993333; font-weight: bold;">AS</span> varchar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&quot;, False)'</span><br />
&nbsp; &nbsp; EXEC @hr <span style="color: #66cc66;">=</span> sp_OAMethod @Object<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'setTimeouts(3000,3000,3000,3000)'</span><br />
&nbsp; &nbsp; EXEC @hr <span style="color: #66cc66;">=</span> sp_OAMethod @Object<span style="color: #66cc66;">,</span> @openparams<br />
&nbsp; &nbsp; EXEC @hr <span style="color: #66cc66;">=</span> sp_OAMethod @Object<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Send'</span><br />
&nbsp; &nbsp; EXEC @hr <span style="color: #66cc66;">=</span> sp_OAGetProperty @Object<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'responseText'</span><span style="color: #66cc66;">,</span> @responseText out<br />
END<br />
END</div></div>
<p>That&#8217;s it, the method performs and scales quite well. I think I&#8217;ll find other uses for it soon&#8230;</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-556-1'>The operation could not be performed because OLE DB provider &#8220;%ls&#8221; for linked server &#8220;%ls&#8221; was unable to begin a distributed transaction. <span class='footnotereverse'><a href='#fnref-556-1'>&#8617;</a></span></li>
</ol>
</div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=556" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/from-ms-sql-to-mysql-realtime-row-copy/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Recovering NTBackup Tapes</title>
		<link>http://www.108.bz/posts/it/recovering-ntbackup-tapes/</link>
		<comments>http://www.108.bz/posts/it/recovering-ntbackup-tapes/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 10:36:43 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=539</guid>
		<description><![CDATA[This article will show you how to handle tape backups generated by NTBackup, turn them into a .BKF file (using Linux) and extract specific files (using Linux/Windows). Some of the stuff explained here may also be useful when dealing with corrupt tapes/files, and may work for any backup software that generates MTF (Microsoft Tape Format) [...]]]></description>
			<content:encoded><![CDATA[<p>This article will show you how to handle tape backups generated by <a href="http://en.wikipedia.org/wiki/Ntbackup">NTBackup</a>, turn them into a .BKF file (using Linux) and extract specific files (using Linux/Windows). Some of the stuff explained here may also be useful when dealing with corrupt tapes/files, and may work for any backup software that generates MTF (Microsoft Tape Format) output, such as maybe Symantec Backup Exec<sup class='footnote'><a href='#fn-539-1' id='fnref-539-1'>1</a></sup>.</p>
<p>The scenario: an old machine (hosting a not so important app) crashes badly due to multiple disk failures. O.S. (Windows 2000 Server) won&#8217;t boot anymore. Backups were directed to a local <a href="http://en.wikipedia.org/wiki/Digital_Data_Storage">DDS</a> tape drive, the only one of its kind surviving in the whole Company. While reinstalling the app to another server, I need to recover some files and have access to the pre-crash registry.</p>
<p>And here&#8217;s the plan:</p>
<ul>
<li>Boot the half-dead server with the invaluable <a href="http://www.sysresccd.org/Main_Page">SystemRescueCd</a>.</li>
<li>Put the last available tape backup in the drive.</li>
<li>Save an <i>image</i> of the tape somewhere.</li>
<li>Extract stuff from the image.</li>
</ul>
<p>When SystemRescueCd is running and network connected, make available a shared folder:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@sysresccd /root % mkdir /mnt/storagespace<br />
root@sysresccd /root % mount -t cifs //fileserver/e$ /mnt/storagespace -o username=administrator,workgroup=domain.local</div></div>
<p>Then, generate the image. NTBackup tape backups are spread across multiple &#8220;tape files&#8221;. If you read the tape from the beginning, sooner or later you will hit EOF (an end-of-file condition). <i>Don&#8217;t</i> rewind it: go on to the next file instead. Repeat until there are no more files to read.<br />
On Unix, the first SCSI tape device is mapped to <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/st0</span> <i>and</i> <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/nst0</span>. When a process finishes reading from <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/st0</span>, the tape is implicitly rewound. Viceversa, using <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/nst0</span> doesn&#8217;t cause any rewind; tape will stay positioned right after the last block read.</p>
<p>Just in case, perform a manual rewind:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@sysresccd /mnt/storagespace/temp % mt -f /dev/st0 rewind</div></div>
<p>Then, try to guess the right block size. It seems to be set at 16K. Should this method fail, check the &#8220;How do I find out tape block size?&#8221; method <a href="http://www.cyberciti.biz/faq/rhel-centos-debian-set-tape-blocksize/">here</a>.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@sysresccd /mnt/storagespace/temp % mt -f /dev/st0 status<br />
SCSI 2 tape drive: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
File number=0, block number=0, partition=0.<br />
Tape block size 16384 bytes. Density code 0x26 (DDS-4 or QIC-4GB).<br />
Soft error count since last status=0<br />
General status bits on (41010000):<br />
&nbsp;BOT ONLINE IM_REP_EN</div></div>
<p>Start reading (by means of <a href="http://en.wikipedia.org/wiki/Dd_(Unix)">dd</a>) with the specified block size. See? We&#8217;re using the non-rewinding tape device <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">/dev/nst0</span>.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@sysresccd /mnt/storagespace/temp % for f in `seq 1 10`; do echo dd if=/dev/nst0 of=tapeblock`printf &quot;%<br />
06g&quot; $f`.bin ibs=16384; done<br />
dd if=/dev/nst0 of=tapeblock000001.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000002.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000003.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000004.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000005.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000006.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000007.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000008.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000009.bin ibs=16384<br />
dd if=/dev/nst0 of=tapeblock000010.bin ibs=16384<br />
root@sysresccd /mnt/storagespace/temp % dd if=/dev/nst0 of=tapeblock000001.bin ibs=16384<br />
1+0 records in<br />
32+0 records out<br />
16384 bytes (16 kB) copied, 0.0341089 s, 480 kB/s<br />
root@sysresccd /mnt/storagespace/temp % dd if=/dev/nst0 of=tapeblock000002.bin ibs=16384<br />
270540+0 records in<br />
8657280+0 records out<br />
4432527360 bytes (4.4 GB) copied, 7666.22 s, 578 kB/s<br />
[..]<br />
root@sysresccd /mnt/storagespace/temp % dd if=/dev/nst0 of=tapeblock000007.bin ibs=16384<br />
4+0 records in<br />
128+0 records out<br />
65536 bytes (66 kB) copied, 0.1176 s, 557 kB/s<br />
root@sysresccd /mnt/storagespace/temp % dd if=/dev/nst0 of=tapeblock000008.bin ibs=16384<br />
0+0 records in<br />
0+0 records out<br />
0 bytes (0 B) copied, 0.00461986 s, 0.0 kB/s<br />
root@sysresccd /mnt/storagespace/temp % dd if=/dev/nst0 of=tapeblock000009.bin ibs=16384<br />
dd: reading `/dev/nst0': Input/output error<br />
0+0 records in<br />
0+0 records out<br />
0 bytes (0 B) copied, 0.00356835 s, 0.0 kB/s</div></div>
<p>Reads beyond the last file will result in an &#8220;Input/output error&#8221;.</p>
<p><a href="http://www.108.bz/wp-content/uploads/2010/08/tape1.png"><img src="http://www.108.bz/wp-content/uploads/2010/08/tape1-300x120.png" alt="Tape image chunks" title="Tape image chunks" width="300" height="120" class="alignnone size-medium wp-image-551" /></a></p>
<p>It&#8217;s time to join the <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.bin</span> files into a single one: the tape image (maybe using <a href="http://www.freebyte.com/hjsplit/">HJSplit</a> for the task). You could&#8217;ve been more clever than me and appended <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">dd</span>&#8216;s output to a single file, thus skipping the join step and saving space. I didn&#8217;t do it because I wanted to see if any tape file was corrupted (and be able to re-read it, if needed).</p>
<p>I called the tape image &#8220;backup.bkf&#8221;, even though it&#8217;s not a true <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">.BKF</span> file&#8230; As we said, it&#8217;s a tape image. NTBackup is not able to read it, whereas the abundance of &#8220;BKF recovery&#8221; software can. Before going on, let me polemicize a bit. There are many, almost identical, software of this kind. I&#8217;ve got the feeling that they all &#8220;borrow&#8221; from <a href="http://www.codeproject.com/KB/files/BackupReader.aspx">this</a> open source BKF reader<sup class='footnote'><a href='#fn-539-2' id='fnref-539-2'>2</a></sup>. Looks like different commercial developers grabbed the same source, embellished the GUI just a bit, and made a product to sell. How lame. But it turns out that you don&#8217;t need to pay a cent to extract files from a .BKF or tape image, on Linux or Windows as well.</p>
<p>On windows, get <a href="http://www.fpns.net/willy/msbackup.htm">ntbkup</a> by William T. Kranz . I use the (optional) <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">-s3</span> switch to target set 3 which I know holds the System State.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\temp\x&gt;..\ntbkup.exe ..\backup.bkf -s3 -l&quot;\Registry:&quot;<br />
<br />
NTBKUP Ver 1.07c compiled for WIN32 with MAX_PATH = 100<br />
&nbsp; &nbsp;compiled for 64 bit file offsets<br />
Copyright (C) 2003 William T. Kranz<br />
NTBKUP comes with ABSOLUTELY NO WARRANTY<br />
Free software distributed under the terms of the GNU General Public license<br />
See http://www.gnu.org/licenses/gpl.html for license information<br />
Check http://www.fpns.net/willy/msbackup.htm for Updates &amp; Documentation<br />
<br />
resrict operations to backup set 3<br />
device name: C:<br />
volume name: Local disk<br />
device name: D:<br />
volume name: Volume<br />
Set 3:<br />
Name: Company lun-29-06-2009-23.04<br />
Description:<br />
User: DOMAIN\administrator<br />
<br />
device name: System state data from 0x36113d956 to 0x3611ec956<br />
length 716800 &nbsp;atrib 0x20 &nbsp;05/14/2008 &nbsp;03:10:38 PM<br />
extracing: default:<br />
&nbsp;data from 0x3611ecd4e to 0x3611f2d4e<br />
length &nbsp;24576 &nbsp;atrib 0x20 &nbsp;06/29/2009 &nbsp;09:42:50 PM<br />
extracing: SAM:<br />
&nbsp;data from 0x3611f3156 to 0x3611fe156<br />
length &nbsp;45056 &nbsp;atrib 0x20 &nbsp;06/29/2009 &nbsp;11:00:07 PM<br />
extracing: SECURITY:<br />
&nbsp;data from 0x3611fe556 to 0x3621cb556<br />
length 16568320 &nbsp;atrib 0x20 &nbsp;06/30/2009 &nbsp;01:35:59 AM<br />
extracing: software:<br />
&nbsp;data from 0x3621cb952 to 0x362487952<br />
length 2867200 &nbsp;atrib 0x20 &nbsp;06/29/2009 &nbsp;10:42:23 PM<br />
extracing: system:<br />
&nbsp;data from 0x362487d2e to 0x3624aad2e<br />
length 143360 &nbsp;atrib 0x20 &nbsp;06/04/2003 &nbsp;01:24:14 PM<br />
extracing: userdiff:</div></div>
<p>Bingo, I can load the <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">software</span> hive with &#8220;reg load&#8221; (see <a href="http://www.petri.co.il/reg_command_in_windows_xp.htm">here</a>) and extract the keys I need.</p>
<p>Should you prefer so, download <a href="http://gpl.internetconnection.net/files/mtftar.tar.gz">mtftar</a> on your Linux box, compile it and run something like:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">./mtftar -f /mnt/storagespace/temp/backup.bkf | tar xvf - &quot;Registry&quot;</div></div>
<p>Extract the other files you need and voilà&#8230;</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-539-1'>ex Veritas Backup Exec <span class='footnotereverse'><a href='#fnref-539-1'>&#8617;</a></span></li>
<li id='fn-539-2'>There&#8217;s no executable in the archive. You need Visual Studio and compile it for yourself. <span class='footnotereverse'><a href='#fnref-539-2'>&#8617;</a></span></li>
</ol>
</div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=539" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/recovering-ntbackup-tapes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counting received emails on MS Exchange</title>
		<link>http://www.108.bz/posts/it/counting-received-emails-on-ms-exchange/</link>
		<comments>http://www.108.bz/posts/it/counting-received-emails-on-ms-exchange/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 13:23:46 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[MS Exchange]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=340</guid>
		<description><![CDATA[Today I was asked to count the number of emails received on a given address (more than one), across a given time frame. I ended up using Microsoft&#8217;s Log Parser (the existence of which I discovered thanks to this post). Log Parser let&#8217;s you run SQL queries on a range of differently formatted log files. [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was asked to count the number of emails received on a given address (more than one), across a given time frame. I ended up using Microsoft&#8217;s <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&#038;displaylang=en">Log Parser</a> (the existence of which I discovered thanks to <a href="http://msexchangetips.blogspot.com/2006/09/exchange-exporting-and-querying.html">this</a> post).<br />
Log Parser let&#8217;s you run SQL queries on a range of differently formatted log files. Pretty handy stuff: I&#8217;ll surely find other uses for it.</p>
<p>MS Exchange, when Message Tracking is <a href="http://www.msexchange.org/tutorials/Exchange-2003-Message-Tracking-Logging.html">enabled</a>, generates a bunch of log files into something like a <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">C:\Exchsrvr\SERVERNAME.log\</span> folder. The data we need is tracked there.</p>
<div class="codecolorer-container text blackboard" style="border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">logparser -q -i:w3c -o:tsv -headers OFF &quot;SELECT DISTINCT MSGID, To_Lowercase(Recipient-Address) As dst FROM C:\Exchsrvr\SERVERNAME.log\*.log WHERE dst = 'addr1@domain.com' OR dst = 'addr2@domain.com'&quot; &gt; x.tsv</div></div>
<p>&#8220;-q&#8221; stands for &#8220;quiet&#8221;, &#8220;-i:w3c&#8221; states that the input log(s) are in W3C format, &#8220;-o:tsv&#8221; tells Log Parser to output tab-separated fields, &#8220;-headers OFF&#8221; is self explanatory and then comes the SQL query. I&#8217;m selecting distinct combinations of <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">MSGID</span> and <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Recipient-Address</span>. Distinct because info about an email message is stored in the log files across multiple lines, keyed by MSGID. A single query is enough to filter all of the addresses we&#8217;re interested in, ORed together. Also notice that in the SQL &#8220;FROM&#8221; clause I used &#8220;*.log&#8221;; you may need to change that to suit your time frame (message tracking logs are switched daily and stored for a configurable amount of days).</p>
<p>Log Parser&#8217;s output, redirected to a file, is then fed to cut/sort/uniq. Remember to change the line termination sequence (&#8220;:set fileformat=unix&#8221;, on vim) if you don&#8217;t have the afore mentioned commands on Windows and move the file to a Unix box.</p>
<p>We use <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">cut</span> (which defaults to tab separated fields) to trash MSGID and just select recipients addresses. These ones get sorted and counted. Last step is a reverse numerical sort. This kind of pipe sequence is a rather common &#8220;idiom&#8221; on Unix: it computes word (record) frequencies in a file.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cut -f 2 x.tsv | sort | uniq -c | sort -n -r<br />
&nbsp; &nbsp; 782 addr1@domain.com<br />
&nbsp; &nbsp; 747 addr2@domain.com</div></div>
<p>Phew, no lines of script written for once&#8230; <img src='http://www.108.bz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=340" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/counting-received-emails-on-ms-exchange/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detecting malware using Windows Auditing events</title>
		<link>http://www.108.bz/posts/it/detecting-malware-using-windows-auditing-events/</link>
		<comments>http://www.108.bz/posts/it/detecting-malware-using-windows-auditing-events/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 23:58:18 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=314</guid>
		<description><![CDATA[This post1 explains how to use nmap and smb-check-vulns to scan a network in search of Conficker infected hosts. I thought that the whole Conficker case was over, but hopefully some of the measures I took to deal with it almost an year ago, will still be relevant to other kinds of malware. And, also, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.disordine.com/2010/02/11/come-cercare-luntore-nella-propria-rete/">This</a> post<sup class='footnote'><a href='#fn-314-1' id='fnref-314-1'>1</a></sup> explains how to use nmap and smb-check-vulns to scan a network in search of <a href="http://en.wikipedia.org/wiki/Conficker">Conficker</a> infected hosts. I thought that the whole Conficker case was over, but hopefully some of the measures I took to deal with it almost an year ago, will still be relevant to other kinds of malware. And, also, the method I&#8217;ll show you here differs from the nmap one in that the latter is active, whereas mine is passive. Actively probing an host for vulnerabilities could be very very much alike &#8220;exploiting&#8221; it as malware does, and have similar effects. For instance, a service/process could crash, making it not always advisable to run active scans on your servers subnet. Passive analysis, on the other hand, unobtrusively collects clues about who&#8217;s misbehaving. </p>
<p>During the Conficker/Downadup outburst, we observed that:</p>
<ul>
<li>Antivirus wasn&#8217;t always able to detect/stop it.</li>
<li>The virus was copying files in known directories (<span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">C:\WINDOWS\SYSTEM32</span>) on about to be infected machines.</li>
<li>Security patched hosts were still subject to the remote malicious file copying routine. The copy could either succeed or fail, depending on which permissions had the user that &#8220;runs&#8221; the virus. The copy in itself doesn&#8217;t pose any security concern. Even if no A/V is active on the destination host, but virus exploitable flaws have been patched, malware won&#8217;t be able to activate itself. Otherwise, the A/V would remove suspect files as soon as they are caught, without interfering with our detection purposes.</li>
</ul>
<p>This behaviour makes it possible to use a &#8220;honeypot&#8221; approach. The detecting server can be any production host provided that it is security patched and A/V protected. You could, as we did, choose a Domain Controller and: </p>
<ul>
<li>Run <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Administrative Tools</span> &rarr; <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Domain Controller Security Policy</span></li>
<p><a href="http://www.108.bz/wp-content/uploads/2010/03/detectingmalware1.gif"><img src="http://www.108.bz/wp-content/uploads/2010/03/detectingmalware1.gif" alt="" title="detectingmalware1" width="429" height="44" class="alignnone size-full wp-image-322" /></a></p>
<li>Modify the Audit Policy, enabling tracking of successful <i>logon events</i> and <i>object access</i>. By default the OS will only log <i>failures</i>, but that&#8217;s not enough.</li>
<p><a href="http://www.108.bz/wp-content/uploads/2010/03/detectingmalware21.gif"><img src="http://www.108.bz/wp-content/uploads/2010/03/detectingmalware21.gif" alt="" title="detectingmalware2" width="562" height="180" class="alignnone size-full wp-image-329" /></a></p>
<li><i>Object Access</i> is activated at a file/directory level. Open up the Properties of a directory you know is accessed by the virus, click on <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Security</span>, then <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Advanced</span>. The <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Auditing</span> tab is what you&#8217;re interested in. Set things up so that any &#8220;Create File/Write Data&#8221; attempt of Type &#8220;Success&#8221; will be logged. The semantics about how auditing settings are propagated from parent to child works in the same way as NFTS permissions.</li>
<p><a href="http://www.108.bz/wp-content/uploads/2010/03/detectingmalware3.gif"><img src="http://www.108.bz/wp-content/uploads/2010/03/detectingmalware3.gif" alt="" title="detectingmalware3" width="549" height="465" class="alignnone size-full wp-image-324" /></a></p>
<li>From this point on, you should monitor the honeypot server&#8217;s Security Event Log. I wrote a Perl script to do it for me. It works by selecting events with ID 560 and 540, extracting their text and printing just the needed info.</li>
</ul>
<p>Let&#8217;s look at how it&#8217;s used (the only parameter is the hostname/address of the honeypot server):</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\loganalysis&gt;perl ddloganalysis.pl honeypot-srv.domain.lan &gt; ddlog.txt</div></div>
<p>Skimming through the generated log, you&#8217;ll notice the files being dropped into <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">C:\WINDOWS\system32</span> (or any directory you set up for auditing), the user that actually created them and, before (time-wise), from which address the user is coming.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">17/03/2009 16.26.19 &nbsp; 560 : C:\WINDOWS\system32\onevthx.vr (Administrator)<br />
17/03/2009 16.26.18 &nbsp; 540 : &nbsp;(10.1.1.94 - Administrator)<br />
17/03/2009 15.35.24 &nbsp; 560 : C:\WINDOWS\system32\onevthx.vr (SpectrumLT)<br />
17/03/2009 15.35.24 &nbsp; 540 : &nbsp;(10.6.3.6 - SpectrumLT)</div></div>
<p>We successfully used the script to pinpoint the rogue hosts. Deeming it useful, here it is:</p>
<div class="codecolorer-container perl blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!perl</span><br />
<br />
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> Win32<span style="color: #339933;">::</span><span style="color: #006600;">EventLog</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">use</span> POSIX <a href="http://perldoc.perl.org/functions/qw.html"><span style="color: #000066;">qw</span></a> <span style="color: #009900;">&#40;</span> strftime <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@matches</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#'job$', &nbsp; # useless, since scheduled tasks are always created by SYSTEM</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">'system32'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">'eicar.com'</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;Usage:<span style="color: #000099; font-weight: bold;">\n</span>$0 servername&quot;</span> <span style="color: #b1b100;">unless</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ev</span><span style="color: #339933;">=</span>Win32<span style="color: #339933;">::</span><span style="color: #006600;">EventLog</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'Security'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;Can't open EventLog<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$recs</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$ev</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">GetNumber</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$recs</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;Can't get number of EventLog records<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$base</span><span style="color: #339933;">;</span><br />
<span style="color: #0000ff;">$ev</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">GetOldest</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$base</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;Can't get number of oldest EventLog record<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">sub</span> getts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/return.html"><span style="color: #000066;">return</span></a> strftime <span style="color: #ff0000;">'%d/%m/%Y %H.%M.%S'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/localtime.html"><span style="color: #000066;">localtime</span></a> <a href="http://perldoc.perl.org/functions/shift.html"><span style="color: #000066;">shift</span></a><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@progress</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'-'</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\'</span>,'</span><span style="color: #339933;">|</span><span style="color: #ff0000;">','</span><span style="color: #339933;">/</span><span style="color: #ff0000;">','</span><span style="color: #339933;">-</span><span style="color: #ff0000;">','</span>\<span style="color: #ff0000;">','</span><span style="color: #339933;">|</span><span style="color: #ff0000;">','</span><span style="color: #339933;">/</span><span style="color: #ff0000;">');<br />
<br />
my $x = $recs-1;<br />
my $h;<br />
while ($x &gt;= 0) {<br />
&nbsp; &nbsp; $ev-&gt;Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,<br />
&nbsp; &nbsp; &nbsp; &nbsp; $base + $x,<br />
&nbsp; &nbsp; &nbsp; &nbsp; $h)<br />
&nbsp; &nbsp; &nbsp; &nbsp; or die &quot;Can'</span>t <a href="http://perldoc.perl.org/functions/read.html"><span style="color: #000066;">read</span></a> EventLog entry <span style="color: #666666; font-style: italic;">#$x\n&quot;;</span><br />
&nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #0000ff;">$progress</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$#progress</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$x</span> <span style="color: #339933;">%</span> <span style="color: #0000ff;">@progress</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>Source<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">eq</span> <span style="color: #ff0000;">'Security'</span> <span style="color: #b1b100;">and</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>EventID<span style="color: #009900;">&#125;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">560</span> <span style="color: #b1b100;">or</span> <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>EventID<span style="color: #009900;">&#125;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">540</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Win32<span style="color: #339933;">::</span><span style="color: #006600;">EventLog</span><span style="color: #339933;">::</span><span style="color: #006600;">GetMessageText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>EventID<span style="color: #009900;">&#125;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">560</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>Message<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/Object Name:[\t ]*(.*?)\r/gis</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>Message<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/Client User Name:[\t ]*(.*?)\r/gis</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$clientusername</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/grep.html"><span style="color: #000066;">grep</span></a> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$m</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$filename</span> <span style="color: #339933;">=~</span> <span style="color: #339933;">/</span><span style="color: #0000ff;">$m</span><span style="color: #339933;">/</span>i<span style="color: #009900;">&#125;</span> <span style="color: #0000ff;">@matches</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #ff0000;">&quot;%s %5d : %s (%s)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> getts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>TimeGenerated<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>EventID<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$filename</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$clientusername</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>EventID<span style="color: #009900;">&#125;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">540</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>Message<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/User Name:[\t ]*(.*?)\r/gis</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>Message<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/Workstation Name:[\t ]*(.*?)\r/gis</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$workstation</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>Message<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/Source Network Address:[\t ]*(.*?)\r/gis</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$addr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #ff0000;">&quot;%s %5d : %s (%s - %s)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> getts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>TimeGenerated<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$h</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>EventID<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$workstation</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$addr</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$username</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$workstation</span> <span style="color: #b1b100;">or</span> <span style="color: #0000ff;">$addr</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">$x</span><span style="color: #339933;">--;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span></div></div>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-314-1'>In italian, sorry. Look <a href="http://jahboite.co.uk/blog/2009/03/nmap-4-85beta5-and-conficker.html">here</a> for an english equivalent and <a href="http://nmap.org/nsedoc/scripts/smb-check-vulns.html">here</a> for more info. <span class='footnotereverse'><a href='#fnref-314-1'>&#8617;</a></span></li>
</ol>
</div>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=314" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/detecting-malware-using-windows-auditing-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shared folder access from Windows CE</title>
		<link>http://www.108.bz/posts/it/shared-folder-access-from-windows-ce/</link>
		<comments>http://www.108.bz/posts/it/shared-folder-access-from-windows-ce/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 16:30:14 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Weirdnesses]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows CE]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=223</guid>
		<description><![CDATA[Scenario: Headquarter (HQ) connected (MPLS VPN) to some branch sites. In some of the branches, a Check Point UTM-1 Edge X (SofaWare) sits between the wireless and wired networks, enforcing security policies between them. The two networks are bridged together (Layer 2) by the firewall. The wireless LAN is used by some kind of next [...]]]></description>
			<content:encoded><![CDATA[<p>Scenario:
<ul>
<li>Headquarter (HQ) connected (MPLS VPN) to some branch sites.</li>
<li>In some of the branches, a Check Point UTM-1 Edge X (SofaWare) sits between the wireless and wired networks, enforcing security policies between them.</li>
<li>The two networks are bridged together (Layer 2) by the firewall.</li>
<li>The wireless LAN is used by some kind of next gen Barcode Scanner: an embedded device with Windows CE .NET 4.2, also able to act as a Terminal Services client.</li>
</ul>
<p>Customer wants to install some software on the scanners, downloading it from a shared folder residing on one of HQ servers. I add the necessary (and temporary) rules on the firewalls, but the folder still cannot be reached. Windows CE complains that &#8220;The network path was not found&#8221; but the rules look good.</p>
<p>Luckily, the Edge firewalls provide a packet sniffer, allowing us to further investigate the issue. Just connect to the web based interface of UTM-1/SofaWare, go to <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Setup</span> &rarr; <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Tools</span> &rarr; <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">Sniffer</span>, choose a filter string (using the familiar libpcap/tcpdump syntax), select the interface (&#8220;bridge&#8221;, in my case), and you&#8217;re set. Captured packets can then be downloaded to your PC and opened up in Wireshark.</p>
<p>We came up with a bunch of peculiar NetBIOS Name query requests/answers:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ tshark -r sniffer4.cap <br />
&nbsp; 1 &nbsp; 0.000000 &nbsp; &nbsp;192.168.2.3 &nbsp;-&gt; 192.168.1.10 &nbsp;NBNS Name query NB HQSERVER&lt;20&gt;<br />
&nbsp; 2 &nbsp; 0.028436 &nbsp; &nbsp;192.168.1.10 -&gt; 192.168.2.3 &nbsp; NBNS Name query response<br />
&nbsp; 3 &nbsp; 1.001397 &nbsp; &nbsp;192.168.2.3 &nbsp;-&gt; 192.168.2.255 NBNS Name query NB HQSERVER&lt;20&gt;<br />
&nbsp; 4 &nbsp; 1.251460 &nbsp; &nbsp;192.168.2.3 &nbsp;-&gt; 192.168.2.255 NBNS Name query NB HQSERVER&lt;20&gt;<br />
&nbsp; 5 &nbsp; 1.502820 &nbsp; &nbsp;192.168.2.3 &nbsp;-&gt; 192.168.2.255 NBNS Name query NB HQSERVER&lt;20&gt;</div></div>
<p>Some hostnames, for clarity:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; 192.168.2.3 &nbsp;: BOSCANNER<br />
&nbsp; 192.168.1.10 : HQDC1<br />
&nbsp; 192.168.1.20 : HQSERVER</div></div>
<p>The Barcode Scanner (Client) asks one of the DNS/Domain Controllers in HQ if it is called HQSERVER. But HQSERVER is the server we&#8217;re trying to connect to from the Scanner (by means of <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">\\HQSERVER\sharename</span>)! Why in the world the device should directly ask HQDC1 if it is called HQSERVER? Using an unicast NetBIOS query, too? Obviously HQDC1 answers &#8220;no, it&#8217;s not me&#8221; (Requested name does not exist)&#8230; The Scanner then broadcasts the same query to its local network segment, but since HQSERVER sits in Headquarter, it gets no answer and generates the error &#8220;The network path was not found&#8221;.<br />
Turns out that <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">\\192.168.1.20\sharename</span> causes the same dialoque, with a NetBIOS name query that seemingly asks for a server named &#8220;192.168.1.20&#8243;. It&#8217;s as if in Windows CE, UNC paths could only use names, not IP addresses.</p>
<p>Well, the Customer didn&#8217;t have enough time for me to properly solve/understand the issue but we worked around it by:
<ul>
<li>Assigning a static IP to the Windows CE device.</li>
<li>In the TCP/IP settings of Windows CE, use 192.168.1.20 (HQSERVER &#8211; where the shared folder is hosted) as DNS and WINS server.</li>
<li>Copy the needed files from the network share and revert back to DHCP.</li>
</ul>
<p>Step two makes the Client send NetBIOS name queries to HQSERVER instead of HQDC1. This allows shared folder access to work.</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=223" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/shared-folder-access-from-windows-ce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Executing processes as the SYSTEM user</title>
		<link>http://www.108.bz/posts/it/executing-processes-as-the-system-user/</link>
		<comments>http://www.108.bz/posts/it/executing-processes-as-the-system-user/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 22:05:08 +0000</pubDate>
		<dc:creator>Giuliano</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[OS Internals]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.108.bz/?p=179</guid>
		<description><![CDATA[On MS Windows operating systems, many processes run under the NT AUTHORITY\SYSTEM account, be them scheduled tasks or services. Sometimes it&#8217;s useful to run cmd.exe as the SYSTEM user and see what&#8217;s going on. Here&#8217;s a nifty trick to do it. C:\Documents and Settings\giuliano&#62;time /t 17:10 C:\Documents and Settings\giuliano&#62;at 17:11 /interactive cmd.exe Added a new [...]]]></description>
			<content:encoded><![CDATA[<p>On MS Windows operating systems, many processes run under the <em>NT AUTHORITY\SYSTEM</em> account, be them scheduled tasks or services.<br />
Sometimes it&#8217;s useful to run <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">cmd.exe</span> as the <em>SYSTEM</em> user and see what&#8217;s going on. Here&#8217;s a nifty trick to do it.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Documents and Settings\giuliano&gt;time /t<br />
17:10<br />
<br />
C:\Documents and Settings\giuliano&gt;at 17:11 /interactive cmd.exe<br />
Added a new job with job ID = 1<br />
<br />
C:\Documents and Settings\giuliano&gt;</div></div>
<p>Basically you check what time it is and schedule <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">cmd.exe</span> to run on the next minute. You do that by means of the <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;"><a href="http://technet.microsoft.com/en-us/library/bb490866.aspx">at.exe</a></span> OS command.</p>
<p>When the time comes, a Command Prompt window should pop-up. It runs under the <em>SYSTEM</em> account:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Microsoft Windows [Version 5.2.3790]<br />
(C) Copyright 1985-2003 Microsoft Corp.<br />
<br />
C:\WINDOWS\system32&gt;whoami<br />
nt authority\system<br />
<br />
C:\WINDOWS\system32&gt;</div></div>
<p>Each process you run from there, also runs as <em>SYSTEM</em>. If you run <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">regedit.exe</span>, for instance, you can import registry data into the <em>SYSTEM</em> user&#8217;s hive. Today I used this tecnique to export/import Putty&#8217;s settings (they are stored in the registry) in order to make <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;"><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">plink.exe</a></span>, as run from a UPS monitoring Agent, see a pre-configured SSH &#8220;Session&#8221; (hostname, login username, private key, &#8230;). I needed the Agent to shut down a bunch of Linux servers when the battery charge was running low: <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">plink.exe</span> on Windows side and <span style="font-family: Bitstream Vera Sans Mono,Courier New,monospace;">sudo</span> on the Linux one, did the job.</p>
<p>For completness sake, <a href="http://verbalprocessor.com/2007/12/05/running-a-cmd-prompt-as-local-system/">here</a>&#8216;s a post on the same subject. It also deals about Vista/Windows Server 2008 and how to achieve our goal using <a href="http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx">PsExec</a>.</p>
 <img src="http://www.108.bz/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=179" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.108.bz/posts/it/executing-processes-as-the-system-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

