<?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>blog.dervalp.com &#187; AZAM</title>
	<atom:link href="http://blog.dervalp.com/tag/azam/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dervalp.com</link>
	<description>Think before Programming (Public learning)</description>
	<lastBuildDate>Sat, 20 Mar 2010 22:22:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>&#8220;AZAM, ADAM, Abracanabram&#8221; ! Is Harry Potter a dotnet developer?</title>
		<link>http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/</link>
		<comments>http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/#comments</comments>
		<pubDate>Tue, 12 May 2009 19:53:04 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Active Directory MemberShip Provider]]></category>
		<category><![CDATA[ADAM]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[AZAM]]></category>
		<category><![CDATA[Membership Provider]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=39</guid>
		<description><![CDATA[
Well, with all the acronyms which exist in the software development world, Harry Potter should have found a lot of words for his magic formulas. Today, I will explain you two of them, AZAM and ADAM.


The ASP.NET Membership Provider

 In my opinion, membership provider of ASP.NET provides a good abstraction for the authentication and the [...]]]></description>
			<content:encoded><![CDATA[<p><!--[endif]--></p>
<p class="MsoNormal"><span>Well, with all the acronyms which exist in the software development world, Harry Potter should have found a lot of words for his magic formulas. Today, I will explain you two of them, AZAM and ADAM.</span></p>
<h2 class="MsoNormal"><span><span id="more-39"></span><br />
</span></h2>
<h2 class="MsoNormal"><span>The ASP.NET Membership Provider<br />
</span></h2>
<p class="MsoNormal"><span> In my opinion</span><span>, <a href="http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx" target="_blank">membership provider of ASP.NET</a> provides a good abstraction for the authentication and the authorization. Moreover, I guess it is enough flexible that you can use it almost all the time. Thus, stop implementing your own custom authentication layer to make something that the framework does better than you and begin to learn it. </span></p>
<p class="MsoNormal"><span>Note : If you have cases where Membership provider cannot be use, please, share us your experience and leave a comment. </span></p>
<ul>
<li><span><a href="http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.aspx" target="_blank">The SqlMembershipProvider</a> (absolutely needs a Sql Server database for working; Sql Express per default).</span></li>
<li><span><a href="http://msdn.microsoft.com/en-us/library/system.web.security.activedirectorymembershipprovider.aspx" target="_blank">The ActiveDirectoryMembershipProvider</a>.</span></li>
</ul>
<p><span>Today, we will focus on ActiveDirectory Membership Provider; I will show you how to setup the ActiveDirectoryMembershipProvider, use Authorization Manager (Azman) as role provider and give you an introduction of Active Directory Application Mode (ADAM). Of course, to use ActiveDirectoryMembershipProvider, you need a domain controller (2003 SP2). It is not my aim to show you how to configure a DC, so I assume you have it up.</span></p>
<p><span><br />
If you only need an active directory authentication with no role managment, here is a post of my friend Mike who explains how to use Active Directory for the authentication with the new framework MVC (<a href="http://helios.ca/2009/05/04/aspnet-mvc-forms-authentication-with-active-directory/" target="_blank">http://helios.ca/2009/05/04/aspnet-mvc-forms-authentication-with-active-directory/</a>).</span></p>
<h2><span>Setting up Active Directory Membership Provider:</span></h2>
<h3><span>1. Add a ldap connection string to you Active Directory:</span></h3>
<p><span>Note : I assume you have the read permissions to your Active Directory.</span></p>
<p><span>If like me, you are sometimes a bit loss with active directory and the ldap protocol, here is a good tip to ensure a valid connection string. <a href="http://support.microsoft.com/kb/892777" target="_blank">Download the Windows Server 2003 Support tools: Windows Server 2003 Service Pack 1 Support Tools</a> and run the ADSIEDIT.MSC (per default in C:/ProgramFile/Support Tools). This tool allows you to see the structure of your Active Directory and it helps to make valid ldap connection string.</span></p>
<p><span>By default, you should see: DC = test, DC=mydomain, DC=COM. This is the first part of the connection string. Here is the first part of the connection string &#8220;test.mydomain.com&#8221;.<br />
After that, you should see objects as OU (organization unit) or CN (common name). If you expend the node DC=test, DC=mydomain. DC=COM, you will see all the OUs and the CNs of your active directory.  Normally, you should see the CN=Users or the OU User Accounts. When you have located where all your users are, you can now gathering the objects to make a valid LDAP connection string. </span></p>
<p><span>And here is the result: “LDAP://test.mydomain.com/CN=Users,DC=test,DC=mydomain,DC=com”.</span></p>
<p><span>So in you webconfig, you have to add this code :</span></p>
<p><span><img class="alignnone size-full wp-image-67" title="azam_adam1" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam1.jpg" alt="azam_adam1" width="658" height="90" /><br />
</span></p>
<h3><span>2. Configure the active directory membership provider :</span></h3>
<p><span>Now that you have a connection between your webserver and your domain controller, you will now be able to use AD for the authentication. To enable the active directory membership provider with you application, add some links to your webconfig file. </span></p>
<p><span>Find the &lt;membership&gt; element in your webconfig and add this:</span></p>
<p><span><img class="alignnone size-full wp-image-68" title="azam_adam2" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam2.jpg" alt="azam_adam2" width="658" height="179" /><br />
</span></p>
<p><span>More info here:<a href=" http://msdn.microsoft.com/en-us/library/whae3t94.aspx" target="_blank"> http://msdn.microsoft.com/en-us/library/whae3t94.aspx</a></span></p>
<h3><span>3. Wire Forms authentication with MemberShipProvider and your connection string :</span></h3>
<p><span>Add this code under the &lt;system.web&gt;</span></p>
<p><span><img class="alignnone size-full wp-image-70" title="azam_adam3" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam3.jpg" alt="azam_adam3" width="700" height="107" /><br />
</span></p>
<p><span>To use forms authentication, your IIS must use anonymous access enabled.</span></p>
<p><span>For IIS 6.0 :</span></p>
<ul>
<li><span>Command run : inetmgr</span></li>
<li>Right-click “properties” on your website</li>
<li><span>Directory Security</span><span>-Edit and you will receive this screen : Check that Anonymous access is enabled</span></li>
</ul>
<p><span><img class="alignnone size-full wp-image-72" title="azam_adam4" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam4.jpg" alt="azam_adam4" width="375" height="429" /><br />
</span></p>
<p><span>For IIS 7.0: <a href=" http://technet.microsoft.com/en-us/library/cc770966.aspx)" target="_blank">Here is the link</a>. </span></p>
<p><span>Note : To avoid storing a username and a password in a connection string, you can use IIS to manage that.  I hope I will have some time to write a post about that in the future.</span></p>
<h3><span>4. Taste it!</span></h3>
<p><span>Create a new MVC project and follow all the steps above, you should be now able to log you in with your active directory account.</span></p>
<p><span>Note : Here is the end of the first part, we saw the different methods to use ASP.NET Membership Provider and how to enable ActiveDirectory Membership provider. In next step, we will see how to use Authorization Manager and Active directory application mode.</span></p>
<h3><span>5. Active Directory Role manager :</span></h3>
<p><span>Now, that you have your authentication, you would expect an active directory role manager who retrieves the current user’s group information. Unfortunately, it does not exist. I saw interesting posts on the net <a href="(http://oricode.wordpress.com/2008/02/14/active-directory-role-provider/" target="_blank">(http://oricode.wordpress.com/2008/02/14/active-directory-role-provider/</a> and <a href="http://www.codeproject.com/KB/aspnet/active_directory_roles.aspx" target="_blank">http://www.codeproject.com/KB/aspnet/active_directory_roles.aspx</a> ) but I did not have the time to test it. It seems to sounds pretty good but if you search on MSDN, you will find that the &#8220;best practices&#8221; for Microsoft is using Azman.</span></p>
<h3>6. Authorization Manager:</h3>
<p>Azman or Authorization Manager “enables you to define individual operations, which can be grouped together to form tasks. You can then authorize roles to perform specific tasks and/or individual operations. AzMan provides an administration tool as a Microsoft Management Console (MMC) snap-in to manage roles, tasks, operations, and users. You can configure an AzMan policy store in an XML file, Active Directory, or in an Active Directory Application Mode (ADAM) store.” More info : <a href="http://msdn.microsoft.com/en-us/library/ms998336.aspx" target="_blank">here</a>.<br />
Here is a good “how to” from Msdn:<a href="http://msdn.microsoft.com/en-us/library/ms998336.aspx" target="_blank"> http://msdn.microsoft.com/en-us/library/ms998336.aspx</a><br />
Azman is installed with Windows Server 2003 SP1 and later. To use it with Windows XP, you need to install the Windows Server 2003 Administration Tools Pack (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e487f885-f0c7-436a-a392-25793a25bad7&amp;DisplayLang=en" target="_blank">here</a>).<br />
Managing role membership with AzMan is quite easy; you can use the snap-in to add roles and tasks in your application. You can also easily map Windows accounts with the roles you have defined. It can be used with an XML file or ADAM.</p>
<h4 style="padding-left: 30px;">Install The AzMan Snapin, install it :</h4>
<p>First, Install the Windows Server 2003 Administration Tools Pack, which you can download <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e487f885-f0c7-436a-a392-25793a25bad7&amp;DisplayLang=en" target="_blank">here</a>. <span>If you have some difficulties to have this screen, please follow the <a href="http://msdn.microsoft.com/en-us/library/ms998336.aspx" target="_blank">guideline </a>from MSDN. </span>In a run command type : &#8220;azman.msc&#8221;, you’ll receive this window :</p>
<p><img class="alignnone size-full wp-image-74" title="azam_adam5" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam5.jpg" alt="azam_adam5" width="628" height="440" /></p>
<h3 style="padding-left: 30px;">Developer Mode</h3>
<p>Right-Click “Authorization Manager”, “options”, choose “Developer Mode”.</p>
<h3 style="padding-left: 30px;">Create an Authorization Store</h3>
<p>Right Click “New Authorization Store” on “Authorization Manager”. Choose the XML file.</p>
<p><img class="alignnone size-full wp-image-75" title="azam_adam6" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam6.jpg" alt="azam_adam6" width="430" height="299" /></p>
<p>Browse the directory you want the Xml to be stored.  For example: &lt;PathOfYourApplicationFolder\App_Data\Roles.xml.<br />
As soon as you have created your “Role Manager”, you should now create an application.<br />
Right-Click on roles.xml, create New Application:</p>
<p><img class="alignnone size-full wp-image-76" title="azam_adam7" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam7.jpg" alt="azam_adam7" width="388" height="291" /></p>
<p>You have now a tree like this</p>
<p><img class="alignnone size-full wp-image-77" title="azam_adam8" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam8.jpg" alt="azam_adam8" width="180" height="163" /></p>
<p>-    Expand the Definitions folder and then right click on Role Definition&#8230;<br />
-    Provide a name for the role “Admin”<br />
-    Right Click on Role Assignments and select Assign Role Assignment, check the box against Admin and click OK. This role should now be listed under Role Assignments node.<br />
-    Right-click on the role Admin and you can assign Users form Windows or Active Directory.<br />
-    Choose assign to active directory and choose a user.</p>
<h3 style="padding-left: 30px;">Use your authorization store with your application :</h3>
<p>Open you web.config and add the connection string to your XML :</p>
<p><img class="alignnone size-full wp-image-78" title="azam_adam9" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam9.jpg" alt="azam_adam9" width="544" height="72" /></p>
<p>Enable Role Manager and configure the role provider :</p>
<p><img class="alignnone size-full wp-image-79" title="azam_adam10" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam10.jpg" alt="azam_adam10" width="566" height="111" /></p>
<h3 style="padding-left: 30px;">Configure Role with your web.config :</h3>
<p>Under &#8220;Secured&#8221;</p>
<p><img class="alignnone size-full wp-image-80" title="azam_adam11" src="http://blog.dervalp.com/wp-content/uploads/2009/05/azam_adam11.jpg" alt="azam_adam11" width="566" height="98" /></p>
<p>Test your website and it should works. Try to login with a user account which is not a member of the role you decided. You should not have access, try the opposite and you should have access.</p>
<p>Note: After you add a role in your application authorization store, you certainly have noticed that it needs some times to be effective. Indeed, you have to restart the application or wait for a recycle. I did not find any solution for the moment but there should be a way to force it. If you have a solution, please leave me a comment.</p>
<h2><strong>6. Active directory application mode (ADAM)</strong></h2>
<p>Instead of using an xml with AzMan, you could use ADAM. The main quality is that you can have one instance for all your web application in place of a XML file for each one.<br />
The “How to” in Msdn is so clear that I prefer to give you the link in place of explaining eveything step by step.</p>
<p>Here is the link: <a href="http://msdn.microsoft.com/en-us/library/ms998331.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms998331.aspx</a>. I tried it and I succeed to work with ADAM using AzMan policy.</p>
<p>Note:  ADAM is not supported on Windows Vista.<strong><br />
</strong></p>
<p><span>As always, if you have corrections or remarks, leave me a comment. Thank you.</span></p>
<p><span><br />
</span></p>
<p><span><br />
</span></p>
<p><span><br />
</span></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d39').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d39" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/&amp;title=%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/&amp;title=%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/&amp;title=%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/&amp;title=%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/&amp;title=%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F+@+http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/&amp;t=%26%238220%3BAZAM%2C+ADAM%2C+Abracanabram%26%238221%3B+%21+Is+Harry+Potter+a+dotnet+developer%3F" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d39').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d39').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%c2%bb-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
