Skip to content

Kloadut/ldapOrm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

ldapOrm

A simple PHP LDAP ORM

Usage

  1. Include the single php file require 'ldapOrm.php';
  2. Create a 'models' directory
  3. Create your models
  4. Initialize the ldapOrm with the command
$ldap = new LdapEntry('yourLdapServer', 'your.___domain.name', 'your/model/directory');

LDAP Server is usually localhost, and ___domain name corresponds to the dc attribute in LDAP

Model building

There is some settings to do in your model file:

  • Name your file in lowercase, with the exact name of your model, e.g mymodel.php
  • Initialize the model class by calling class Mymodel extends LdapEntry {...}

The model name's first letter must be uppercased and must correspond to the model filename.

  • The $options array contains 3 parameters:
    • dnPattern: contains the key attribute of the DN
    • searchPath: contains the name of the group if exists
    • objectClass: objectClasses of the model
$options = array
           (
              'dnPattern'     => array('cn' => ''),
              'searchPath' 	  => array('ou' => 'mygroupname'),
              'objectClass' 	=> array('myFirstObjectClass', 'mySecondObjectClass')
           );
  • The $fields array contains all the model attributes and its optionnal parameters listed below:
    • required: true|false (default false)
    • unique: true|false (default false) - Set it to true if
    • minLength: (default 0) - Minimum length of the field value
    • maxLength: (default 1024) - Maximum length of the field value
    • pattern: (default null) - Pattern that the field must match, regex style
$fields = array
(
    'mymailfield' => array
    (       
        'required' => true,
        'unique'   => true,
        'pattern'  => '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#'
    ),
    'myotherfield' => array
    (
        'required' => false,
        'minLength' => 1,
        'maxlength' => 30
    )
);

You can see a full example in the user.php model

About

A simple LDAP ORM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages