编写 Symfony3 应用程序并尝试配置 symfony/ldap 组件来验证用户身份并从我的 AD 服务器检索用户属性。
据我了解,我需要安装LDAP组件 https://symfony.com/doc/current/components/ldap.html#installation first:
composer require symfony/ldap
安装后我需要配置LDAP客户端 http://symfony.com/doc/current/cookbook/security/ldap.html:
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
not:
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 服务不存在,但事实并非如此......知道为什么会看到此错误设置有问题吗......?