<?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>Peter Izuoba</title>
	<atom:link href="http://peterizuoba.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterizuoba.com</link>
	<description>Freelance .NET Developer</description>
	<lastBuildDate>Tue, 11 Dec 2012 10:33:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to Pull Users from Active Directory</title>
		<link>http://peterizuoba.com/how-to-pull-users-from-active-directory/</link>
		<comments>http://peterizuoba.com/how-to-pull-users-from-active-directory/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 10:33:03 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Windows Server]]></category>

		<guid isPermaLink="false">http://peterizuoba.com/?p=100</guid>
		<description><![CDATA[You might have the need to access users information from the windows active directory. .NET offers you a cool way of searching through active directory records and getting to the information you want. In this article I will show you a few ways of interacting with the AD. Lets dive in. .NET provides the System.DirectoryServices.dll [...]]]></description>
				<content:encoded><![CDATA[<p>You might have the need to access users information from the windows active directory. .NET offers you a cool way of searching through active directory records and getting to the information you want. In this article I will show you a few ways of interacting with the AD.</p>
<p>Lets dive in.</p>
<p>.NET provides the System.DirectoryServices.dll assembly for this, so be sure to add a reference to your project. This gives us access to classes like the DirectoryEntry, DirectorySearcher, SearchResultCollection, SearchResult etc.</p>
<p><strong>Pulling all users from the AD</strong></p>
<p>This happens to be quite easy.</p>
<div>
<div>        public List&lt;string&gt; GetAllUsers()</div>
<div>        {</div>
<div>            List&lt;string&gt; names = new List&lt;string&gt;();</div>
<div></div>
<div>            DirectoryEntry entry = new DirectoryEntry(&#8220;LDAP://mydomain.com&#8221;);</div>
<div>            DirectorySearcher searcher = new DirectorySearcher(entry);</div>
<div>            searcher.Filter = &#8220;(&amp;(objectClass=user)(objectCategory=person))&#8221;;</div>
<div>            searcher.PropertiesToLoad.Add(&#8220;distinguishedName&#8221;);</div>
<div>            SearchResultCollection results = searcher.FindAll();</div>
<div></div>
<div>            if (results != null)</div>
<div>            {</div>
<div>                for (int i = 0; i &lt; results.Count; i++)</div>
<div>                {</div>
<div>                    SearchResult result = results[i];</div>
<div></div>
<div>                    if (result.Properties.Contains(&#8220;distinguishedName&#8221;))</div>
<div>                        names.Add((String)result.Properties["distinguishedName"][0]);</div>
<div>                }</div>
<div>            }</div>
<div></div>
<div>            return names;</div>
<div>        }</div>
</div>
<div></div>
<div>Ok! What is this?</div>
<div></div>
<div><strong>DirectoryEntry entry = new DirectoryEntry(&#8220;LDAP://mydomain.com&#8221;);</strong></div>
<div>Here we create a DirectoryEntry object passing in the domain we want to search. This happens to be our ticket into the world of AD.</div>
<div></div>
<div>
<div><strong>DirectorySearcher searcher = new DirectorySearcher(entry);</strong></div>
<div><strong>searcher.Filter = &#8220;(&amp;(objectClass=user)(objectCategory=person))&#8221;;</strong></div>
<div>The DirectorySearcher object helps us search the AD based on a filter criteria passed to the &#8216;Filter&#8217; property. In our case we are asking it to scan the AD for objects with a class of user and category of person.</div>
</div>
<div></div>
<div><strong>searcher.PropertiesToLoad.Add(&#8220;distinguishedName&#8221;);</strong></div>
<div>Here we specify the properties of the objects we will like to pull. It always good practice to pull only the information you need.</div>
<div></div>
<div><strong>SearchResultCollection results = searcher.FindAll();</strong></div>
<div>At this point we are asking the searcher to now pull this information.</div>
<div></div>
<div>
<div>  <strong>if (results != null)</strong></div>
<div><strong>            {</strong></div>
<div><strong>                for (int i = 0; i &lt; results.Count; i++)</strong></div>
<div><strong>                {</strong></div>
<div><strong>                    SearchResult result = results[i];</strong></div>
<div><strong> </strong></div>
<div><strong>                    if (result.Properties.Contains(&#8220;distinguishedName&#8221;))</strong></div>
<div><strong>                        names.Add((String)result.Properties["distinguishedName"][0]);</strong></div>
<div><strong>                }</strong></div>
<div><strong>            }</strong></div>
<div>At this point we iterate through our collection of users, checking to make sure the needed property is available before trying to extract it.</div>
</div>
<div></div>
<div>Hope this helps. I&#8217;d love to hear from you</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://peterizuoba.com/how-to-pull-users-from-active-directory/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sending a Collection from Browser to Controller in ASP.NET MVC</title>
		<link>http://peterizuoba.com/sending-a-collection-from-browser-to-controller-in-asp-net-mvc/</link>
		<comments>http://peterizuoba.com/sending-a-collection-from-browser-to-controller-in-asp-net-mvc/#comments</comments>
		<pubDate>Thu, 21 Jun 2012 22:29:19 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>

		<guid isPermaLink="false">http://peterizuoba.com/?p=4</guid>
		<description><![CDATA[In this artcle, I’m going to show you an easy way of sending a collection from the client to the server in asp.net mvc using the hidden control and just a little jquery. We are going to be sending this list of my favourite fruits to an MVC controller action when the submit button is [...]]]></description>
				<content:encoded><![CDATA[<p>In this artcle, I’m going to show you an easy way of sending a collection from the client to the server in asp.net mvc using the hidden control and just a little jquery.</p>
<p>We are going to be sending this list of my favourite fruits to an MVC controller action when the submit button is clicked.<a href="http://peterizuoba.com/wp-content/uploads/2012/06/fruits1.jpg"><img class="alignnone size-full wp-image-5" title="Html Collection" src="http://peterizuoba.com/wp-content/uploads/2012/06/fruits1.jpg" alt="The html view of the collection" width="402" height="386" /></a><a href="http://peterizuoba.com/wp-content/uploads/2012/06/fruits2.jpg"><img class="alignnone size-full wp-image-6" title="Html Collection" src="http://peterizuoba.com/wp-content/uploads/2012/06/fruits2.jpg" alt="Html Collection" width="491" height="447" /></a></p>
<p>To get these lovely fruits into the html hidden input control, we need to intercept the submit event of the form, iterate over the list items and add each one to the hidden control while appending any separator of your choice, in this case I think I can simply use a comma. Don’t worry its not that difficult to accomplish.</p>
<p>Here is the jquery code for this<a href="http://peterizuoba.com/wp-content/uploads/2012/06/fruits3.jpg"><img class="alignnone size-full wp-image-7" title="fruits3" src="http://peterizuoba.com/wp-content/uploads/2012/06/fruits3.jpg" alt="Jquery code to send collection to controller" width="628" height="447" /></a></p>
<p>Well, over at the controller side, we have this<a href="http://peterizuoba.com/wp-content/uploads/2012/06/fruits4.jpg"><img class="alignnone size-full wp-image-8" title="fruits4" src="http://peterizuoba.com/wp-content/uploads/2012/06/fruits4.jpg" alt="" width="628" height="241" /></a></p>
<p>I hope this has helped you. You can download the source <a href="http://peterizuoba.com/wp-content/uploads/2012/06/MvcApplication2.rar">here</a>. Please leave me your comments, I’d love to hear from you.</p>
]]></content:encoded>
			<wfw:commentRss>http://peterizuoba.com/sending-a-collection-from-browser-to-controller-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
