mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 15:08:28 +03:00
[change-password] Use LDAP URI format instead of host/name
ldap_connect(<host>, <port>) is deprecated and ldap_connect(<uri>) format makes it possible to use ldaps.
This commit is contained in:
parent
2454909e83
commit
ba2b903d67
1 changed files with 5 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue