I want to be able to search LDAP users by first name, last name, or email, and in the results show the user's picture, first/last names, role, and email. I've looked into it a little and found the LDAP module for drupal, but all I see is syncing with users. Is this something I can do using this module? Am I going to have to sync the LDAP db with a table in my MySQL db and then reference that table?
2 Answers
I think you'll find that LDAP modules for Drupal are primarily for allowing LDAP users to use Drupal.
My understanding of what you're saying is that you just want to display the LDAP users, sort of like a directory system?
If Drupal doesn't have to really interact with your LDAP users, you should be able to create your own module for this pretty easily.
There are quite a few LDAP functions in PHP: http://ca2.php.net/manual/en/ref.ldap.php
Create a module that makes use of them, and then passes the data over to a node for display purposes.
I have toyed alot with the LDAP module. It can do exactly what you want assuming you're not a newb with LDAP or Drupal. I highly recommend you read the official drupal LDAP documentation -- pretty much all your answers may be found there.
If the LDAP module seems complex -- it's in my opinion because LDAP (and the ldap vendors) simply are complex.
The LDAP module lets you connect to and query an LDAP service. It has many submodules:
- LDAP Servers. Stores connection information for ldap servers and relationships between ldap and drupal users. Also contains api functions for LDAP project.
- LDAP User (7.x-2.x branch). Controls provisioning and synching mappings of Drupal user fields and properties to and from LDAP Entry attributes.
- LDAP Query. Stores individual queries that can be leveraged by other modules such as LDAP Feeds and LDAP Views.
- LDAP Authentication. Authentication via user credential checking or single sign on methods such as NTLM.
- LDAP Authorization. Conversion of ldap user data to drupal roles, organic group memberships and other authorization consumers.
- LDAP Feeds. Fetchers for LDAP Queries and LDAP Users to integrate with Drupal Feeds module.
- LDAP Views. Views module integration for LDAP Query resultsets
- LDAP Help. Helper module for debugging configuration issues with other LDAP Modules.
- LDAP Test (7.x-2.x branch). This is simply for automated test coverage and never needs to be enabled; the simpletests will enable it while running. It contains the mock ldap server and related helper functions.
I have bolded the key submodules found in the documentation relevant to your question. You can save an LDAP Query (a raw LDAP search query -- this has nothing to do with Drupal and 100% pure LDAP usage knowledge) and use it within a Drupal View or via the Feeds module.
Understanding whether you want a drupal View or leverage the Feeds module to populate a content type or something else is where you're understanding of Drupal will be helpful -- and specifically these 2 modules.
As an example here is a stored query to run against ldap:
And its test result:
EDIT In short, yes LDAP lets you Sync or create/add LDAP "users" into Drupal. It may also be used to simply query and essentially use and "show" LDAP data on your site. What modules you choose to do that with -- and your approach is up to you (Views or Feeds processing). Writing this stuff from scratch sucks. Use the LDAP modules and the tools outlined here :)