This is a simple module to provide a bridge between Drupal and LDAP.

Installation

1. Download the adLDAP library and place it on sites/{all|sitename}/libraries: https://github.com/adldap/adLDAP/archive/v4.0.4.zip.
2. Install the module.
3. Configure the LDAP variables here: admin/config/people/ldap

For developers

Module workflow when logging in:

1. User is on Drupal already.
1.1. User is on LDAP.
1.1.1 Update the user info based on the LDAP information and logs user in.
1.2. User is NOT on LDAP
1.2.1 Normal Drupal login

2. User is not on Drupal.
2.1 User is on LDAP
2.1.1 Creates user on Drupal and logs user in.
2.2 User is NOT on LDAP
2.2.1 Login validation error.

If you want to add additional fields to your user profile, use the hook_ldap_login_user_alter(&$drupal_user).

Testing

You should be good to go :)
To test it, just try to get one username / password from the LDAP server and log in using it.

Similar modules

Lightweight Directory Access Protocol (LDAP) (https://www.drupal.org/project/ldap) - This is a much more complex modules that will allow you read/write.

Project code

git clone --branch 7.x-1.x https://git.drupal.org/sandbox/rafaelferreir4/2741035.git ldap_login

Comments

rafaelferreir4 created an issue. See original summary.

PA robot’s picture

Issue summary: View changes
Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpsgitdrupalorgsandboxrafaelferreir4274103...

Fixed the git clone URL in the issue summary for non-maintainer users.

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

dsouza_rohan’s picture

Automated Review

http://pareview.sh/pareview/httpsgitdrupalorgsandboxrafaelferreir42741035git

Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.

Manual Review

Individual user account
[Yes: Follows ] the guidelines for individual user accounts.
No duplication
[Yes: Does not cause] module duplication and/or fragmentation.
Master Branch
[Yes: Follows ] the guidelines for master branch.
Licensing
[Yes: Follows] the licensing requirements.
3rd party assets/code
[Yes: Follows ] the guidelines for 3rd party assets/code.
README.txt/README.md
[Yes: Follows ] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[Yes: Follows ] the guidelines for project length and complexity.
Secure code
[Yes: Meets the security requirements.
Coding style & Drupal API usage

This review uses the Project Application Review Template.

rafaelferreir4’s picture

Code is reviewed and pushed to the community.

rafaelferreir4’s picture

Status: Needs work » Needs review
travis-bradbury’s picture

Status: Needs review » Needs work

Manual review:
* Variables set by the admin form should be deleted on uninstall.

Module duplication

What is the use case for this module versus the ldap module? I get that it's a lot smaller but if I want to authenticate with an LDAP server or create users that don't exist in Drupal yet I can already do that pretty quickly in that module.

  • info file: package should be removed, see "In general, this property should only be used by large multi-module packages, or by modules meant to extend these packages, such as Fields, Views, Commerce, Organic Groups, and the like." from https://www.drupal.org/node/542202#package
  • README.md is probably not what you want when the markdown is rendered.
    - The numbered lists does not render as sub-lists (eg: 1, 1.1, 1.1.1 are all on one line).
    - Headings like "For Developers" and "Similar modules:" could be prefixed with one or more '#' to render as varying sizes of heading text.

ldap_login.module
_ldap_login_validate_ldap_user()

    // Allow other modules to modify the user entity in case of custom fields.
    if (count(module_implements('ldap_login_user_alter')) > 0) {
      // Call all modules that implement the hook,
      // and let them make changes to $drupal_user.
      $drupal_user = module_invoke_all('ldap_login_user_alter', $drupal_user);
    }
    

It's not necessary to wrap this in count(module_implements(...)).

    // TODO: remove this mail creation once all the users from LDAP have the respective email.
    $user_mail = isset($ldap_user->mail) ? $ldap_user->mail : rand('1', '1000') . '@drupalized.co';

* Can you explain the random-number@drupalized.co thing or remove it if it's no longer necessary? $user_mail is used to load the user and is passed in to user_save() and I don't think that a random email would be a desirable thing.

_ldap_login_decode_objectsid()
Is this function named appropriately? It's called decode_objectsid but returns a hash and that's not what I'd think of as "decoded".
This function also appears to be unused - is it stil necessary?

travis-bradbury’s picture

Could you also compare this module to Simple LDAP?

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.