Décrivez ici votre problème ou ce que vous cherchez à faire.

mon fichier service.yaml

# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
    medias_directory: 'public/upload'
    upload_directory: 'upload/'
    users_directory: 'public/upload/user'
    users_upload: 'upload/user/'
    actual_directory: 'public/upload/actual'
    actual_upload: 'upload/actual/'
    formation_directory: 'public/upload/formation'
    formation_upload: 'upload/formation/'

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'
    Symfony\Component\Ldap\Ldap:
           class: Symfony\Component\Ldap\Ldap
           arguments: [ '@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter' ]
           tags:
            - { name: ldap }

    Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
            class: Symfony\Component\Ldap\Adapter\ExtLdap\Adapter
            arguments:
                $config:
                    host: 'ldap.forumsys.com'
                    port: 389
                    encryption: ssl
                    options:
                        protocol_version: 3
                        referrals: false

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

mon fichier security

security:
    # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
    password_hashers:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
    # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
    providers:
        # used to reload user from session & other features (e.g. switch_user)
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email
        my_ldap:
            ldap:
                service: Symfony\Component\Ldap\Ldap
                base_dn: "dc=exemple,dc=com"
                search_dn: "cn=read-only-admin,dc=example,dc=com"
                search_password: "password"
                default_roles: ROLE_USER
                uid_key: uid

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            lazy: true
            provider: my_ldap
#
#            custom_authenticator:
#                - App\Security\UserformauthAuthenticator

            logout:
                path: app_logout
                # where to redirect after logout
                # target: app_any_route

            remember_me:
                secret: '%kernel.secret%'
                lifetime: 604800
                path: /
                always_remember_me: true

            # activate different ways to authenticate
            # https://symfony.com/doc/current/security.html#the-firewall

            # https://symfony.com/doc/current/security/impersonating_user.html
            # switch_user: true

        form_login_ldap:
                # ...
            provider: my_ldap
            stateless: true
            http_basic_ldap:
                    service: Symfony\Component\Ldap\Ldap
                    dn_string: "cn=read-only-admin,dc=example,dc=com"

    # Easy way to control access for large sections of your site
    # Note: Only the *first* access control that matches will be used
    access_control:
        - { path: ^/admin, roles: 'ROLE_SEC, ROLE_COM, ROLE_ADMIN' }
        - { path: ^/profil, roles: ROLE_USER }
    role_hierarchy:
        ROLE_SEC : ['ROLE_USER']
        ROLE_COM : ['ROLE_SEC']
        ROLE_ADMIN : ['ROLE_COM']

when@test:
    security:
        password_hashers:
            # By default, password hashers are resource intensive and take time. This is
            # important to generate secure password hashes. In tests however, secure hashes
            # are not important, waste resources and increase test times. The following
            # reduces the work factor to the lowest possible values.
            Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
                algorithm: auto
                cost: 4 # Lowest possible value for bcrypt
                time_cost: 3 # Lowest possible value for argon
                memory_cost: 10 # Lowest possible value for argon

Ce que je veux

je n arrive pas a me connecter au serveur test ldap
j ai ce message d erreur

Ce que j'obtiens

"Error connecting to LDAP: Can't contact LDAP serverCheck LDAP Connection completed" ou un manke de setificat tls ou ssl quand j utilise comme host ldap://ldap.forumsys.com j obtiens
Erreur de connexion à LDAP : Avertissement : ldap_connect() : Impossible de créer un handle de session : paramètre incorrect d’une routine LDAPervice de connexion LDAP terminée

2 réponses


Salut,

essaye en remplacant :

encryption: ssl

par

encryption: none

si ça marche c'est que le port SSL n'est pas ouvert sur ton serveur

bonjour merci pour votre reponse mais j ai toujours une erreur mais je voudrai savoir quelle approche est la meilleur pour integrer le protocol ldap a mon projet