我将 FR3DLdapBundle 与 FOSUserBundle 一起使用。
Symfony 2.5.6
FOSUserBundle ~2.0@dev
FR3DLdapBundle ~2.0@dev
$ldapManager = $this->get('fr3d_ldap.ldap_manager');
print_r($ldapManager->findUserByUsername('nhoang@ldap.example.com'));
但我发现了一个错误。
Binding requires username in DN form
CRITICAL - Uncaught PHP Exception FR3D\LdapBundle\Driver\LdapDriverException: "An error occur with the search operation." at myproj\vendor\fr3d\ldap-bundle\FR3D\LdapBundle\Driver\ZendLdapDriver.php line 55
我已经完成了安装文档中的所有内容
配置.yml
fr3d_ldap:
driver:
host: ldap.example.com
port: 389
username: ldapadmin@ldap.example.com
password: password
bindRequiresDn: true
baseDn: dc=ldap,dc=example,dc=com
accountFilterFormat: (&(uid=%s)) # Optional. sprintf format %s will be the username
user:
baseDn: dc=ldap,dc=example,dc=com
filter: (&(ObjectClass=Person))
attributes:
- { ldap_attr: uid, user_method: setUsername }
安全.yml
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
firewalls:
admin:
pattern: /admin/(.*)
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: _admin_login
check_path: _admin_login_check
default_target_path: /admin
logout:
path: _admin_logout
target: _admin_login
anonymous: true
main:
pattern: ^/
fr3d_ldap: ~
form_login:
provider: chain_provider
csrf_provider: form.csrf_provider
default_target_path: /profile
logout: true
anonymous: true
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
default:
anonymous: ~
我不知道如何使这项工作。