DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
509 stars 54 forks source link

[Support] Override LDAP config with settings from database #424

Closed scramatte closed 1 year ago

scramatte commented 2 years ago

Hello,

I need to store LDAP settings in my database. I've made a Service Provider that is loaded just after AppServiceProvider. This service provider map and override database values to config/ldap.php or any other config/* values

        \App\Providers\SettingsServiceProvider::$storageToConfigMap = [
            'ldap_hosts' => 'ldap.connections.default.hosts',
            'ldap_username' => 'ldap.connections.default.username',
            'ldap_password' => 'ldap.connections.default.password',
            'ldap_base_dn' => 'ldap.connections.default.base_dn',
            'ldap_port' => 'ldap.connections.default.port',
            'ldap_timeout' => 'ldap.connections.default.timeout',
            'ldap_ssl' => 'ldap.connections.default.use_ssl',
        ];

Unfortunately ldaprecord ignore new default connection parameters What can I do to reread config?

Regards

scramatte commented 2 years ago

After some tweaks I've been able to get it working ...

le-pepe commented 1 year ago

@scramatte Hi, how did you solve it?

stevebauman commented 1 year ago

Hi @le-pepe,

If you're looking to setup LDAP connections via database, you can inspect theLdapServiceProvider to see how it registers them via Laravel configuration file:

https://github.com/DirectoryTree/LdapRecord-Laravel/blob/e2e0439626ab1767a1c60f46be9c7186ad58eefa/src/LdapServiceProvider.php#L33

https://github.com/DirectoryTree/LdapRecord-Laravel/blob/e2e0439626ab1767a1c60f46be9c7186ad58eefa/src/LdapServiceProvider.php#L101-L117