ldaptools / ldaptools-bundle
LdapTools 提供了通过 LdapTools 为 Symfony 简化 LDAP 集成的功能。
0.9.2
2018-06-07 22:01 UTC
Requires
- ldaptools/ldaptools: >=0.25
- symfony/framework-bundle: ~2.7|~3.0|~4.0
Requires (Dev)
- akeneo/phpspec-skip-example-extension: ~2.0
- doctrine/orm: ~2.4
- friendsofphp/php-cs-fixer: ~1.0
- phpspec/phpspec: ~3.0
- symfony/form: ~2.7|~3.0|~4.0
- symfony/security-bundle: ~2.7|~3.0|~4.0
Suggests
- doctrine/doctrine-bundle: For LDAP object type integration in Doctrine.
README
LdapToolsBundle 通过 LdapTools 为 Symfony 提供了简单的 LDAP 集成。
- 包括高级用户界面支持的 LDAP 认证提供者。
- 用于在表单中轻松使用 LDAP 对象的 LDAP 表单类型。
- Doctrine 中的 LDAP 类型,用于轻松存储和检索 Doctrine 实体中的 LDAP 结果。
- LDAP 操作的日志功能。
- Web 调试工具栏的 LDAP 操作集成。
- 使用服务标签集成 LdapTools 事件 进行 LDAP 操作(认证、创建、修改等)。
注意:LdapTools 库需要 PHP 5.6+。
安装
安装 LdapToolsBundle 的推荐方法是使用 Composer。
composer require ldaptools/ldaptools-bundle
然后在内核中启用该捆绑包
// app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new LdapTools\Bundle\LdapToolsBundle\LdapToolsBundle(), ); // ... } }
入门
安装捆绑包后,您可以运行以下命令以帮助生成/测试您的 LDAP 配置
# It will prompt for some basic questions (LDAP server, username/password to use, etc)
php bin/console ldaptools:generate:config
将您的域名(s)添加到 config.yml
文件就像以下示例一样简单
# app/config/config.yml ldap_tools: domains: # The below "example" key can be anything you want. It just has to be a unique name for the YML config. example: # The LDAP FQDN is required domain_name: example.local # The username to use for the LDAP connection username: foo # The password to use for the username password: secret # The base DN for LDAP searches (queried from the RootDSE if not provided) base_dn: "dc=example,dc=local" # The LDAP servers to use for the connection (Queried from DNS if not provided) servers: ["dc1", "dc2", "dc3"] # Define another domain if you want foo: domain_name: foo.bar username: foo password: bar servers: ['dc1.foo.bar', 'dc2.foo.bar'] base_dn: 'dc=foo,dc=bar'
域名配置选项也记录在 LdapTools 文档 中。
然后,在您的控制器中,您可以使用 ldap_tools.ldap_manager
服务查询/修改/创建 LDAP 对象...
class DefaultController extends Controller { public function indexAction() { $ldap = $this->get('ldap_tools.ldap_manager'); $users = $ldap->buildLdapQuery()->fromUsers()->getLdapQuery()->getResult(); $users->count(); foreach ($users as $user) { $user->getFirstName(); $user->getLastName(); $user->getUsername(); } # ... } }
生成/检索您的 LDAP SSL 证书
如果您想快速检索服务器的 LDAP SSL 证书,可以运行一个简单的命令将其输出
# Just supply your LDAP server name... php bin/console ldaptools:generate:sslcert --server "servername"