ldap 组件 Symfony3 配置和设置 [英] ldap component Symfony3 configuration and set up

查看:31
本文介绍了ldap 组件 Symfony3 配置和设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在编写 Symfony3 应用程序并尝试配置 symfony/ldap 组件以验证用户身份并从我的 AD 服务器检索用户属性.

Writing Symfony3 app and trying to config symfony/ldap component to authenticate users and retrieve user attributes from my AD server.

据我所知,我需要先安装 ldap 组件:

so as i understand i need to install the ldap component first:

composer require symfony/ldap

安装后,我需要配置 ldap 客户端:

Once this installed I need to Configure the ldap client:

app/config/services.yml:

services:
    ldap:
        class: 'Symfony\Component\Ldap\Ldap'
        arguments:
            - ldap.forumsys.com # host
            - 389         # port
            - 3           # version
            - false       # SSL
            - true        # TLS

app/config/security.yml:

# http://symfony.com/doc/current/book/security.html
security:

    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
    providers:
        in_memory:
            memory: ~
        my_ldap:
            ldap:
                service: ldap
                base_dn: dc=example,dc=com
                search_dn: "cn=read-only-admin,dc=example,dc=com"
                search_password: password
                default_roles: ROLE_USER
                uid_key: uid

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            anonymous: ~
            # activate different ways to authenticate

            # http_basic: ~
            # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate

            # form_login: ~
            # http://symfony.com/doc/current/cookbook/security/form_login_setup.html

附言.在 services.yml 中,我将一个类设置为:

Ps. in services.yml I put a class as:

Symfony\Component\Ldap\Ldap

不是:

Symfony\Component\Ldap\LdapClient

因为 LdapClient 已被弃用

as LdapClient is deprecated

无论哪种方式,我都会收到此错误:

Either way I get this error:

ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "security.firewall.map.context.main" has a dependency on a non-existent service "ldap".

我理解错误,说在我的 services.yml 中声明的 ldap 服务不存在,但事实并非如此......知道为什么会看到这个错误,设置有什么问题......?

I understand the error saying that the ldap service declared in my sertvices.yml does not exist which is not the case.... Any idea why am seeing this error anything wrong with the set up...?

推荐答案

嘿 好吧 我设法找到了解决这个问题的方法基本上是由于我的 Symfony 3.0.9 版本,它必须是 3.1.0 或更高版本.

Hey All well I managed to find the solution to this problem basically it was due to my Symfony version 3.0.9 and it has to be 3.1.0 or above.

这篇关于ldap 组件 Symfony3 配置和设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆