Auth_Ldap: LDAP Authentication Library for CodeIgniter

 

This was first presented in my post LDAP Authentication with CodeIgniter.  This is just a simple library that wraps up the necessary LDAP calls to authenticate a user against LDAP and then set a session cookie that identifies the user as logged in.

Usage is relatively simple: unpack the archive and copy the files into the appropriate CodeIgniter libraries for your application.  This usually just means mirroring the directory structure in the zip file over to your CodeIgniter install.  The directory structure should look something like this:

The files controllers/auth.php, views/auth/login_form.php, and views/auth/logout_view.php are not necessary for the functionality of the library and are provided as an example of how to use AuthLDAP within your application.

Downloads:

AuthLDAP (2261)
 Posted by at 14:00:40 pm

  8 Responses to “Auth_Ldap: LDAP Authentication Library for CodeIgniter”

  1. Hi,

    Am getting the following error when configuring for Active Directory:

    Error looking up DN for coolvixs: Success

    My configs as follows:

    $config['ldap_uri'] = array(‘ldap://example.com:389/’);
    $config['use_tls'] = false; // Using SSL above, don’t use TLS with it
    $config['search_base'] = ‘DC=example,DC=com’;
    $config['user_search_base'] = ”;
    $config['group_search_base'] = ”;
    $config['user_object_class'] = ‘user’;
    $config['group_object_class'] = ‘group’;
    $config['user_search_filter'] = ”;
    $config['group_search_filter'] = ”;
    $config['login_attribute'] = ‘sAMAccountName’;
    $config['schema_type'] = ‘ad’; // Could also use rfc2307bis
    $config['proxy_user'] = ‘CN=Admin,CN=Users,DC=staff,DC=example,DC=com
    $config['proxy_pass'] = ‘xxxxxx’;
    $config['roles'] = array(1 => ‘User’,
    3 => ‘Power User’,
    5 => ‘Administrator’);
    $config['auditlog'] = ‘application/logs/audit.log’;

    Would be grateful if you could advise where am going wrong…

    Thanks in advance

  2. Hello.

    I would like to ask your help.

    can you write down step by step to install this in CI.

    TQ.

  3. Thanks a lot for this script ! I’ll test it ! :)

  4. Thanks for the great plugin. I have updated to the newer version and now I’m getting this error:

    Message: ldap_connect() [function.ldap-connect]: Could not create session handle: Bad parameter to an ldap routine

  5. im succes to login, but i want to know my uid_number and gid_number, can u help me

  6. libraries/AuthLDAP.php line 193 – uses ldapconn() as a function when it’s a variable; need to drop the ()

    controlllers/auth.php refers to ‘authldap.php’ when it should be ‘AuthLDAP.php’; I’m guessing you are using a case insensitive filesystem/OS.

  7. Thanks for this useful script. Saved me some time.

    For my uses, I had to disable all mentions of roles in order for everything to work. We don’t set anything like this where I work and I don’t have control over it. It took me a while to figure that out, though, because the error message I received said “Group search successful but no memberships were found.”

    After commenting out all things related to roles and removing any vars that were related to roles, everything worked great.

    The next helpful thing I did was autoload the session library. This is key if you want to be able to access the session vars that this library sets. Then in my “view page” controller, I check to see if ‘logged_in’ is set before showing the user anything.

    [code]$this->session->userdata('logged_in') ? null : redirect('auth');[/code]

    I hope this is useful to anyone else who runs into it.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">