承接 mikebywater/ldap 相关项目开发

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

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

mikebywater/ldap

Composer 安装命令:

composer require mikebywater/ldap

包简介

My simple, crude LDAP package

关键字:

README 文档

README

Installation

Composer

To install simply put the following in your composer json file

"require": {
  		"mikebywater/ldap": "dev-master"
},

next simply run

composer update

Parameters

ldap relies on global variables being set.

Laravel

In Laravel simply set the variables below in the .env file

LDAP_SERVER =server.example.com
LDAP_DOMAIN=mydomain
LDAP_BASE_DSN=dc=example,dc=com
LDAP_ADMIN_USER=admin
LDAP_ADMIN_PASSWORD=password

Usage

Authenticating a user

use mikebywater\LDAP\LDAP as LDAP;
$ldap = new LDAP();
$username = 'testmember';
$password = 'test123';
if($ldap->authenticate($username,$password))
{
 echo "Authenticated";
}
else
{
    echo "Invalid Credentials";
}

Searching LDAP

use mikebywater\LDAP\LDAP as LDAP;
// Instantiate object
$ldap = new LDAP();
$username = "george.land";
// Method chaining allows us to bind to ldap, apply an ldap filter and get the first result
$entry = $ldap->bind()->filter("sAMAccountName=$username")->get()->first();

Extracting user Details from an entry

By using the LDAPUser class we can get user details from an entry

use mikebywater\LDAP\LDAPUser as LDAPUser;
// Instantiating the object requires you to pass your ldap connection and the entry
// from the previous example
$user = new LDAPUser($ldap->conn, $entry);
$name =  $user->getName(); //special function for display name
$email = $user->getEmail(); //special function foe mail attributes
$company= $user->__get('company')[0]; // any other attribute can be grabbed with magic get method (beware will return an array)
$description= $user->__get('description')[0];

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-25