编写Symfony3应用程序并尝试配置symfony / ldap组件以对用户进行身份验证并从我的AD服务器检索用户属性。
据我所知,我需要先安装ldap component:
composer require symfony/ldap
安装完成后,我需要配置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我把一个类放在:
Symfony\Component\Ldap\Ldap
不
Symfony\Component\Ldap\LdapClient
不推荐使用LdapClient
无论哪种方式,我都会收到此错误:
ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "security.firewall.map.context.main" has a dependency on a non-existent service "ldap".
我理解错误说我的sertvices.yml中声明的ldap服务不存在,但事实并非如此....任何想法为什么看到这个错误设置有什么问题......?
答案 0 :(得分:1)
在您的services.yml文件中,您是否尝试过不带这样的引号:
services:
ldap:
class: Symfony\Component\Ldap\Ldap
我不确定指定课程的正确方法。
答案 1 :(得分:0)
嘿所有我很好地找到了解决这个问题的方法基本上是由于我的Symfony版本3.0.9而且必须是3.1.0或更高版本。