<?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>Rickey Whitworth&#039;s Blog &#187; Code Sample</title>
	<atom:link href="http://www.whitworth.org/category/code-sample/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whitworth.org</link>
	<description>insights from managing a microsoft enterprise infrastructure</description>
	<lastBuildDate>Tue, 22 Jun 2010 17:12:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Baby Smash! by Scott Hanselman</title>
		<link>http://www.whitworth.org/2009/09/08/baby-smash-by-scott-hanselman/</link>
		<comments>http://www.whitworth.org/2009/09/08/baby-smash-by-scott-hanselman/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 20:07:05 +0000</pubDate>
		<dc:creator>rwhitworth</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/2009/09/08/baby-smash-by-scott-hanselman/</guid>
		<description><![CDATA[&#160;
As babies smash on the keyboard, colored shapes, letters and numbers appear on the screen. Baby Smash will lock out the Windows Key, as well as Ctrl-Esc and Alt-Tab so your baby can&#8217;t get out of the application. Pressing ALT-F4 will exit the application and Shift-Ctrl-Alt-O brings up the options dialog. I&#8217;m always interested in [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<blockquote><p>As babies smash on the keyboard, colored shapes, letters and numbers appear on the screen. Baby Smash will lock out the Windows Key, as well as Ctrl-Esc and Alt-Tab so your baby can&#8217;t get out of the application. Pressing ALT-F4 will exit the application and Shift-Ctrl-Alt-O brings up the options dialog. I&#8217;m always interested in your <a href="http://feedback.babysmash.com/">feedback</a> as well!</p>
<p>I wrote BabySmash! for my 2 year old and 5 month old so they could bang on the keyboards of my Windows machines without hurting anything. It&#8217;s a copy/homage of the very fine and free <a href="http://alphababy.sourceforge.net/">AlphaBaby</a> for the Macintosh. BabySmash is <i>free</i> also and the source code is available on <a href="http://www.hanselman.com/blog">my blog</a> soon. Enjoy! <img src='http://www.whitworth.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</blockquote>
<p><a href="http://www.hanselman.com/babysmash/index.htm">Baby Smash! by Scott Hanselman</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2009/09/08/baby-smash-by-scott-hanselman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launching and Monitoring External Programs from VB.NET Applications</title>
		<link>http://www.whitworth.org/2007/10/16/launching-and-monitoring-external-programs-from-vbnet-applications/</link>
		<comments>http://www.whitworth.org/2007/10/16/launching-and-monitoring-external-programs-from-vbnet-applications/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 23:31:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/Blog/PermaLink,guid,75d84046-7c09-4be0-949e-fb201618aa18.aspx</guid>
		<description><![CDATA[
&#160;



With .NET things have gotten much simpler. The System.Diagnostics namespace exposes
a Process class that you can use to launch external programs. At the simplest level,
you can launch a new process with the shared Process.Start method, passing it either
the name of an executable file or a filename with an extension associated with an
executable application. For example, [...]]]></description>
			<content:encoded><![CDATA[<p>
&nbsp;
</p>
<blockquote>
<p>
With .NET things have gotten much simpler. The System.Diagnostics namespace exposes<br />
a Process class that you can use to launch external programs. At the simplest level,<br />
you can launch a new process with the shared Process.Start method, passing it either<br />
the name of an executable file or a filename with an extension associated with an<br />
executable application. For example, the following code launches the &#8220;c:somepathsomefile.txt&#8221;
<pre><code> System.Diagnostics.Process.Start
_ ("c:somepathsomefile.txt") </code></pre>
</blockquote>
<p>
<a href="http://www.devx.com/dotnet/Article/7914/1954?pf=true">Launching and Monitoring<br />
External Programs from VB.NET Applications</a>
</p>
<p><img width="0" height="0" src="http://www.whitworth.org/Blog/aggbug.ashx?id=75d84046-7c09-4be0-949e-fb201618aa18" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2007/10/16/launching-and-monitoring-external-programs-from-vbnet-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating Visio 2007 and Active Directory</title>
		<link>http://www.whitworth.org/2007/01/30/integrating-visio-2007-and-active-directory/</link>
		<comments>http://www.whitworth.org/2007/01/30/integrating-visio-2007-and-active-directory/#comments</comments>
		<pubDate>Tue, 30 Jan 2007 22:37:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[Visio]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/Blog/PermaLink,guid,dbf18f65-88ea-4ce0-a88b-79702de8e5ff.aspx</guid>
		<description><![CDATA[Cool article that demonstrates several concepts in programming Visio 2007. This sample
uses a template, connects to Active Directory based on input from the user, dynamically
populates a drawing with user objects, dynamically fills in custom properties like
ldap path for each user object, displays different icons if a user is disabled or
locked out, and gives some right [...]]]></description>
			<content:encoded><![CDATA[<p>Cool article that demonstrates several concepts in programming Visio 2007. This sample<br />
uses a template, connects to Active Directory based on input from the user, dynamically<br />
populates a drawing with user objects, dynamically fills in custom properties like<br />
ldap path for each user object, displays different icons if a user is disabled or<br />
locked out, and gives some right click menu options like reset password and disable<br />
account.</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/bb245820.aspx">http://msdn2.microsoft.com/en-us/library/bb245820.aspx</a></p>
<p> </p>
<p><img src="http://www.whitworth.org/Blog/aggbug.ashx?id=dbf18f65-88ea-4ce0-a88b-79702de8e5ff" alt="" width="0" height="0" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2007/01/30/integrating-visio-2007-and-active-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add static items and results from data binding to a DropDownList control by using Visual Basic .NET</title>
		<link>http://www.whitworth.org/2006/06/02/how-to-add-static-items-and-results-from-data-binding-to-a-dropdownlist-control-by-using-visual-basic-net/</link>
		<comments>http://www.whitworth.org/2006/06/02/how-to-add-static-items-and-results-from-data-binding-to-a-dropdownlist-control-by-using-visual-basic-net/#comments</comments>
		<pubDate>Fri, 02 Jun 2006 18:36:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/Blog/PermaLink,guid,c697459d-050a-4fe2-b6d8-5c448a28e9ec.aspx</guid>
		<description><![CDATA[
An example of mixing static items and databound items in a drop down list.



This article demonstrates how to add static items and data-bound items to a DropDownList
control. The sample in this article populates a DropDownList control with an initial
item.



How
to add static items and results from data binding to a DropDownList control by using
Visual Basic .NET.


]]></description>
			<content:encoded><![CDATA[<p>
An example of mixing static items and databound items in a drop down list.
</p>
<blockquote cite="http://support.microsoft.com/?kbid=314334">
<p>
<em>This article demonstrates how to add static items and data-bound items to a DropDownList<br />
control. The sample in this article populates a DropDownList control with an initial<br />
item.</em>
</p>
</blockquote>
<p class="citation">
<cite cite="http://support.microsoft.com/?kbid=314334"><a href="http://support.microsoft.com/?kbid=314334">How<br />
to add static items and results from data binding to a DropDownList control by using<br />
Visual Basic .NET</a></cite>.
</p>
<p><img width="0" height="0" src="http://www.whitworth.org/Blog/aggbug.ashx?id=c697459d-050a-4fe2-b6d8-5c448a28e9ec" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2006/06/02/how-to-add-static-items-and-results-from-data-binding-to-a-dropdownlist-control-by-using-visual-basic-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get the creation date for users from Active Directory</title>
		<link>http://www.whitworth.org/2006/03/03/get-the-creation-date-for-users-from-active-directory/</link>
		<comments>http://www.whitworth.org/2006/03/03/get-the-creation-date-for-users-from-active-directory/#comments</comments>
		<pubDate>Fri, 03 Mar 2006 16:46:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Network Administration]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/Blog/PermaLink,guid,36e4282a-3eaf-48a3-8ef1-9e975bf1476e.aspx</guid>
		<description><![CDATA[
This sample connects to active directory and retrieves the name and createTimeStamp
field for every user in a given OU or Container (and subcontainers).&#160; You will
need to change the ContainerPath variable to an appropriate value for your domain.
If you are binding to the builtin users container in Active Directory use a path like:


LDAP://CN=Users,DC=subdomain,DC=domain,DC=com


If you are binding [...]]]></description>
			<content:encoded><![CDATA[<p>
This sample connects to active directory and retrieves the name and createTimeStamp<br />
field for every user in a given OU or Container (and subcontainers).&nbsp; You will<br />
need to change the ContainerPath variable to an appropriate value for your domain.<br />
If you are binding to the builtin users container in Active Directory use a path like:
</p>
<p>
LDAP://CN=Users,DC=subdomain,DC=domain,DC=com
</p>
<p>
If you are binding to an OU, use a path like
</p>
<p>
LDAP://OU=Employees,DC=subdomain,DC=domain,DC=com
</p>
<p>
<span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Imports</span> System.DirectoryServices</p>
<p><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> GetCreationDate()<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> ContainerPath <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;LDAP://CN=Users,DC=subdomain,DC=domain,DC=com&#8221;</span><br />
<br />
Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;Start&#8221;</span>)<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> searcher <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DirectorySearcher<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> results <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> SearchResultCollection<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> searchRoot <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DirectoryEntry(ContainerPath)<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br />
<br />
searcher <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DirectorySearcher(searchRoot)<br />
searcher.PropertiesToLoad.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Add</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;createTimeStamp&#8221;</span>)<br />
searcher.PropertiesToLoad.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Add</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;cn&#8221;</span>)<br />
searcher.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Filter</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;(&amp;(objectClass=user)(objectCategory=person))&#8221;</span><br />
<br />
results <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> searcher.FindAll</p>
<p>Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;Users<br />
Found: &#8220;</span> &amp; results.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Count</span>)</p>
<p><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&#8216;<br />
These two variables will hold the values found</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> createTime <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;&#8221;</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> cname <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;&#8221;</span></p>
<p><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&#8216;<br />
Loop through each entry in the result collection and</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&#8216;<br />
write the name and createTimeStamp value</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">For</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Each</span> result <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> SearchResult <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">In</span> results<br />
<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&#8216;<br />
Get the value currently stored for createTimeStamp</span><br />
<br />
createTime <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> result.Properties(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;createTimeStamp&#8221;</span>)(0)</p>
<p><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&#8216;<br />
Get the value currently stored for name</span><br />
<br />
cname <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> result.Properties(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;cn&#8221;</span>).<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Item</span>(0).ToString</p>
<p>Console.WriteLine(cname.PadLeft(40) &amp; ControlChars.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Tab</span> &amp;<br />
createTime.PadLeft(12))<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Next</span><br />
<br />
Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;Complete&#8221;</span>)<br />
Console.ReadLine()<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> ex <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception<br />
Console.WriteLine(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;Error:<br />
&#8220;</span> &amp; ex.Message)<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br />
<br />
</span>
</p>
<p><img width="0" height="0" src="http://www.whitworth.org/Blog/aggbug.ashx?id=36e4282a-3eaf-48a3-8ef1-9e975bf1476e" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2006/03/03/get-the-creation-date-for-users-from-active-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Sample: Retrieving all users in an OU</title>
		<link>http://www.whitworth.org/2006/02/15/code-sample-retrieving-all-users-in-an-ou/</link>
		<comments>http://www.whitworth.org/2006/02/15/code-sample-retrieving-all-users-in-an-ou/#comments</comments>
		<pubDate>Wed, 15 Feb 2006 22:57:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/Blog/PermaLink,guid,06efcda9-7fe5-49e3-adc0-a17a722efa94.aspx</guid>
		<description><![CDATA[
Using Directory Searcher. This sample shows how to get the results back quickly using
only the directorysearcher without binding to each individual directoryEntry. To do
this you must specify the properties you want to load before doing the search.


Dim searcher As DirectorySearcher
Dim results As SearchResultCollection
Dim searchRoot As New DirectoryEntry(&#8220;LDAP://CN=Users,DC=mytest,DC=whitworth,DC=org&#8221;)
searcher = New DirectorySearcher(searchRoot)
searcher.PropertiesToLoad.Add(&#8220;telephoneNumber&#8221;)
searcher.PropertiesToLoad.Add(&#8220;cn&#8221;)
searcher.Filter = &#8220;(&#38;(objectClass=user)(objectCategory=person))&#8221;

results = searcher.FindAll
dim result [...]]]></description>
			<content:encoded><![CDATA[<p>
Using Directory Searcher. This sample shows how to get the results back quickly using<br />
only the directorysearcher without binding to each individual directoryEntry. To do<br />
this you must specify the properties you want to load before doing the search.
</p>
<p>
<span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> searcher <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> DirectorySearcher<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> results <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> SearchResultCollection<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> searchRoot <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DirectoryEntry(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;LDAP://CN=Users,DC=mytest,DC=whitworth,DC=org&#8221;</span>)<br />
searcher <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> DirectorySearcher(searchRoot)<br />
searcher.PropertiesToLoad.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Add</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;telephoneNumber&#8221;</span>)<br />
searcher.PropertiesToLoad.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Add</span>(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;cn&#8221;</span>)<br />
searcher.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Filter</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;(&amp;(objectClass=user)(objectCategory=person))&#8221;</span><br />
<br />
results <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> searcher.FindAll</p>
<p><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">dim</span> result <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> SearchResult<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">dim</span> entryName <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;&#8221;</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">dim</span> entryTelephone <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;&#8221;</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">each</span> result <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> results<br />
entryName <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> result.properties(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;cn&#8221;</span>)(0).tostring</p>
<p><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span> result.Properties(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;telephoneNumber&#8221;</span>).<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Count</span> <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">then</span><br />
<br />
entryTelephone <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> result.properties(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;telephoneNumber&#8221;</span>)(0).tostring<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
<br />
entryTelephone <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;Empty&#8221;</span><br />
<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">end</span> <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span></p>
<p>debug.writeline(entryName &amp; vbTab &amp; entryTelephone)<br />
<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">next</span><br />
<br />
debug.writeline(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">&#8220;Complete&#8221;</span>)</span>
</p>
<p><img width="0" height="0" src="http://www.whitworth.org/Blog/aggbug.ashx?id=06efcda9-7fe5-49e3-adc0-a17a722efa94" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2006/02/15/code-sample-retrieving-all-users-in-an-ou/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.473 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-08 07:04:07 -->
