<?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>Chris&#039;s Blog of Gooey Goodness! &#187; mod_auth_sspi</title>
	<atom:link href="http://chrisbjax.com/tag/mod_auth_sspi/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrisbjax.com</link>
	<description>My personal world on the web!</description>
	<lastBuildDate>Fri, 23 Jul 2010 19:28:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4060</generator>
		<item>
		<title>Setting up mod_auth_sspi &amp; adldap</title>
		<link>http://chrisbjax.com/2008/09/26/setting-up-mod_auth_sspi-adldap/</link>
		<comments>http://chrisbjax.com/2008/09/26/setting-up-mod_auth_sspi-adldap/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 17:39:24 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[adldap]]></category>
		<category><![CDATA[mod_auth_sspi]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.chrisbjax.com/?p=29</guid>
		<description><![CDATA[Outlines setting up mod_auth_sspi &#038; adldap to provide seamless authentication to Active Directory.]]></description>
			<content:encoded><![CDATA[<p>WOW, that&#8217;s a mouthful!</p>
<p>Well, luckily, I just managed to get this working myself! Hurray for me!</p>
<p><strong>WHAT THIS DOES???</strong></p>
<p>This script will use the SSPI module to grab your local login<br />
DOMAIN\ID, break the domain name off the front of your ID, then<br />
utilizing adldap, query AD for your user ID, which is displayed<br />
lastname,firstname, then break that apart, and echo first name last<br />
name.</p>
<p>You can easily copy this on your intranet pages. (Which is what I use it for,)</p>
<p><strong>ASSUMPTIONS</strong></p>
<ul>
<li> Windows 2003 STD server</li>
<li> PHP, MYSQL, APACHE (Typically referred to as a WAMP installation) installed and running correctly.</li>
<li>You have a working knowledge of PHP, and apache, and how to edit, modify files.</li>
</ul>
<p><strong>SETUP</strong></p>
<p>Download the current release of <a href="http://adldap.sourceforge.net/download.php">ADLDAP from their website </a>(At the time of this writing, the current version was v2.1)</p>
<p>Edit the file to point to your LDAP server. (See example below)</p>
<table style="background-color: #ccffff; height: 238px;" border="1" width="477">
<tbody>
<tr>
<td><span style="color: #339966;">class </span>adLDAP {</p>
<p><span style="color: #ff6600;">// BEFORE YOU ASK A QUESTION, PLEASE READ THE DOCUMENTATION AND THE FAQ</span></p>
<p>// http://adldap.sourceforge.net/documentation.php</p>
<p>// http://adldap.sourceforge.net/faq.php</p>
<p><span style="color: #ff6600;"> // You can set your default variables here, or when you invoke the class</span></p>
<p><span style="color: #339966;">var</span> $_account_suffix=<span style="color: #ff0000;">&#8220;@yourdomin.com&#8221;</span>;</p>
<p><span style="color: #339966;">var</span> $_base_dn = <span style="color: #ff0000;">&#8220;DC=yourdomain,DC=com&#8221;</span>;</p>
<p><span style="color: #ff6600;">// An array of domain controllers. Specify multiple controllers if you</span></p>
<p>// would like the class to balance the LDAP queries amongst multiple servers</p>
<p><span style="color: #339966;">var</span> $_domain_controllers = <span style="color: #0000ff;">array</span> (<span style="color: #ff0000;">&#8220;yourdomaincontroller.yourdomin.com&#8221;</span>);</p>
<p><span style="color: #ff6600;">// optional account with higher privileges for searching</span></p>
<p>// not really that optional because you can&#8217;t query much as a user</p>
<p><span style="color: #339966;">var</span> $_ad_username=<span style="color: #ff0000;">&#8220;account_to_query_AD&#8221;</span>;</p>
<p><span style="color: #339966;">var</span> $_ad_password=<span style="color: #ff0000;">&#8220;password_for_Account&#8221;</span>;</td>
</tr>
</tbody>
</table>
<p>Copy the adldap.php file to your website. (I installed into /includes folder.)</p>
<p>ok, we&#8217;re done..</p>
<p>Just kidding, but not too much more!<br />
<img title="Wink" src="admin/editor/plugins/emotions/images/smiley-wink.gif" border="0" alt="Wink" /></p>
<p>Next, Download <a href="http://sourceforge.net/projects/mod-auth-sspi">mod-auth-sspi from sourceforge.net</a> .</p>
<p>Copy the files <strong>mod_auth_sspi.so</strong> and <strong>sspipkgs.exe</strong> to your apache modules folder.</p>
<p>Add the module to the server&#8217;s config file by editing httpd.con.</p>
<table style="background-color: #ccffff; height: 34px;" border="1" width="570">
<tbody>
<tr>
<td>LoadModule sspi_auth_module modules/mod_auth_sspi.so</td>
</tr>
</tbody>
</table>
<p>Protect a directory or location.</p>
<p>You can put these directives inside the httpd.conf file, or inside .htaccess</p>
<p>files if AllowOverride AuthConfig is set.</p>
<table style="background-color: #ccffff; height: 189px;" border="1" width="286">
<tbody>
<tr>
<td>&lt;Directory &#8220;C:/SSPI&#8221;&gt;</p>
<p>AllowOverride None</p>
<p>Options None</p>
<p>Order allow,deny</p>
<p>Allow from all</p>
<p>AuthName &#8220;My Intranet&#8221;</p>
<p>AuthType SSPI</p>
<p>SSPIAuth On</p>
<p>SSPIAuthoritative On</p>
<p>require valid-user</p>
<p>&lt;/Directory&gt;</td>
</tr>
</tbody>
</table>
<p>NOTE &#8211; There is information on the SSPI</p>
<p>Create a file named : <strong>whoami.php</strong> or you can name it, <strong>ilikepinkelephants.php</strong> if you prefer.</p>
<p>Copy this into it.</p>
<table style="background-color: #ccffff; height: 232px;" border="1" width="575">
<tbody>
<tr>
<td><span style="color: #ff0000;"><strong>&lt;?php</strong></span> <span style="color: #339966;">require</span>(<span style="color: #ff0000;">&#8216;includes/adLDAP.php&#8217;</span>);<span style="color: #ff0000;"> <strong>?&gt;</strong></span></p>
<p><span style="color: #ff0000;"><strong>&lt;?php</strong></span></p>
<p>$cred = <span style="color: #0000ff;">explode</span>(<span style="color: #ff0000;">&#8216;\\&#8217;</span>,<span style="color: #0000ff;">$_SERVER</span>[<span style="color: #ff0000;">'REMOTE_USER'</span>]);</p>
<p>if (<span style="color: #0000ff;">count</span>($cred) <span style="color: #0000ff;">==</span> <span style="color: #ff0000;">1</span>) <span style="color: #0000ff;">array_unshift</span>($cred, <span style="color: #ff0000;">&#8220;(no domain info &#8211; perhaps SSPIOmitDomain is On)&#8221;</span>);</p>
<p><span style="color: #0000ff;">list</span>($domain, $user) = $cred;</p>
<p>$ldap=<span style="color: #339966;">new</span> adLDAP($options);</p>
<p><span style="color: #339966;">if</span> (<span style="color: #ff0000;">1</span>){</p>
<p>$result = $ldap-&gt;user_info($user,<span style="color: #0000ff;">array</span>(<span style="color: #ff0000;">&#8216;displayname&#8217;</span>));</p>
<p><span style="color: #0000ff;">$_SESSION</span>[<span style="color: #ff0000;">'username'</span>] = $result[<span style="color: #ff0000;">0</span>][displayname][<span style="color: #ff0000;">0</span>];</p>
<p>$fullname = <span style="color: #0000ff;">$_SESSION</span>[<span style="color: #ff0000;">'username'</span>];</p>
<p>$splitname = <span style="color: #0000ff;">explode</span>(<span style="color: #ff0000;">&#8220;,&#8221;</span>, $fullname);</p>
<p><span style="color: #0000ff;">echo</span> $splitname[<span style="color: #ff0000;">1</span>];</p>
<p><span style="color: #0000ff;">echo </span>(<span style="color: #ff0000;">&#8221; &#8220;</span>);</p>
<p><span style="color: #0000ff;">echo</span> $splitname[<span style="color: #ff0000;">0</span>];</p>
<p>}</p>
<p><span style="color: #ff0000;"><strong>?&gt;</strong></span></td>
</tr>
</tbody>
</table>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://chrisbjax.com/2008/09/26/setting-up-mod_auth_sspi-adldap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
