PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Symfony 3.4 - The service "Symfony\Component\Ldap\Ldap" has a dependency on a non-existent service "Symfony\Component\Ldap\Adapter\ExtLdap\Adapter"

 January 31, 2022     ldap, php, symfony     No comments   

Issue

Edit: My issue was resolved, see at the bottom of the post.

i've been trying to connect to a LDAP with Symfony 3.4 and i'm having quite troubles here.

i've setup my services.yml and security.yml following the documentation at https://symfony.com/doc/3.4/components/ldap.html and https://symfony.com/doc/3.4/security/ldap.html and also https://symfony.com/doc/3.4/reference/configuration/security.html

Here is my services.yaml

services:
  Symfony\Component\Ldap\Ldap:
    arguments: ['@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter']
    Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
      arguments:
      - host: myaddress
        port: 389
        #encryption: tls
        options:
          protocol_version: 3
          referrals: false

And here is my security.yaml

security:
    providers:
      my_ldap:
            ldap:
              service: Symfony\Component\Ldap\Ldap
              base_dn: dc=corp,dc=com
              search_dn: "dc=corp,dc=com"
              search_password: password
              default_roles: ROLE_USER
              uid_key: uid
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern: ^/
        provider: my_ldap
        anonymous: true
        form_login_ldap:
            login_path: login
            check_path: login
            service: Symfony\Component\Ldap\Ldap
            dn_string: 'uid={username},ou=People,dc=corp,dc=com'
        logout_on_user_change: true
        logout:
            path: logout
            target: login


role_hierarchy:
    ROLE_ADMIN: ROLE_MANAGER
    ROLE_MANAGER: ROLE_USER
    - { path: ^/admin, roles: ROLE_ADMIN }
    - { path: ^/manager, roles: ROLE_MANAGER }
    - { path: ^/myaccount, roles: ROLE_USER }
    - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }

I don't know why the dependency isn't found. I've checked the Ldap package with composer and everything was there. What am i missing ?

Thanks by advance for any clue or answer.

Edit: I managed to resolved my error. My service.yaml syntax was wrong i used:

Symfony\Component\Ldap\Ldap:
  arguments: ['@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter']
    Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
     arguments:
     #...

Where it should've been:

Symfony\Component\Ldap\Ldap:
  arguments: ['@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter']
Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
  arguments:

The tabulation for the second service was baddly made.


Solution

Syntax of services.yaml was wrong: one indentation was misplaced



Answered By - Silver
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing