PHP Classes
elePHPant
Icontem

Simple LDAP: Manage the records of users in an LDAP server

Recommend this page to a friend!

  Author Author  
Name: Klaus Silveira <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: ???
All time rank: 2718196 in Brazil Brazil
Week rank: 527 Up40 in Brazil Brazil Up


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This class can manage the records of users in an LDAP server.

It can connect to a given LDAP server and send queries to create, retrieve, update and delete user records.

Details

SimpleLDAP

SimpleLDAP is a small library that implements an abstraction layer for LDAP server communication using PHP. It makes your life easier when you need to authenticate users through an LDAP server and/or when you need to perform CRUD actions on it. It's meant to be simple and easy to use. If you need more robust solutions, feel free to expand from SimpleLDAP and create... well, ComplexLDAP.

Authors and contributors

License

New BSD license

Roadmap

  • Keep the code clean and easy to understand
  • Keep the features easy to use
  • Improve the documentation, as well comments

Status

SimpleLDAP is currently under development by the community and is just starting. Feel free to suggest improvements and provide heavy feedback. We really want to hear it! (Seriously, we do!)

Todo

  • better comments for the code, not just methods and properties
  • create a better documentation
  • error handling can be improved, should focus on that
  • develop new features based on user-feedback
  • new features will be made, but always remembering of the library name... SimpleLDAP
  • test, test, test

Using SimpleLDAP

The idea behind SimpleLDAP is to keep things very easy to use, without headaches. In order to start using SimpleLDAP, you'll have to provide a few details, otherwise it won't be able to do it's magic.

$ldap = new LDAP('192.168.0.1', 389, 3); // Host, port and server protocol (this one is optional)
$ldap->dn = 'ou=users,dc=demo,dc=com'; // The default DN (Distinguished Name)

That's it. Now you're able to connect and authenticate to an LDAP server.

$ldap = new LDAP('192.168.0.1', 389, 3);
$ldap->dn = 'ou=users,dc=demo,dc=com';
print_r($ldap->auth('demo', 123456));

The auth method will return the user information as an array if the authentication is successful, and false if it wasn't.

CRUD Actions

If you want to perform administrative actions on the server, such as CRUD, you'll have to bind as an user with administrative rights. That's what the ADN and APass properties are for. They are required for the CRUD actions to be performed correctly.

$ldap = new LDAP('192.168.0.1', 389, 3);
$ldap->dn = 'ou=users,dc=demo,dc=com';
$ldap->adn = 'cn=admin,dc=demo,dc=com';
$ldap->apass = '987654';

Now you can add, remove, modify and list users on the server.

Listing users

You can list users based on a filter and SimpleLDAP will return an array with information about each users that matched that filter. You can read more about those filters here: http://www.mozilla.org/directory/csdk-docs/filter.htm

$ldap = new LDAP('192.168.0.1', 389, 3);
$ldap->dn = 'ou=users,dc=demo,dc=com';
$ldap->adn = 'cn=admin,dc=demo,dc=com';
$ldap->apass = '987654';
print_r($ldap->getUsers('(!(description=warcraft))'));

Creating users

In order to create users, you just need to pass the username you want to create and it's directory information. The directory information should be inside an array.

$ldap = new LDAP('192.168.0.1', 389, 3);
$ldap->dn = 'ou=users,dc=demo,dc=com';
$ldap->adn = 'cn=admin,dc=demo,dc=com';
$ldap->apass = '987654';

$data['cn'][] = 'James';
$data['sn'][] = 'Bond';
$data['uid'][] = 'james';
$data['userpassword'][] = '123456';

$ldap->addUser('james', $data);

Removing users

In order to remove users, you just need to pass the username you want to remove.

$ldap = new LDAP('192.168.0.1', 389, 3);
$ldap->dn = 'ou=users,dc=demo,dc=com';
$ldap->adn = 'cn=admin,dc=demo,dc=com';
$ldap->apass = '987654';

$ldap->removeUser('james');

Modifying users

In order to modify users, you just need to pass the username you want to modify and the new information.

$ldap = new LDAP('192.168.0.1', 389, 3);
$ldap->dn = 'ou=users,dc=demo,dc=com';
$ldap->adn = 'cn=admin,dc=demo,dc=com';
$ldap->apass = '987654';

$data['sn'][] = 'Bonded';

$ldap->modifyUser('james', $data);

  Classes of Klaus Silveira  >  Simple LDAP  >  Download Download .zip .tar.gz  >  Support forum Support forum (1)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Simple LDAP
Base name: simple-ldap
Description: Manage the records of users in an LDAP server
Version: 0.1
PHP version: 5.0
License: BSD License
All time users: 687 users
All time rank: 4596
Week users: 1 user
Week rank: 640 Up
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image Networking Networking protocols, clients and servers View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image User Management User records, authentication and session handling View top rated classes


  User ratings  
Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Accessible without login Plain text file LICENSE.txt Lic. License information
Accessible without login Plain text file README.txt Doc. Library documentation
Accessible without login Plain text file SimpleLDAP.class.php Class SimpleLDAP library

Install with Composer Install with Composer - Download Download all files: simple-ldap.tar.gz simple-ldap.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.