Over the last couple of months, I tasked myself with learning how to implement LDAP in Symfony2. This was about as painful as it sounds. At first, I had wanted to modify OpenSky’s LDAP bundle for the goals I wanted to meet. There were a few drawbacks to this — namely, that it was really difficult to split out the dependencies required to implement a non-preauthenticated model for authorization and user provision. Without this, it was going to be difficult to, for instance, authorize through LDAP via a form. There was also a dependency on Zend’s LDAP module, since Symfony2 does not presently have LDAP support in any of its releases. This was kind of a problem, since it constitutes leaning on one framework to fill in for the missing features of another. Solving a framework’s problem with another framework isn’t the best idea.
After struggling with OpenSky’s LDAP bundle, I did a lot of research online to see if anyone else had problems using it. I discovered then, through Grégoire Pineau’s pull request to the Symfony2 main project, that not only had he found OpenSky’s approach to be sub-optimal, but it was one of the leading causes for him to write his own LDAP component native to Symfony2. This was exactly what I was looking for — Symfony2 framework-level support for LDAP. But it was coming too late. The deadline for this project was to get it working with 2.1, and this won’t make it out to the public until 2.2.
Because LDAP support is coming in a future version of the Symfony framework, I decided to create a bundle that copied Pineau’s approach as closely as possible, adding in those features we needed, which were still to-dos on the main project. Now, any time the LDAP component updates, we can incorporate those changes relatively easy. For instance, we got TLS and SSL for free because of updates from the main project. The best part is that we don’t have to wait for a later version of Symfony to get the features we want now.
Because I like puns and bro-fisting, I called this “advanced release” of the Symfony2 LDAP feature Daps. You can get Daps on GitHub. It’s my first time building out a bundle, so I’ve probably got a bit to learn. It was a fun — albeit insanely difficult — way to get my feet wet working with Symfony2. If you’re looking for a relatively clean way generating users based on listings your LDAP solution, please feel free to fork and add on.
Coming full circle, working on this project has me actually asking questions about the original pull request, helping to shape the way this component looks when it actually makes its way into Symfony2. Another great story about how open source software helps us all go far, together.