sgomez / adldap2-bundle

Adldap2 Integration for Symfony
4 stars 5 forks source link

"Notice: Undefined index: connection_settings" using Symfony4 #2

Open jvbussel opened 6 years ago

jvbussel commented 6 years ago

Is this bundle suitable for Symfony 4?

In services.yaml I do have:

parameters: locale: 'en' adldap2: auto_connect: true connection_class: Adldap\Connections\Ldap connection_settings: domain_controllers: .... .

But do get "Notice: Undefined index: connection_settings"

sgomez commented 6 years ago

Can you run composer info and send me this package and adldap2/adldap2 installed versions?

Anyway, can you format your configuration with ``` to see it propertly?

Thanks.

jvbussel commented 6 years ago

I looked like you update this buble to support Symfony 4.0:

composer.json :     Updated to symfony 4

service.yaml:

parameters: ....locale: 'en'

....adldap2: ........auto_connect: true ........connection_class: Adldap\Connections\Ldap ........connection_settings: ............domain_controllers:

composer info:

adldap2/adldap2 v7.0.15 A PHP LDAP Package for Active Directory Manipulation. sgomez/adldap2-bundle v4.0.0 Symfony Bundle for adldap2 library.

output of bin/console --verbose:

In Adldap2Extension.php line 20:

[ErrorException]
Notice: Undefined index: connection_settings

Exception trace: Sgomez\Bundle\Adldap2Bundle\DependencyInjection\Adldap2Extension->load() at /var/www/projects/base/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:76 Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process() at /var/www/projects/base/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:39 Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process() at /var/www/projects/base/vendor/symfony/dependency-injection/Compiler/Compiler.php:95 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /var/www/projects/base/vendor/symfony/dependency-injection/ContainerBuilder.php:736 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /var/www/projects/base/vendor/symfony/http-kernel/Kernel.php:519 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/projects/base/vendor/symfony/http-kernel/Kernel.php:123 Symfony\Component\HttpKernel\Kernel->boot() at /var/www/projects/base/vendor/symfony/framework-bundle/Console/Application.php:65 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/projects/base/vendor/symfony/console/Application.php:145 Symfony\Component\Console\Application->run() at /var/www/projects/base/bin/console:39

sgomez commented 6 years ago

AFAIK the configuration should be:

parameters:
    locale: 'en'
adldap2:
    auto_connect: true
    connection_class: Adldap\Connections\Ldap
    connection_settings:
        domain_controllers: ....

Mine is:

adldap2:
    connection_settings:
        domain_controllers: ["%ad_domain_controller%"]
        base_dn: "%ad_base_dn%"
        admin_username: "%ad_admin_username%"
        admin_password: "%ad_admin_password%"
        account_suffix: "%ad_account_suffix%"
        use_ssl: true

Check the indentation of your config.

jvbussel commented 6 years ago

changed services.yaml into

parameters:
    locale: 'en'

adldap2:
    auto_connect: true
    connection_class: Adldap\Connections\Ldap
    connection_settings:
        domain_controllers: ['domain']
        base_dn: 'base'
        admin_username: 'username'
        admin_password: 'password'
        account_suffix: ''
        port: 389
        follow_referrals: false
        use_ssl: false
        use_tls: false
        use_sso: false 

which results in:

In ArrayNode.php line 311:

Unrecognized option "use_sso" under "adldap2.connection_settings"

Note: Symfony 4 does not have an app/config/config.yml I assumed parameters need to be added in config/service.yaml. Or do we need to have an config/pakackages/adldap2.yaml ?

jvbussel commented 6 years ago

I have found the issue and the solution for Symfony 4

You need to add config/packages/adldap2.yaml:

adldap2:
    auto_connect: true
    connection_class: Adldap\Connections\Ldap
    connection_settings:
        domain_controllers: ['domain']
        base_dn: 'base'
        admin_username: 'username'
        admin_password: 'password'
        account_suffix: ''
        port: 389
        follow_referrals: false
        use_ssl: false
        use_tls: false
        use_sso: false 

After that there is still a problem with the 'auto_connect', 'connection_class' and 'use-sso' parameter as they are missing in ./vendor/sgomez/adldap2-bundle/DependencyInjection/Configuration.php

I have add these parameters in ./vendor/sgomez/adldap2-bundle/DependencyInjection/Configuration.php into:

    $rootNode
        ->children()
            .
            .
            ->booleanNode('auto_connect')
                ->defaultFalse()
            ->end()
            ->scalarNode('connection_class')
                ->isRequired()
                ->cannotBeEmpty()
            ->end()
            .
            .
            ->arrayNode('connection_settings')
                ->children()
                    .
                    .
                    ->booleanNode('use_sso')
                        ->defaultFalse()
                    ->end()
                    .
                    .

                ->end()
            ->end()
        ->end()
    ;

Is it possible to update your bundle with these enhancements to have Symfony 4 supported?

jvbussel commented 6 years ago

( accidently closed )

sgomez commented 6 years ago

Hi @jvbussel,

I don't remember now the reason I removed this option. Anyway you can remove it, because the default value is false. You don't need it to use the bundle.

I have no time right now to implement it. Maybe the next weekend...

Thanks.