承接 stepansib/ldap 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stepansib/ldap

最新稳定版本:v2.4.1

Composer 安装命令:

composer require stepansib/ldap

包简介

PHP LDAP library functionality packed in a simple class

README 文档

README

SensioLabs Insight Codacy Packagist

1. Installation

Run in your project directory:

composer require stepansib/ldap

2. Usage

1. LDAP object

To configure connection instantiate LDAP object with connection params array:

use StepanSib\LDAP\LDAP;

$ldap = new LDAP2(array(
    'host' => 'server.company.com',
    'username' => 'johndoe',
    'password' => '12345',
    'domain' => 'Company',
    'base_dn' => 'DC=Company,DC=com',
    'anonymous' => false,               // Optional parameter
    'can_login_via_shortname' => true,  // Optional parameter, set to false if your LDAP instance requires authentication by full qualified name
));

2. Connection

To connect and bind to LDAP:

$ldap->connect();

Usage of this method is not necessary because connection will be established automatically when it will needed

3. User authentication

To authenticate any account:

$ldap->authenticate("jdoe", "12345");
$ldap->authenticate("johndoe@company.com", "12345");
$ldap->authenticate("John Doe", "12345");

The username credential can be any of following LDAP entry parameters:

  • cn
  • mail
  • displayname
  • name
  • sAMAccountName

4. Search

To find any record in LDAP directory use the following search method. You need to specify filter string, baseDN string and array of parameters you want to get per entry:

$filter = '(memberOf=CN=Company Management,CN=Users,DC=Company,DC=com)';
//$filter = '&(objectClass=user)(sAMAccountName=jdoe))'; // any valid filter can be passed
$baseDn = 'DC=Company,DC=com';

$data = $ldap->search(
    $filter,
    array(
        'cn',
        'distinguishedname',
        'displayname',
        'department',
        'title',
        'sAMAccountName',
        'mail',
        'displayName'
    ),
    $baseDn,
);

The method returns assoc array with matched entries and their parameters values

5. Close connection

After things was done you need to close connection:

$ldap->close();

统计信息

  • 总下载量: 5.78k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-02