Skip to content

Commit 011f847

Browse files
committed
Fix pass custom config to Symfony Ldap-Adapter
1 parent 12fcfc2 commit 011f847

3 files changed

Lines changed: 28 additions & 21 deletions

File tree

MapbenderLDAPBundle.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
namespace Mapbender\LDAPBundle;
44

55
use Symfony\Component\Config\FileLocator;
6-
use Symfony\Component\Config\Resource\FileResource;
76
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
87
use Symfony\Component\HttpKernel\Bundle\Bundle;
98
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
10+
use Symfony\Component\DependencyInjection\Definition;
1011

1112
class MapbenderLDAPBundle extends Bundle
1213
{
1314
public function build(ContainerBuilder $container)
1415
{
15-
parent::build($container);
1616
$configLocator = new FileLocator(__DIR__ . '/Resources/config');
1717
$loader = new YamlFileLoader($container, $configLocator);
1818
$loader->load('services.yml');
19-
$container->addResource(new FileResource($configLocator->locate('services.yml')));
19+
$providerDefinition = new Definition(Adapter::class, array([
20+
'host' => '%ldap.host%',
21+
'port' => '%ldap.port%',
22+
'version' => '%ldap.version%',
23+
'encryption' => '%ldap.encryption%',
24+
],
25+
));
26+
$container->setDefinition('Symfony\Component\Ldap\Adapter\ExtLdap\Adapter', $providerDefinition);
2027
}
2128
}

Resources/config/services.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@ services:
88
arguments:
99
- host: '%ldap.host%'
1010
- port: '%ldap.port%'
11-
- encryption: '%ldap.encryption'
11+
- encryption: '%ldap.encryption%'
1212
- options:
13-
protocol_version: '%ldap.version'
13+
protocol_version: '%ldap.version%'
1414
referrals: false
1515

1616
mapbender.ldap.client:
1717
class: Mapbender\LDAPBundle\Security\LdapClient
1818
arguments:
19-
- '%ldap.host%'
20-
- '%ldap.port%'
21-
- '%ldap.version%'
22-
- '%ldap.encryption%'
23-
- '%ldap.bind.dn%'
24-
- '%ldap.bind.pwd%'
19+
- '%ldap.host%'
20+
- '%ldap.port%'
21+
- '%ldap.version%'
22+
- '%ldap.encryption%'
23+
- '%ldap.bind.dn%'
24+
- '%ldap.bind.pwd%'
2525

2626
mapbender.ldap.user_provider:
2727
class: Mapbender\LDAPBundle\Security\LdapUserProvider
2828
arguments:
29-
- '@mapbender.ldap.client'
30-
- '%ldap.user.baseDn%'
31-
- '%ldap.user.query%'
32-
- '%ldap.user.groupKey%'
33-
- '%ldap.group.baseDn%'
34-
- '%ldap.group.query%'
35-
- '%ldap.group.id%'
36-
- '%ldap.group.defaultRoles%'
29+
- '@mapbender.ldap.client'
30+
- '%ldap.user.baseDn%'
31+
- '%ldap.user.query%'
32+
- '%ldap.user.groupKey%'
33+
- '%ldap.group.baseDn%'
34+
- '%ldap.group.query%'
35+
- '%ldap.group.id%'
36+
- '%ldap.group.defaultRoles%'
3737

3838
mapbender.ldap.authenticator:
3939
class: Mapbender\LDAPBundle\Security\MapbenderLdapAuthenticator

Security/LdapClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class LdapClient
1313

1414
public function __construct($host, $port, $version, $encryption, $bindDn, $bindPwd)
1515
{
16-
$adapterOptions = array_filter([
16+
$adapterOptions = [
1717
'host' => $host,
1818
'port' => $port,
1919
'version' => $version,
2020
'encryption' => $encryption,
21-
]);
21+
];
2222
$this->adapter = new Adapter($adapterOptions);
2323
$this->host = $host;
2424
$this->bindDn = $bindDn;

0 commit comments

Comments
 (0)