ucsf / ldaporm-bundle
Symfony 3 的 LDAP ORM
5.0.10
2021-04-23 21:29 UTC
Requires
- php: >=7.1.33
- doctrine/orm: ^2.7
- symfony/framework-bundle: ^5.1
- dev-master
- v5.x-dev
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.1.0
- 4.0.1
- 4.0.0
- v3.x-dev
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0.17
- 3.0.16
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.1.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- dev-fresh34
This package is not auto-updated.
Last update: 2024-09-20 04:18:53 UTC
README
一个提供 LDAP ORM 的 Symfony 扩展包。
2020年10月1日。自从 UcsfLdapOrm 处于 Symfony 3.3 兼容性以来已经很久了,但这种情况即将改变。我最终开始了升级过程,并直接移至当时你所阅读时的最新次要版本(Symfony 5)。
最初的努力是使所有东西都符合 Symfony 5,包括它使用的最新版本的 Doctrine。新版本目前处于“v5”分支,并将有一个新的 5.x.x 版本 - 两个主版本的跳跃。这主要是为了使扩展包的主版本与 Symfony 保持一致。在这最初的推动之后,或许在某种程度上,我将对事物进行清理,并进行一些重组和重构。虽然这个扩展包生命的前几年都在增强 Mathieu Goulin 的原始代码,而不想全面重构,但现在到了改变的时候了。
我的目标是到2020年圣诞节前准备好5.1.0版本并将其合并到主分支。
原始 README
这段代码最初是基于 Mathieu Goulin 的 GorgLdapOrmBundle 开发的。我们永远感激他为 UCSF IT 身份与访问管理继续的工作提供了一个优秀的基础。最初,我们分叉了 GorgLdapOrmBundle,但随着我们开发工作的分歧和新增的功能,我们来到了一个新的起点。UcsfLdapOrm 仓库就是从这个新起点创建的。
到目前为止的变化和/或新增内容
- 添加了
LdapEntity
类。这是一个代表top
LDAP 对象类的 Symfony 实体。 - 添加了许多
LdapEntity
的子类来描述从top
到InetOrgPerson
的对象类。 - 添加了
Repository::filterByComplex()
,这使得实体管理器/存储库能够使用自定义构造的复杂布尔逻辑进行筛选。(有关详细信息,请参阅代码注释 API 文档。) - 取消了依赖于 r1pp3rj4ck 的 TwigstringBundle 的依赖,并用 Symfony 2.6+ 的新特性替换了它,即使用 Twig 的新字符串模板功能。
安装
需要 PHP5.5+ 和 Symphony 2.7+
- 添加到 composer.json
"ucsf/ldaporm": "dev-master"
- 将扩展包添加到 AppKernel.php
new Ucsf\LdapOrmBundle\UcsfLdapOrmBundle()
- 使用 composer 安装
$ composer update ucsf/ldaporm-bundle
文档
使用 UcsfLdapOrm 进行开发
在 config.yml 中配置 LDAP 服务
parameters:
some_ldap_server:
uri: ldaps://ldap.example.com
use_tls: true
bind_dn: cn=admin,dc=example,dc=com
password: shhhItsASecret
password_type: plaintext
ucsfldaporm_test: false
- uri: 连接到 LDAP 服务的 URI。
- use_tls: 'true' 或 'false' 决定是否使用 TLS 连接
- bind_dn: 绑定到 LDAP 服务的 DN
- password: 与给定 bind DN 关联的密码
- password_type:
sha1
或plaintext
。当 URI 是 LDAPS 时,我使用 plaintext。
LDAP 实体管理器和服务的依赖注入
services:
myldap_entity_manager:
class: Ucsf\LdapOrmBundle\Ldap\LdapEntityManager
public: true
arguments: ["@logger", "@annotation_reader", "%some_ldap_server%"]
comexample_person_service:
class: MyBundle\ComExamplePersonService
arguments: [ @myldap_entity_manager ]
创建实体(通常用于表示一个对象类)
/**
* Represents a ComExamplePerson object class, which is a subclass of InetOrgPerson
*
* @ObjectClass("comExamplePerson")
* @SearchDn("ou=people,dc=example,dc=come")
* @Dn("uid={{ entity.uid }},ou=people,dc=example,dc=com")
*/
class ComExamplePerson extends InetOrgPerson
{
/**
* @Attribute("comExampleFavoriteIceCreamFlavor")
* @Must()
* @ArrayField()
*
* The @Attribute annotation relates the $comExampleFavoriteIceCreamFlavor member variable to the
* 'comExampleFavoriteIceCreamFlavor' attribute within the ComExamplePerson object class in LDAP.
* You don't have to name the PHP variable the same as your attribute name, but it helps to be
* consistent in this way.
*
* The @Must annotation requires this attribute to not be empty when persisting back to LDAP. If
* a @Must requirement is not satisfied, attempting to persist the entry will throw
* a MissingMustAttributeException.
*
* The @ArrayField aannotation tells the LDAP Entity Manager, repositories and services to treat
* this attribute as a multi-value LDAP field. This is unfortunately backwards from LDAP's default
* to multi-value an attribute. Baring miracles (i.e. finding the time), this will probably not be "fixed".
*
*/
protected $comExampleFavoriteIceCreamFlavor;
...
public function getComExampleFavoriteIceCreamFlavor() {
return $this->comExampleFavoriteIceCreamFlavor;
}
public function setComExampleFavoriteIceCreamFlavor($comExampleFavoriteIceCreamFlavor) {
$this->comExampleFavoriteIceCreamFlavor = $comExampleFavoriteIceCreamFlavor;
}
...
}
编码服务
class ComExamplePersonService {
protected $comExamplePersonRepository;
public function __construct(LdapEntityManager $entityManager) {
// Make a repo for ComExamplePerson entities
$this->comExamplePersonRepository = $entityManager->getRepository(ComExamplePerson::class);
// Make a another repo for SomethignElse entities (just another example...)
$this->somethingElseRepository = $entityManager->getRepository(SomethingElse::class);
...
}
public function getPersonByUid($uid, $includeAddress = false, $attributes = null) {
$person = $this->comExampePersonRepository->findByUid($uid, $attributes);
...
return $person;
}
控制器...使其完整
class PeopleController extends Controller {
/**
* @Route("/person/detail/{uid}")
* @Template()
*/
public function detailAction(Request $request, $uid)
{
$comExamplePersonService = $this->get('comexample_person_service');
$person = $comExamplePersonService->getPersonByUid($uid);
...
return array('person' => $person);
}
待办事项
删除通用LDAP配置的需求配置文档开发示例- 重写测试套件(进行中...)
- 删除已弃用的搜索结果迭代器