X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fchange_password%2Fbackend%2Fldap.php;h=d325cb3cf84ff6c21d2c273f5a8e64959952a572;hp=b4562c6e434355fbeeb21b39023ad6ffc24736cb;hb=b4df37a525c34a317d5f6ff10baa518f75448703;hpb=02c81de496ba189cf1dca6d9588ea434f93ee3da
diff --git a/plugins/change_password/backend/ldap.php b/plugins/change_password/backend/ldap.php
index b4562c6e..d325cb3c 100644
--- a/plugins/change_password/backend/ldap.php
+++ b/plugins/change_password/backend/ldap.php
@@ -1,41 +1,60 @@
*
'ldap.example.com' - connect to server on ldap.example.com address
- * 'ldaps://ldap.example.com' - connect to server on ldap.example.com address
- * and use SSL encrypted connection to default ldaps port.
+ * 'ldaps://ldap.example.com' - connect to server on ldap.example.com address
+ * and use SSL encrypted connection to default LDAPs port.
*
* defaults to imap server address.
* @link http://www.php.net/ldap-connect
* @global string $cpw_ldap_server
*/
global $cpw_ldap_server;
-$cpw_ldap_server='localhost';
+$cpw_ldap_server=$imapServerAddress;
/**
- * Port of ldap server.
- * Used only when $cpw_ldap_server specifies ip address or dns name.
+ * Port of LDAP server.
+ * Used only when $cpw_ldap_server specifies IP address or DNS name.
* @global integer $cpw_ldap_port
*/
global $cpw_ldap_port;
$cpw_ldap_port=389;
/**
- * ldap basedn that is used for binding to ldap server.
+ * LDAP basedn that is used for binding to LDAP server.
* this option must be set to correct value.
- * @global $cpw_ldap_basedn;
+ * @global string $cpw_ldap_basedn;
*/
global $cpw_ldap_basedn;
$cpw_ldap_basedn='';
@@ -49,8 +68,8 @@ global $cpw_ldap_connect_opts;
$cpw_ldap_connect_opts=array();
/**
- * Controls use of starttls on ldap connection.
- * Requires php 4.2+, php ldap extension with ssl support and
+ * Controls use of starttls on LDAP connection.
+ * Requires PHP 4.2+, PHP LDAP extension with SSL support and
* PROTOCOL_VERSION => 3 setting in $cpw_ldap_connect_opts
* @global boolean $cpw_ldap_use_tls
*/
@@ -58,9 +77,9 @@ global $cpw_ldap_use_tls;
$cpw_ldap_use_tls=false;
/**
- * BindDN that should be able to search ldap directory and find DN used by user.
- * Uses anonymous bind if set to empty string. You should not use DN with write
- * access to ldap directory here. Write access is not required.
+ * BindDN that should be able to search LDAP directory and find DN used by user.
+ * Uses anonymous bind if set to empty string. You should not use DN with write
+ * access to LDAP directory here. Write access is not required.
* @global string $cpw_ldap_binddn
*/
global $cpw_ldap_binddn;
@@ -68,15 +87,15 @@ $cpw_ldap_binddn='';
/**
* password used for $cpw_ldap_binddn
- * @global string $cpw_ldap_bindpw
+ * @global string $cpw_ldap_bindpw
*/
global $cpw_ldap_bindpw;
$cpw_ldap_bindpw='';
/**
* BindDN that should be able to change password.
- * WARNING: usually user has enough privileges to change own password.
- * If you leave default value, plugin will try to connect with dn that
+ * WARNING: sometimes user has enough privileges to change own password.
+ * If you leave default value, plugin will try to connect with DN that
* is detected in $cpw_ldap_username_attr=$username search and current
* user password will be used for authentication.
* @global string $cpw_ldap_admindn
@@ -86,13 +105,13 @@ $cpw_ldap_admindn='';
/**
* password used for $cpw_ldap_admindn
- * @global string $cpw_ldap_adminpw
+ * @global string $cpw_ldap_adminpw
*/
global $cpw_ldap_adminpw;
$cpw_ldap_adminpw='';
/**
- * ldap attribute that stores username.
+ * LDAP attribute that stores username.
* username entry should be unique for $cpw_ldap_basedn
* @global string $cpw_ldap_userid_attr
*/
@@ -122,6 +141,9 @@ if (isset($cpw_ldap['adminpw'])) $cpw_ldap_adminpw=$cpw_ldap['adminpw'];
if (isset($cpw_ldap['userid_attr'])) $cpw_ldap_userid_attr=$cpw_ldap['userid_attr'];
if (isset($cpw_ldap['default_crypto'])) $cpw_ldap_default_crypto=$cpw_ldap['default_crypto'];
+/** make sure that setting does not contain mapping */
+$cpw_ldap_server=sqimap_get_user_server($cpw_ldap_server,$username);
+
/**
* Adding plugin hooks
*/
@@ -132,50 +154,41 @@ $squirrelmail_plugin_hooks['change_password_init']['ldap'] =
'cpw_ldap_init';
/**
- * Backend specific functions
+ * Makes sure that required functions and configuration options are set.
*/
function cpw_ldap_init() {
- global $color;
- global $cpw_ldap_basedn;
-
- /**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
- if (!defined('SM_PATH')) define('SM_PATH','../../../');
-
- // load error_box() function
- include_once(SM_PATH . 'functions/display_messages.php');
+ global $oTemplate, $cpw_ldap_basedn;
// set initial value for error tracker
$cpw_ldap_initerr=false;
// check for ldap support in php
if (! function_exists('ldap_connect')) {
- error_box(_("Current configuration requires ldap support in php."),$color);
+ error_box(_("Current configuration requires LDAP support in PHP."));
$cpw_ldap_initerr=true;
}
// chech required configuration settings.
if ($cpw_ldap_basedn=='') {
- error_box(_("Plugin is not configured correctly."),$color);
+ error_box(_("Plugin is not configured correctly."));
$cpw_ldap_initerr=true;
}
- // if error var is positive, close html and stop execution
+ // if error var is positive, close html and stop execution
if ($cpw_ldap_initerr) {
- echo '