Thursday, April 1, 2010

Implement LDAP facility in OrangeHRM

Hi all this article is about enabling LDAP authentication procedure in OrangeHRM so it has been considered from my side that you must have the knowlwdge about Orange HRM system.

If you are not aware of OHRM, then please go to www.orangehrm.com

I have implemented this facility using adLDAP which is nothing but a PHP class that provides LDAP authentication and integration with Active Directory. Another thing that I have installed OrangeHRM on win XP.

Please follow below steps to achieve LDAP implementation

  1. Download adLDAP from adLDAP Download
  2. Extract the zip containing adLDAP PHP class and place the adLDAP.php to OrangeHRM root directory as web_content(PHP root)/OrangeHRM/lib/common/ldap/adLDAP.php (create ldap directory as it is not present there)
  3. Now before start coding, please read the documentation of adLDAP at adLDAP Documentation because adLDAP class needs some information related to your ADS server to get connected
  4. Find login.php of OrangeHRM in which modification will be done
  5. Comment the existing code to handle LDAP module
  6. Below that write following piece of code
    require_once(dirname(__FILE__) . '/lib/common/ldap/adLDAP.php');
    $adldap = new adLDAP();
    $ldapFile = ROOT_PATH . "/lib/common/ldap/adLDAP.php";
    $_SESSION['ldap'] = "enabled";
    $_SESSION['ldapStatus'] = "enabled";
  7. Now call the adLDAP class's method authenticate() using adLDAP object in place of ldapAuth() as shown at the place of authentication code
    $ldapAuth = $adldap->authenticate($rset[0][0], $_POST['txtPassword']);
  8. Create the users in OrangeHRM same as ADS server with blank passwords
  9. Now start login with ADS authentication credentials
Please follow How to enable LDAP to get information about OrangeHRM LDAP module work

Hey as above has done with OrangeHRM using adLDAP, both are opensource projects developed using PHP. In my case it has been worked successfully. As I have also searched for this issue drastically but didn't got any solution so after achieved the solution me presenting this piece of work to you. Please let me know your reviews and comments if any...


Thanks

28 comments:

  1. Thanks brother I googled like crazy guns to handle this issue but got complete solution at you...

    And it's working too

    Thank u very much

    ReplyDelete
    Replies
    1. Hi Please, could you help with doing this step by step as I am not very old with PHP yet

      Delete
  2. Dear All,

    Is it possible to send me all completed files?

    Much appreciate if you could help on this.

    Thank you,

    My email address: terence.kiat@gmail.com

    Thank you so much..

    ReplyDelete
  3. i got this error, somebody can help me? very upset here

    Fatal error: Uncaught exception 'adLDAPException' with message 'No LDAP support for PHP. See: http://www.php.net/ldap' in C:\xampp\htdocs\hrm\lib\common\ldap\adLDAP.php:338 Stack trace: #0 C:\xampp\htdocs\hrm\login.php(65): adLDAP->__construct() #1 {main} thrown in C:\xampp\htdocs\hrm\lib\common\ldap\adLDAP.php on line 338

    ReplyDelete
  4. Seems that LDAP facility not been enabled, Please follow

    http://www.php.net/manual/en/ldap.installation.php

    Reply if not resolved...

    ReplyDelete
  5. Hey can you let me know the version of OrangeHRM and adLDAP used, because i am facing lot of problem while configuring same.

    Also, can you please mail me those configuration file, will be very thankful. Stuck with this project.

    Mail : rick.rocx@gmail.com

    Thank you in advance

    ReplyDelete
  6. The implementation has been done on
    OrangeHRM 2.5
    adLDAP 3.3.1

    ReplyDelete
  7. This doesn't work for me either, I commented out everything within the first /* LDAP Module */ and the 2nd /* LDAP Module */ and added this below it:
    require_once(dirname(__FILE__) . '/lib/common/ldap/adLDAP.php');
    $adldap = new adLDAP();
    $ldapFile = ROOT_PATH . "/lib/common/ldap/adLDAP.php";
    $_SESSION['ldap'] = "enabled";
    $_SESSION['ldapStatus'] = "enabled";
    $ldapAuth = $adldap->authenticate($rset[0][0], $_POST['txtPassword']);

    I got error saying "Undefined variable: rset"
    Can you clarify? Thanks

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Seems you didn't configured your adLDAP class. It requires some information related to your ADS server please refer to the link http://adldap.sourceforge.net/wiki/doku.php?id=api for further details and set the adLDAP class variables such as

    protected $_account_suffix = "@example.local";
    protected $_base_dn = "DC=example,DC=local";
    protected $_domain_controllers = array ("example-controller.example.local");

    Use your server credentials
    It is easy

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I am getting this error after admin login and can't create users.

      Warning
      require_once(C:\xampp\htdocs\orangehrm25/plugins/ldap/LdapDetails.php) [function.require-once]: failed to open stream: No such file or directory

      Technical Details
      Encountered the problem in C:\xampp\htdocs\orangehrm25\lib\controllers\ViewController.php Line 69

      Please help me out.

      Delete
  10. I use the same adLDAP class together with putting some other files (and not modifying login.php) under plugins/ldap folder and successfully enabled LDAP authentication. Now I want to implement IWA (Integrated Windows Authentication) so that our users don't have to keyin username/password. Do you have any idea about that?

    ReplyDelete
    Replies
    1. can you please provide the other files you have put under plugins/ldap folder ?

      naeem.ijaz@hotmail.com
      naeem.ijaz81@gmail.com

      Regards,

      Delete
  11. Hi,

    I tried to implement adldap in the version 2.6.11 of orangehrm. And I cannot connect to the application using my ldap login.
    The only message I have is invalid credentials. I already tried the adldap classes and they are ok.

    Did you tried to implement adldap with this version ?

    I will be pleased to here your feedbacks.

    Thanks.

    Best regards

    Paps

    ReplyDelete
  12. I installed OpenHRM 2.6.11 and tried to implement ldap login, but could not find the login.php file referenced in your post. I assume they have changed structure of how authentication works since. How do I implement LDAP authentication in this new version? Thanks!

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Hi

    I am also looking into ldap authentication for orangehrm , I am not able to find the common folder in orangehrm location , as you mention in your previous posts /OrangeHRM/lib/common/ldap/adLDAP.php .

    I am not able to find the "common folder" please kindly help to solve this

    ReplyDelete
  15. we are using orangehrm 3.0.1 version. please help us in implementing ldap authentication in orangehrm 3.0.1..

    Thankyou..

    ReplyDelete
  16. Hi, I'm using orangeHRM 3.0.1. The Structure of orangeHRM is quite different as well as how the program works. So could you guide me toward implementing the above mentioned functionality in orangeHRM 3.0.1. I'm very new to symfony and orangeHRM , so it will be a great help if you do

    ReplyDelete
    Replies
    1. were you helped when you sent this request comment

      Delete
  17. Hi!
    We already have an LDAP Server configured,so how can i just bind it to HRM? Do I have to follow the same procedure? Thank you

    ReplyDelete
  18. I am also using orangeHRM 3.0.1, could you send me the config file for this version.
    masanafu@gmail.com

    Much appreciated.

    ReplyDelete
  19. I installed OpenHRM 3.1.1 and tried to implement ldap login, but could not find the login.php file referenced in your post. I assume they have changed structure of how authentication works since. How do I implement LDAP authentication in this new version? Thanks!

    ReplyDelete
  20. I installed OrangeHRM 3.0.1 how to implement adldap process please help me

    ReplyDelete
  21. Good Enhancement Sandeep Sir!!!

    ReplyDelete
  22. what is the path for login.php in orangeHRM directory ? I am unable to find it. Please help

    ReplyDelete
  23. Can u plz make a short tutorial video for best option

    ReplyDelete