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.

Requirements

Yii 1.1.14 or above (not tested on earlier versions)

Installation

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

Usage

In config file:

'components'=>array(
		'ldap'=>array(
			'class'=>'application.extensions.adLDAP.YiiLDAP',
			 // 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";
  }
}

Resources

2 0
10 followers
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

Downloads

show all

Related Extensions