diff --git a/plugins/change-password/drivers/ldap.php b/plugins/change-password/drivers/ldap.php index f021c27be..4203bdeee 100644 --- a/plugins/change-password/drivers/ldap.php +++ b/plugins/change-password/drivers/ldap.php @@ -7,8 +7,7 @@ class ChangePasswordDriverLDAP DESCRIPTION = 'Change passwords in LDAP.'; private - $sHostName = 'localhost', - $iHostPort = 389, + $sLdapUri = 'ldap://localhost:389', $sUserDnFormat = '', $sPasswordField = 'userPassword', $sPasswordEncType = 'SHA'; @@ -21,8 +20,7 @@ class ChangePasswordDriverLDAP function __construct(\RainLoop\Config\Plugin $oConfig, \MailSo\Log\Logger $oLogger) { $this->oLogger = $oLogger; - $this->sHostName = \trim($oConfig->Get('plugin', 'ldap_hostname', '')); - $this->iHostPort = (int) $oConfig->Get('plugin', 'ldap_port', 389); + $this->sLdapUri = \trim($oConfig->Get('plugin', 'ldap_uri', '')); $this->sUserDnFormat = \trim($oConfig->Get('plugin', 'ldap_user_dn_format', '')); $this->sPasswordField = \trim($oConfig->Get('plugin', 'ldap_password_field', '')); $this->sPasswordEncType = \trim($oConfig->Get('plugin', 'ldap_password_enc_type', '')); @@ -37,11 +35,8 @@ class ChangePasswordDriverLDAP public static function configMapping() : array { return array( - \RainLoop\Plugins\Property::NewInstance('ldap_hostname')->SetLabel('Hostname') - ->SetDefaultValue('localhost'), - \RainLoop\Plugins\Property::NewInstance('ldap_port')->SetLabel('Port') - ->SetType(\RainLoop\Enumerations\PluginPropertyType::INT) - ->SetDefaultValue(389), + \RainLoop\Plugins\Property::NewInstance('ldap_uri')->SetLabel('LDAP URI') + ->SetDefaultValue('ldap://localhost:389'), \RainLoop\Plugins\Property::NewInstance('ldap_user_dn_format')->SetLabel('User DN format') ->SetDescription('LDAP user dn format. Supported tokens: {email}, {email:user}, {email:domain}, {login}, {domain}, {domain:dc}, {imap:login}, {imap:host}, {imap:port}, {gecos}') ->SetDefaultValue('uid={imap:login},ou=Users,{domain:dc}'), @@ -70,7 +65,7 @@ class ChangePasswordDriverLDAP '{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->Login()) : '' )); - $oCon = \ldap_connect($this->sHostName, $this->iHostPort); + $oCon = \ldap_connect($this->sLdapUri); if (!$oCon) { return false; }