newtondasilva/ldaptools-bundle

通过 LdapTools 为 Symfony 提供简单的 LDAP 集成。

安装: 12

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 29

类型:symfony-bundle

1 2017-03-16 18:10 UTC

This package is not auto-updated.

Last update: 2024-09-17 04:05:36 UTC


README

LdapToolsBundle 通过 LdapTools 为 Symfony 提供简单的 LDAP 集成。

  • 包括高级用户界面支持的 LDAP 身份验证提供者
  • 一个 LDAP 表单类型,以便在表单中轻松使用 LDAP 对象。
  • Doctrine 的 LDAP 类型,以便轻松存储和检索 Doctrine 实体中的 LDAP 结果。
  • LDAP 操作的日志记录功能。
  • LDAP 操作的 Web 调试工具栏集成。
  • 使用服务标签集成 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 域配置它

# 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"

文档