open-wide/ezpublish-synchronizeldapuser-bundle

同步 Ldap 用户到 Ezpublish 5.3 或更高版本

v1.1 2015-04-23 05:52 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:52:38 UTC


README

https://github.com/Open-Wide/OWSynchronizeLdapUserBundle/raw/master/doc/images/Open-Wide_logo.png

演示

此包将连接 ldap 用户,并在 ezpublish 中创建 ldap 用户(如果没有的话)。

许可证

此 eZ Publish 扩展以原样提供,遵循 GPL v3(见 LICENCE)

你需要什么?

EzPublish 5.3 或 5.4 IMAG/LDAP Bundle 配置 security.yml 和 config.yml

配置 IMAG/LDAP Bundle

请参阅 https://github.com/BorisMorel/LdapBundle

获取 Bundle

Composer

在您的项目 composer.json 中添加 OpenWideSynchronizeLdapUser

{
    "require": {
        "open-wide/synchronizeldapuser-bundle": "dev-master"
    }
}

启用 Bundle

<?php
// ezpublish/EzPublishKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new OpenWide\SynchronizeLdapUserBundle\OpenWideSynchronizeLdapUserBundle(),
    );
}

配置 ezpublish 用户和用户组类

您必须在您的用户和用户组类中创建字段,例如:mail, cn, sn, uid……在 config.yml 中声明的字段必须存在。

配置用户组

创建一个用户组,例如 UserLDAP。在 parent_group_content_id 和 parent_group_location_id 中配置 content_id 和 location_id。Ldap 用户将在此组中创建。

配置 yml

首先配置 security.yml。

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        IMAG\LdapBundle\User\LdapUser: plaintext

    role_hierarchy:
        ROLE_USER:          IS_AUTHENTICATED_ANONYMOUSLY
        ROLE_INSCRIT:       ROLE_USER

    providers:
        chain_provider:
            chain:
                providers: [ldap,ezpublish]
        ezpublish:
            id: ezpublish.security.user_provider
        ldap:
            id: imag_ldap.security.user.provider

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        ezpublish_setup:
            pattern: ^/ezsetup
            security: false

        ezpublish_rest:
            pattern: ^/api/ezp/v2
            stateless: true
            ezpublish_http_basic:
                realm: eZ Publish REST API

        ezpublish_front:
            pattern: ^/
            anonymous: ~
            imag_ldap:
                provider: chain_provider
            form_login:
                require_previous_session: false
                always_use_default_target_path: false
                default_target_path: /

security:
    access_control:

        # Routes exceptions sans accès loggué
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # Routes avec accès loggué
        - { path: ^/, role: [ROLE_USER] }

然后配置 config.yml。

openwide_synchronize_ldap_user:
    enabled: true
    synchronize: true
    parent_group_content_id: 223
    parent_group_location_id: 218
    mode: update
    verbose: true
    #you must define at least one field in user and group (example dn)
    fields:
        user:
            dn: { value: dn }
            first_name: { value: sn}
            last_name: { value: sn}
            mail: { value: mail }
            cn: { value: cn }
            sn: { value: sn }
            uid: { value: uid }
            givenname: { value: givenName }
        group:
            name: { value: ou }
            ou: { value: ou }
            cn: { value: cn }
            dn: { value: dn }
    ldap:
        base_dn: dc=example,dc=com
        filter_user: '(&(objectclass=person)(uid=**USERNAME**))'
        filter_group: '(&(objectclass=groupOfUniqueNames)(uniquemember=uid=**USERNAME**,dc=example,dc=com))'

DOC

enabled
启用或禁用 Bundle
synchronize
如果启用,则 Bundle 会同步用户。它会在 EZ 基中复制用户和组
parent_group_content_id
所有用户都将复制的用户组内容标识符
parent_group_location_id
所有用户都将复制的用户组位置标识符
mode
add: 第一次连接时创建用户 update: 第一次连接时创建用户然后修改
verbose
如果启用,您将在日志文件中写入更多信息
fields
用户和用户组复制的字段列表 语法:<Ez Field>: { value: <LDAP field>}
ldap
配置 ldap 搜索过滤器