openldapobject/ldapobjectbundle
Composer 安装命令:
composer require openldapobject/ldapobjectbundle
包简介
Symfony2 Bundle for OpenLdapObject
README 文档
README
LdapObjectBundle : Symfony2 Bundle for OpenLdapObject
LdapObjectBundle is a Symfony2 Bundle. It is an interface for retrieving, modifying and persisting LDAP entities. It requires an another Bundle : the OpenLdapObject Bundle which is the simple connector LDAP using PHP's native LDAP functions. It can be use with Symfony version 2, 3 and 4, and add a system of complex Query and Conditions LDAP.
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require openldapobject/ldapobjectbundle "~1"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Or add the bundle in your composer.json and launch this command composer update
...
"require" : {
...
"openldapobject/ldapobjectbundle": "~1.0",
...
},
...
Step 2: Configuration
Add configuration keys in the app/config/parameters.yml and app/config/parameters.yml.dist and configure for your openldap :
ldap_hostname: ldap-test.univ.fr
ldap_base_dn: 'dc=univ,dc=fr'
ldap_dn: 'cn=login,ou=ldapusers,dc=univ,dc=fr'
ldap_password: 'password'
Add configuration keys for the bundle in app/config/config.yml
# Ldap
open_ldap_object_ldap_object:
host: "%ldap_hostname%"
dn: "%ldap_dn%"
password: "%ldap_password%"
base_dn: "%ldap_base_dn%"
Step 3: Enable the Bundle
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new OpenLdapObject\Bundle\LdapObjectBundle\OpenLdapObjectLdapObjectBundle(), ); // ... } // ... }
Step 4: Use the Bundle
To use the LdapObjectBundle you have to add annotation to an entity like this example:
For Accounts :
<?php namespace AppBundle\Entity; use OpenLdapObject\Entity; use OpenLdapObject\Collection\EntityCollection; use OpenLdapObject\Annotations as OLO; /** * @OLO\DN(value="ou=accounts") * @OLO\Entity({"udlAccount"}) */ class Account extends Entity { /** * @OLO\Column(type="string") * @OLO\Index */ private $uid; /** * @OLO\Column(type="array") */ private $sn; /** * @OLO\Column(type="array") */ private $udlAccountDisplaySn; /** * @OLO\Column(type="array") */ private $givenName; /** * @OLO\Column(type="array") */ private $udlAccountDisplayGivenName; /** * @OLO\Column(type="string") */ private $mail; /** * @OLO\Column(type="string") */ private $supannEntiteAffectationPrincipale; /** * @OLO\Column(type="string") */ private $eduPersonPrimaryAffiliation; /** * @OLO\Column(type="array") */ private $eduPersonAffiliation; /** * @OLO\Column(type="array") */ private $supannEntiteAffectation; /** * @OLO\Column(type="string") */ private $supannCivilite; /** * @OLO\Column(type="array") */ private $memberOf; public function getUid() { return $this->uid; } public function setUid($value) { $this->uid = $value; return $this; } public function getSn() { return $this->sn; } public function setSn($sn) { $this->sn = $sn; return $this; } public function addSn($value) { $this->sn->add($value); return $this; } public function removeSn($value) { $this->sn->removeElement($value); return $this; } public function getGivenName() { return $this->givenName; } public function setGivenName($givenName) { $this->givenName = $givenName; return $this; } public function addGivenName($value) { $this->givenName->add($value); return $this; } public function removeGivenName($value) { $this->givenName->removeElement($value); return $this; } public function getUdlAccountDisplayGivenName() { return $this->udlAccountDisplayGivenName; } public function setUdlAccountDisplayGivenName($udlAccountDisplayGivenName) { $this->udlAccountDisplayGivenName = $udlAccountDisplayGivenName; return $this; } public function addUdlAccountDisplayGivenName($value) { $this->udlAccountDisplayGivenName->add($value); return $this; } public function removeUdlAccountDisplayGivenName($value) { $this->udlAccountDisplayGivenName->removeElement($value); return $this; } public function getUdlAccountDisplaySn() { return $this->udlAccountDisplaySn; } public function setUdlAccountDisplaySn($udlAccountDisplaySn) { $this->udlAccountDisplaySn = $udlAccountDisplaySn; return $this; } public function addUdlAccountDisplaySn($value) { $this->udlAccountDisplaySn->add($value); return $this; } public function removeUdlAccountDisplaySn($value) { $this->udlAccountDisplaySn->removeElement($value); return $this; } public function getMail() { return $this->mail; } public function setMail($value) { $this->mail = $value; return $this; } public function getSupannEntiteAffectationPrincipale() { return $this->supannEntiteAffectationPrincipale; } public function setSupannEntiteAffectationPrincipale($supannEntiteAffectationPrincipale) { $this->supannEntiteAffectationPrincipale = $supannEntiteAffectationPrincipale; return $this; } public function getEduPersonPrimaryAffiliation() { return $this->eduPersonPrimaryAffiliation; } public function setEduPersonPrimaryAffiliation($eduPersonPrimaryAffiliation) { $this->eduPersonPrimaryAffiliation = $eduPersonPrimaryAffiliation; return $this; } public function getEduPersonAffiliation() { return $this->eduPersonAffiliation; } public function setEduPersonAffiliation($eduPersonAffiliation) { $this->eduPersonAffiliation = $eduPersonAffiliation; return $this; } public function addEduPersonAffiliation($value) { $this->eduPersonAffiliation->add($value); return $this; } public function removeEduPersonAffiliation($value) { $this->eduPersonAffiliation->removeElement($value); return $this; } public function getSupannEntiteAffectation() { return $this->supannEntiteAffectation; } public function setSupannEntiteAffectation($supannEntiteAffectation) { $this->supannEntiteAffectation = $supannEntiteAffectation; return $this; } public function addSupannEntiteAffectation($supannEntiteAffectation) { $this->supannEntiteAffectation->add($supannEntiteAffectation); return $this; } public function removeSupannEntiteAffectation($supannEntiteAffectation) { $this->supannEntiteAffectation->removeElement($supannEntiteAffectation); return $this; } public function getSupannCivilite() { return $this->supannCivilite; } public function setSupannCivilite($value) { $this->supannCivilite = $value; return $this; } public function getMemberOf(){ return $this->memberOf; } public function setMemberOf($memberOf) { $this->memberOf = $memberOf; return $this; } public function addMemberOf($memberOf) { $this->memberOf->add($memberOf); return $this; } public function removeMemberOf($memberOf) { $this->memberOf->removeElement($memberOf); return $this; } }
- Name of each attributes are the ldap object field
- Column : Use this annotation to type the ldap object field (string or array)
- Entity : Use this annotation to attribute to a php entity class an ldapObjectClass
- Dn : Use this annotation to build the dn with twig syntaxe
After you can use entity like this example:
$a = new Account(); $a->setUid('john.doo'); $a->setGivenname('John'); $a->setSn('Doo'); $em = $this->get('ldap_object.manager'); $em->persist($a); $em->flush(); $repo = $em->getRepository('AppBundle\Entity\Account'); $a = $repo->find('john.doo');
you also can set complex request ldap :
$conditions = Array(); $not = true; $conditions[] = new Condition('sn', 'Hetru'); $conditions[] = new Condition('sn', 'Bomy', $not); $query = new Query(Query::CAND); $query->cAnd($conditions); $em = $this->get('ldap_object.manager'); $repo = $em->getRepository('AppBundle\Entity\Account'); $a = $repo->findByQuery($query);
For Groups :
<?php namespace AppBundle\Entity; use OpenLdapObject\Entity; use OpenLdapObject\Annotations as OLO; /** * @OLO\Dn(value="ou=groups") * @OLO\Entity({"udlGroupe"}) */ class Group extends Entity { /** * @OLO\Column(type="string") * @OLO\Index */ private $cn; /** * @OLO\Column(type="string") */ private $description; /** * @OLO\Column(type="array") */ private $member; public function getCn() { return $this->cn; } public function setCn($cn) { $this->cn = $cn; return $this; } public function getDescription() { return $this->description; } public function setDescription($description) { $this->description = $description; return $this; } public function getMember() { return $this->member; } public function setMember($member) { $this->member = $member; return $this; } public function addMember($member) { $this->member->add($member); return $this; } public function removeMember($member) { $this->member->removeElement($member); return $this; } }
After you can use entity like this example:
$g = new Group(); $g->setCn('APP:TEST'); $g->setDescription('APPTEST'); $g->addMember('uid=1940,ou=accounts,dc=univ,dc=fr'); $em = $this->get('ldap_object.manager'); $em->persist($g); $em->flush(); $repo = $em->getRepository('AppBundle\Entity\Group'); $g = $repo->find('APP:TEST');
For Structures :
<?php namespace AppBundle\Entity; use OpenLdapObject\Entity; use OpenLdapObject\Annotations as OLO; /** * @OLO\Dn(value="ou=structures") * @OLO\Entity({"udlStructure"}) */ class Structure extends Entity { /** * @OLO\Column(type="string") * @OLO\Index */ private $supannCodeEntite; /** * @OLO\Column(type="string") */ private $ou; /** * @OLO\Column(type="string") */ private $supannCodeEntiteParent; /** * @OLO\Column(type="string") */ private $description; /** * * @OLO\Column(type="string") */ private $udlStructureLibelleCourt; public function getSupannCodeEntite() { return $this->supannCodeEntite; } public function setSupannCodeEntite($supannCodeEntite) { $this->supannCodeEntite = $supannCodeEntite; return $this; } public function getOu() { return $this->ou; } public function setOu($ou) { $this->ou = $ou; return $this; } public function getSupannCodeEntiteParent() { return $this->supannCodeEntiteParent; } public function setSupannCodeEntiteParent($supannCodeEntite) { $this->supannCodeEntiteParent = $supannCodeEntite; return $this; } public function getDescription() { return $this->description; } public function setDescription($description) { $this->description = $description; return $this; } public function getUdlStructureLibelleCourt() { return $this->udlStructureLibelleCourt; } public function setUdlStructureLibelleCourt($udlStructureLibelleCourt) { $this->udlStructureLibelleCourt = $udlStructureLibelleCourt; return $this; } }
After you can use entity like this example:
$s = new Structure(); $s->setSupannCodeEntite('STTRUCMUCHE'); $s->setOu('STTRUCMUCHE); $s->setSupannCodeEntiteParent('STUDL'); $s->setDescription('{acronyme1}STRUCTURE TRUC MUCHE'); $em = $this->get('ldap_object.manager'); $em->persist($s); $em->flush(); $repo = $em->getRepository('AppBundle\Entity\Structure'); $s = $repo->find('STTRUCMUCHE');
openldapobject/ldapobjectbundle 适用场景与选型建议
openldapobject/ldapobjectbundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.89k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Symfony2」 「bundle」 「ldap」 「object」 「mapping」 「openldap」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 openldapobject/ldapobjectbundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 openldapobject/ldapobjectbundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 openldapobject/ldapobjectbundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
LDAP user provider bundle for Symfony 6.4
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 1.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-27