mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-22 22:04:43 +08:00
ldap-contacts-suggestions: Allow anonymous ldap_bind() if bind DN is not filled up in plugin config
This commit is contained in:
parent
495fb486e1
commit
bb602a52a3
3 changed files with 16 additions and 9 deletions
|
@ -15,12 +15,12 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sAccessDn = '';
|
||||
private $sAccessDn = NULL;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sAccessPassword = '';
|
||||
private $sAccessPassword = NULL;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -68,8 +68,11 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
{
|
||||
$this->sHostName = $sHostName;
|
||||
$this->iHostPort = $iHostPort;
|
||||
$this->sAccessDn = $sAccessDn;
|
||||
$this->sAccessPassword = $sAccessPassword;
|
||||
if (0 < \strlen($sAccessDn))
|
||||
{
|
||||
$this->sAccessDn = $sAccessDn;
|
||||
$this->sAccessPassword = $sAccessPassword;
|
||||
}
|
||||
$this->sUsersDn = $sUsersDn;
|
||||
$this->sObjectClass = $sObjectClass;
|
||||
$this->sNameField = $sNameField;
|
||||
|
@ -181,7 +184,11 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
|
||||
if (!@\ldap_bind($oCon, $this->sAccessDn, $this->sAccessPassword))
|
||||
{
|
||||
$this->logLdapError($oCon, 'ldap_bind');
|
||||
if ( is_null($this->sAccessDn) ) {
|
||||
$this->logLdapError($oCon, 'ldap_bind (anonymous)');
|
||||
} else {
|
||||
$this->logLdapError($oCon, 'ldap_bind');
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.0
|
||||
1.1
|
||||
|
|
|
@ -44,8 +44,7 @@ class LdapContactsSuggestionsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$sNameField = \trim($this->Config()->Get('plugin', 'name_field', ''));
|
||||
$sEmailField = \trim($this->Config()->Get('plugin', 'mail_field', ''));
|
||||
|
||||
if (0 < \strlen($sAccessDn) && 0 < \strlen($sAccessPassword) && 0 < \strlen($sUsersDn) &&
|
||||
0 < \strlen($sObjectClass) && 0 < \strlen($sEmailField))
|
||||
if (0 < \strlen($sUsersDn) && 0 < \strlen($sObjectClass) && 0 < \strlen($sEmailField))
|
||||
{
|
||||
include_once __DIR__.'/LdapContactsSuggestions.php';
|
||||
|
||||
|
@ -71,6 +70,7 @@ class LdapContactsSuggestionsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
|
||||
->SetDefaultValue(389),
|
||||
\RainLoop\Plugins\Property::NewInstance('access_dn')->SetLabel('Access dn (login)')
|
||||
->SetDescription('LDAP bind DN to authentifcate with. If left blank, anonymous bind will be tried and Access password will be ignored')
|
||||
->SetDefaultValue(''),
|
||||
\RainLoop\Plugins\Property::NewInstance('access_password')->SetLabel('Access password')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD)
|
||||
|
@ -89,4 +89,4 @@ class LdapContactsSuggestionsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
->SetDefaultValue('*')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue