Php Symfony3 LDAP用户身份验证
我正在编写一个Symfony3应用程序,希望为用户登录配置LDAP连接 因此,我需要连接到服务目录获取用户对象,并在用户名和密码是否与用户登录页面输入匹配的情况下签入该对象 为了实现这一目标,我计划结合使用这两个捆绑包:Php Symfony3 LDAP用户身份验证,php,symfony,ldap,Php,Symfony,Ldap,我正在编写一个Symfony3应用程序,希望为用户登录配置LDAP连接 因此,我需要连接到服务目录获取用户对象,并在用户名和密码是否与用户登录页面输入匹配的情况下签入该对象 为了实现这一目标,我计划结合使用这两个捆绑包: FR3DLdapBundle FOSUserBundle 但是有一点我不明白,即:对于FOSUserBundle,我将创建用户实体,这个用户实体类params是否需要作为SD对象的属性 此外,我还有一个应用程序数据库,我只想使用LDAP连接来验证用户身份,因为用户名和密码存储
FR3DLdapBundle
FOSUserBundle
但是有一点我不明白,即:对于FOSUserBundle,我将创建用户实体,这个用户实体类params是否需要作为SD对象的属性
此外,我还有一个应用程序数据库,我只想使用LDAP连接来验证用户身份,因为用户名和密码存储在那里
你们能帮我理解这个过程吗
Symfony LDAP组件错误:
因此,我按照SYmfony文档复制了代码,但即使代码相同,仍然收到此错误消息:
ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "security.authentication.manager" has a dependency on a non-existent service "app.ldap".
in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58
at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(object(Reference), object(Reference), 'api', object(Reference), '{username}@example', true)) in CheckExceptionOnInvalidReferenceBehaviorPass.php line 42
at CheckExceptionOnInvalidReferenceBehaviorPass->processDefinition(object(Definition)) in CheckExceptionOnInvalidReferenceBehaviorPass.php line 53
at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(object(Definition), object(Definition), object(Definition))) in CheckExceptionOnInvalidReferenceBehaviorPass.php line 51
at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(array(object(Definition), object(Definition), object(Definition)), true)) in CheckExceptionOnInvalidReferenceBehaviorPass.php line 42
at CheckExceptionOnInvalidReferenceBehaviorPass->processDefinition(object(Definition)) in CheckExceptionOnInvalidReferenceBehaviorPass.php line 36
at CheckExceptionOnInvalidReferenceBehaviorPass->process(object(ContainerBuilder)) in Compiler.php line 104
at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 545
at ContainerBuilder->compile() in Kernel.php line 477
at Kernel->initializeContainer() in Kernel.php line 117
at Kernel->boot() in Kernel.php line 166
at Kernel->handle(object(Request)) in app_dev.php line 30
at require('app_dev.php') in router_dev.php line 40
app/config/services.yml:
services:
app.ldap:
class: Symfony\Component\Security\Ldap\Ldap
arguments: [ "ldap.example.com" ]
app/config/security.yml:
# To get started with security, check out the documentation:
# 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: ~
app_users:
ldap:
service: app.ldap
base_dn: dc=example,dc=com
search_dn: CN=My User,OU=Users,DC=example,DC=com
search_password: p455w0rd
filter: (sAMAccountName={username})
default_roles: ROLE_USER
#
firewalls:
api:
provider: app_users
stateless: true
pattern: ^/api
http_basic_ldap:
service: app.ldap
dn_string: "{username}@example"
backend:
provider: app_users
pattern: ^/admin
logout:
path: logout
target: login
form_login_ldap:
service: app.ldap
dn_string: CN={username},OU=Users,DC=example,DC=com
check_path: login_check
login_path: login
# 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
Symfony 2.8+现在包含一个LDAP组件,请参见Hey@LMS94。你能检查一下上面的编辑吗?这基本上是说你还没有在你的服务中定义服务器“app.LDAP”。yml文件Hey thx回答是的,我使用了文档中的代码。在app/config/services.yml中发布此服务,如果您有时间请检查编辑。您仍然会收到相同的错误吗?Symfony 2.8+现在包含LDAP组件,请参阅Hey@LMS94。您可以检查上面的编辑吗这基本上是说您没有定义服务器“app.LDAP”在your services.yml文件hey thx中,我使用了文档中的代码。在app/config/services.yml中发布此服务,如果您有时间,请检查编辑。您仍然收到相同的错误吗?