<?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>redaware &#187; Windows 2003 Server</title>
	<atom:link href="http://www.redaware.net/tag/windows-2003-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redaware.net</link>
	<description></description>
	<lastBuildDate>Wed, 16 Jun 2010 15:15:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>VB.NET: Retrieving Active Directory account properties</title>
		<link>http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/</link>
		<comments>http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 08:22:24 +0000</pubDate>
		<dc:creator>tsymonds</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Windows 2003 Server]]></category>

		<guid isPermaLink="false">http://www.redaware.net/?p=61</guid>
		<description><![CDATA[The .NET Framework includes an API called System.DirectoryServices. The sample VB.NET code below shows how to retrieve user account properties from the Active Directory. In order to use System.DirectoryServices classes, you will need to first add a reference to System.DirectoryServices. Imports System.DirectoryServices is required at the very top of your VB.NET code. Function GetUserProperties&#40;ByVal GetUser, [...]]]></description>
			<content:encoded><![CDATA[<p>The .NET Framework includes an API called System.DirectoryServices. The sample VB.NET code below shows how to retrieve user account properties from the Active Directory.</p>
<p>In order to use System.DirectoryServices classes, you will need to first add a reference to <strong>System.DirectoryServices</strong>. </p>
<p><strong>Imports System.DirectoryServices</strong> is required at the very top of your VB.NET code.</p>
<div class="codecolorer-container vbnet default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="vbnet codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">Function</span> GetUserProperties<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> GetUser, <span style="color: #FF8000;">ByVal</span> Result<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> objSearch <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> DirectorySearcher<br />
&nbsp; &nbsp; &nbsp; &nbsp; objSearch.<span style="color: #0000FF;">SearchRoot</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> DirectoryEntry<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;LDAP://dc=domain,dc=co,dc=uk&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; objSearch.<span style="color: #0600FF;">Filter</span> <span style="color: #008000;">=</span> GetUser<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">'cn = Full Name, givenName = First name, initials = Middle names, sn = Surname, mail = email address</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; objSearch.<span style="color: #0000FF;">PropertiesToLoad</span>.<span style="color: #0000FF;">AddRange</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">New</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #808080;">&quot;cn&quot;</span>, <span style="color: #808080;">&quot;giveName&quot;</span>, <span style="color: #808080;">&quot;initials&quot;</span>, <span style="color: #808080;">&quot;sn&quot;</span>, <span style="color: #808080;">&quot;department&quot;</span>, <span style="color: #808080;">&quot;mail&quot;</span>, <span style="color: #808080;">&quot;Manager&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">Dim</span> objResult <span style="color: #FF8000;">As</span> SearchResult<br />
&nbsp; &nbsp; &nbsp; &nbsp; objResult <span style="color: #008000;">=</span> objSearch.<span style="color: #0000FF;">FindOne</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GetUserProperties <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>objResult.<span style="color: #0000FF;">Properties</span><span style="color: #000000;">&#40;</span>Result<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></div></div>
<p>Replace <strong>dc=domain, dc=co, dc=uk</strong> with your AD settings.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+&amp;desc=The%20.NET%20Framework%20includes%20an%20API%20called%20System.DirectoryServices.%20The%20sample%20VB.NET%20code%20below%20shows%20how%20to%20retrieve%20user%20account%20properties%20from%20the%20Active%20Directory.%0D%0A%0D%0AIn%20order%20to%20use%20System.DirectoryServices%20classes%2C%20you%20will%20need%20to%20first%20add%20a%20reference%20to%20System.DirectoryServices.%20%0D%0A%0D%0AImpor" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;bm_description=VB.NET%3A+Retrieving+Active+Directory+account+properties+&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/&amp;title=VB.NET%3A+Retrieving+Active+Directory+account+properties+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=VB.NET%3A+Retrieving+Active+Directory+account+properties++-+http://b2l.me/kjek7&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.redaware.net/2009/08/vb-net-retrieving-active-directory-account-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
