yii-adldap Active directory support with authorization example

  1. Requirements
  2. Installation
  3. Usage
  4. Resources

Active directory support for Yii provided by adLDAP class.


Yii 1.1.14 or above (not tested on earlier versions)


Copy adLDAP directory to extensions dir. Copy UserIdentity.php to components dir if you want support for AD authorization.


In config file:

			 // those are standard adLDAP options check http://adldap.sourceforge.net/ for documentation
			 'options'=> array(
		                    'ad_port'      => 389,
		                    'domain_controllers'    => array('ad_server'),
		                    'account_suffix' =>  '@domain_name',
		                    'base_dn' => NULL,
				    // for basic functionality this could be a standard, non privileged domain user (required)
		                    'admin_username' => 'jdoe',
		                    'admin_password' => 'password',

Example usage in every place of an application:

// gather info about domain computer
Yii::app()->ldap->computer()->info('computer_name', null);

If you would like to use UserIdentity class included in this package you could also get Active Directory information about authorized user:

// in template file
if(isset(Yii::app()->user->displayname) {
  echo Yii::app()->user->displayname; // or any other field from UserIdentity $_fields property

if(isset(Yii::app()->user->groups) {
  foreach(Yii::app()->user->groups as $group) {
    echo 'User belongs to: ' . $group ."\n";


2 0
1 478 downloads
Yii Version: Unknown
License: GPL-2.0
Category: Networking
Developed by: Fedek6
Created on: Nov 7, 2013
Last updated: 10 years ago


show all

Related Extensions