<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Andrew E. Bruno &#187; PHP</title>
	<atom:link href="http://left.subtree.org/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://left.subtree.org</link>
	<description>A sourceful of secrets</description>
	<lastBuildDate>Mon, 10 May 2010 03:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='left.subtree.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/e14c799c6e8030a8abefcb495c0b0e17?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Andrew E. Bruno &#187; PHP</title>
		<link>http://left.subtree.org</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://left.subtree.org/osd.xml" title="Andrew E. Bruno" />
	<atom:link rel='hub' href='http://left.subtree.org/?pushpress=hub'/>
		<item>
		<title>phpLDAPadmin and Kerberos</title>
		<link>http://left.subtree.org/2007/06/26/phpldapadmin-and-kerberos/</link>
		<comments>http://left.subtree.org/2007/06/26/phpldapadmin-and-kerberos/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 02:56:55 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://left.subtree.org/2007/06/26/phpldapadmin-and-kerberos/</guid>
		<description><![CDATA[I&#8217;ve been experimenting with phpLDAPadmin for browsing/searching LDAP directories over the web and found it to be a wonderful tool. I&#8217;m currently working with LDAP in a central authentication system together with Kerberos and wanted to have a nice web interface for managing user information within the LDAP directory. phpLDAPadmin provides a very nice interface [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=16&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with <a href="http://phpldapadmin.sourceforge.net/">phpLDAPadmin</a> for browsing/searching LDAP directories over the web and found it to be a wonderful tool. I&#8217;m currently working with LDAP in a central authentication system together with Kerberos and wanted to have a nice web interface for managing user information within the LDAP directory. phpLDAPadmin provides a very nice interface for browsing, searching, and updating entries which makes it a bit easier than working with the ldap* command line tools. Here&#8217;s my basic setup of phpLDAPadmin using Kerberos for authentication. This assumes you already have an LDAP/Kerberos setup working and are using Apache as your web server.</p>
<p>First step is to make sure you have <a href="http://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer">SASL</a> support compiled into the LDAP PHP extension <code>--with-ldap-sasl</code>. Check out phpinfo() and make sure you see <code>SASL Support   Enabled</code> under the LDAP extension. If not re-compile PHP.<br />
<span id="more-16"></span><br />
Grab a copy of phpLDAPadmin <a href="http://phpldapadmin.sourceforge.net/download.php">here</a> and untar into a directory of your choice (/usr/local). Copy the config.php.example to config.php:</p>
<pre class="brush: plain; light: true;">
$ tar -xvxf phpldapadmin-x.x.x.tar.gz
$ ln -s phpldapadmin-x.x.x phpldapadmin
$ cd phpldapadmin
$ cp config/config.php.example config/config.php
</pre>
<p>Edit config/config.php. A few options to define are as follows:</p>
<pre class="brush: php;">
$ldapservers-&gt;SetValue($i,'server','name','My LDAP Server');
$ldapservers-&gt;SetValue($i,'server','host','ldap.host.com');
$ldapservers-&gt;SetValue($i,'server','port','389');
$ldapservers-&gt;SetValue($i,'server','auth_type','config');
$ldapservers-&gt;SetValue($i,'login','dn','');
$ldapservers-&gt;SetValue($i,'login','pass','');
$ldapservers-&gt;SetValue($i,'server','tls',false);
$ldapservers-&gt;SetValue($i,'server','sasl_auth',true);
$ldapservers-&gt;SetValue($i,'server','sasl_mech','GSSAPI');
$ldapservers-&gt;SetValue($i,'server','sasl_authz_id_regex','/^uid=([^,]+)(.+)/i');
$ldapservers-&gt;SetValue($i,'server','sasl_authz_id_replacement','$1');
$ldapservers-&gt;SetValue($i,'login','anon_bind',false);
</pre>
<p>Basically, we&#8217;re configuring phpLDAPadmin with <code>auth_type = config</code> which means that the user/pass used to bind to the LDAP server is hard coded in the config.php file. We leave the user/pass blank because each user will first be authenticating through Kerberos and using their tickets to bind to the LDAP server. Internally phpLDAPadmin calls the <code><a href="http://us.php.net/manual/en/function.ldap-sasl-bind.php">ldap_sasl_bind(..)</a></code> function with an <code>auth_mech of <a href="http://en.wikipedia.org/wiki/Generic_Security_Services_Application_Program_Interface">GSSAPI</a></code> which does the work of binding using Kerberos tickets.</p>
<p>Next, we&#8217;ll configure apache to point to the location where we installed phpLDAPadmin. Edit your httpd.conf file or equivalent. If your running redhat usually create a file in /etc/httpd/conf.d or on Debian /etc/apache2/site-available/. You will probably want to add this to an SSL vhost to ensure your username/passwords are transmitted over a secure connection.</p>
<pre class="brush: plain;">
Alias /ldapadmin /usr/local/phpldapadmin/htdocs/
&lt;Location /ldapadmin&gt;
    AuthType Kerberos
    AuthName &quot;LDAP Admin&quot;
    KrbAuthRealms kerb.yourhost.com
    KrbVerifyKDC off
    KrbServiceName HTTP
    Krb5KeyTab /path/to/your/httpd.keytab
    KrbSaveCredentials on
    require valid-user
&lt;/Location&gt;
</pre>
<p>In order to authenticate users against Kerberos and obtain the necessary Kerberos tickets we use the apache module <a href="http://modauthkerb.sourceforge.net/">mod_auth_kerb</a>. The apache config above defines our location for phpLDAPadmin and adds in the necessary config for mod_auth_kerb. More info can be found <a href="http://modauthkerb.sourceforge.net/configure.html">here</a>. Make sure to add in the <code>KrbSaveCredentails on</code> directive so that mod_auth_kerb will save the Kerberos tickets for use throughout the request.</p>
<p>Next we need to expose the location of the Kerberos tickets to phpLDAPadmin. mod_auth_kerb sets an environment variable <code>KRB5CCNAME</code> to the location of the credential cache. To expose this environment variable to the phpLDAPadmin code edit the file <code>[phpLDAPadmin_install]/lib/common.php</code> and add this line to the very top:</p>
<pre class="brush: php; light: true;">
putenv(&quot;KRB5CCNAME={$_SERVER['KRB5CCNAME']}&quot;);
</pre>
<p>That should do it. Now when you access http://yourserver.com/ldapadmin you should be challenged with HTTP basic auth, which authenticates against Kerberos and uses the Kerberos credentials to bind to your LDAP server. There might be an easier way to go about doing this but I wasn&#8217;t able to turn much up on google so I thought I&#8217;d share one way I was able to get things working.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/qnot.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/qnot.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/qnot.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/qnot.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/qnot.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/qnot.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/qnot.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/qnot.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/qnot.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/qnot.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=left.subtree.org&amp;blog=13566420&amp;post=16&amp;subd=qnot&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://left.subtree.org/2007/06/26/phpldapadmin-and-kerberos/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">sigma110</media:title>
		</media:content>
	</item>
	</channel>
</rss>