編寫Symfony3應用程序並嘗試配置symfony/ldap組件來驗證用戶並從我的AD服務器檢索用戶屬性。ldap組件Symfony3配置和設置
使我明白我需要安裝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服務不存在,而不是這種情況....任何想法爲什麼看到t他的錯誤與設置有什麼不妥...?
我遇到另一個問題會產生另一個問題,並在此處發佈鏈接。 – John
http://stackoverflow.com/questions/37884448/symfony3-ldap-component-adapterinterface-error – John
你可能還需要運行'composer update'。希望這是一個開發環境。 –