Improving MSU’s people search
21 January, 2011 § 1 Comment
In the summer of 2006, I had an idea. I would often use the Michigan State University website to look up email addresses and phone numbers of others at the university. The search mechanism on the website required the last name of individuals, with the first name optional.
But sometimes I didn’t know the last name of the person I was looking for. Like any good computer science student, I decided to write my own “MSU People Search”.
Like many large institutions, Michigan State University uses what is called an LDAP directory. LDAP directories can be used as a sort-of white pages for an institution. They can store information about people and tangible items like computers.
Most likely you have used one of these LDAP directories when setting up a local email client. When using Microsoft Outlook at work, I can type in the real name of a recipient in the “To:” address field. As I’m typing the email, Outlook will perform an LDAP search for a user with the provided name and update the “To:” address field to the user’s email address.
It’s not too hard to make your own LDAP search website. The most common parameters you are going to need are the LDAP server’s hostname, the “Base Distinguished Name” (otherwise known as a Base DN), and some attribute fields to request.
With the php-ldap library, you can write your own LDAP search website in PHP. Simply
- Call ldap_connect to open a connection
- ldap_search to perform your search
- Optionally call ldap_sort to sort your entries
- ldap_get_entries to turn your results into an associative array
- Then iterate through your associate array and you’re done.
Feel free to take a look at my implementation and provide any feedback you have.