在一个Symfony3项目上工作,并尝试结合使用这两个包,通过LDAP对用户进行目录服务的身份验证:
FR3DLdapBundle
FOSUserBundle 我已经按照文档配置了这些在int上运行良好的FSOUserBundel工作,当我根据它的Docks添加FR3DLdapBundle时,留下了这个错误:
Catchable Fatal Error: Argument 2 passed to FR3D\LdapBundle\Driver\ZendLdapDriver::__construct() must be an instance of
Symfony\Component\HttpKernel\Log\LoggerInterface, instance of
Symfony\Bridge\Monolog\Logger given, called in /Users/tomasz.koprowski/Dev/cambio-
back_end/var/cache/dev/appDevDebugProjectContainer.php on line 1729 and definedps。我确实清理了我的缓存。
现在,我认为我可能有错误的文件是security.yml:
# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
# Preserve plain text password in token for refresh the user.
# Analyze the security considerations before turn off this setting.
erase_credentials: false
encoders:
AcmeBundle\Acme\User\LdapUser: plaintext
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
chain_provider:
chain:
providers: [fos_userbundle, fr3d_ldapbundle]
fr3d_ldapbundle:
id: fr3d_ldap.security.user.provider
fos_userbundle:
id: fos_user.user_provider.username
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
# providers:
# in_memory:
# memory: ~
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
# dev:
# pattern: ^/(_(profiler|wdt)|css|images|js)/
# security: false
main:
pattern: ^/
fr3d_ldap: ~
form_login:
always_use_default_target_path: true
default_target_path: /profile
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
# 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和config.yml:
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Cambio\CambioBundle\Entity\User
fr3d_ldap:
fr3d_ldap:
driver:
host: your.host.foo
# port: 389 # Optional
# username: foo # Optional
# password: bar # Optional
# bindRequiresDn: true # Optional
# baseDn: ou=users, dc=host, dc=foo # Optional
# accountFilterFormat: (&(uid=%s)) # Optional. sprintf format %s will be the username
# optReferrals: false # Optional
# useSsl: true # Enable SSL negotiation. Optional
# useStartTls: true # Enable TLS negotiation. Optional
# accountCanonicalForm: 3 # ACCTNAME_FORM_BACKSLASH this is only needed if your users have to login with something like HOST\User
# accountDomainName: HOST
# accountDomainNameShort: HOST # if you use the Backslash form set both to Hostname than the Username will be converted to HOST\User
user:
baseDn: ou=users, dc=host, dc=foo
filter: (&(ObjectClass=Person))
# usernameAttribute: uid # Optional
attributes: # Specify ldap attributes mapping [ldap attribute, user object method]
# - { ldap_attr: uid, user_method: setUsername } # Default
# - { ldap_attr: cn, user_method: setName } # Optional
# - { ldap_attr: ..., user_method: ... } # Optional
# service:
# user_hydrator: fr3d_ldap.user_hydrator.default # Overrides default user hydrator
# ldap_manager: fr3d_ldap.ldap_manager.default # Overrides default ldap manager
user:
- { ldap_attr: uid, user_method: setUsername }
- { ldap_attr: mail, user_method: setEmail }伙计们,你们知道吗?谢谢
发布于 2016-06-02 03:11:26
我认为这是因为FR3DLdapBundle并不完全支持Symfony3。早在2.8版本中,Symfony\Bridge\Monolog\Logger实现了扩展了Psr\Log\LoggerInterface的Symfony\Component\HttpKernel\Log\LoggerInterface,Symfony 3中的类只实现了没有扩展任何东西的Symfony\Component\HttpKernel\Log\DebugLoggerInterface,它只是一个接口。在FR3DLdapBundle类中,FR3D\LdapBundle\Driver\ZendLdapDriver期望第二个参数为Psr\LoggerInterface。就这样。
你可以在他们的github page上把这个写成问题
或者你可以派生他们的repo,修复预期的参数here并发出拉取请求。同时使用您的捆绑包,然后在他们接受并合并您的拉取请求时将其更改回他们的捆绑包
发布于 2016-06-02 07:13:53
你为什么不通读我的博客Symfony AD Integration。
我在你的"config.yml“文件中看到有两次"fr3d_ldap:”。这可能是个问题。
我建议先使用我在博客中展示的LDAP测试服务器来验证它是否正常工作,然后再转到您自己的AD服务器上。
发布于 2019-02-08 06:22:24
如果其他任何人仍在尝试从Symfony 2.8升级到3.4,并遇到FR3DLdapBundle的问题,如原始帖子中所示:
1)使用composer将FR3DLdapBundle从v2.0升级到v3.0
这应该会消除原始发帖者在上面的问题中看到的bug。
2)在Symfony app/config.yml的FR3DLdapBundle设置下,在"user“部分下添加"usernameAttribute”设置,并将其设置为"sAMAccountName“
示例:
fr3d_ldap:
driver:
host: XX.XX.XX.XX
username: user@domain.com
password: password
accountDomainName: domain.com
accountDomainNameShort: DOMA
user:
baseDn: Ou=ListingUsers,DC=domain,DC=com
usernameAttribute: sAMAccountName
filter: (&(ObjectClass=Person))
attributes:
- { ldap_attr: samaccountname, user_method: setUsername }如果您一直在使用该包的较早版本,那么您的配置中可能没有该包,您将需要它来使其正常工作。我在这里找到了这个解决方案:https://github.com/Maks3w/FR3DLdapBundle/issues/131
这两个变化共同解决了我的问题,并使我能够在Symfony 3.4上使用FR3DLdapBundle
https://stackoverflow.com/questions/37575140
复制相似问题