From: Raúl A. <rau...@gr...> - 2009-11-16 15:19:10
|
We proxy imap with nginx. It checks user's "mailhost" ldap attribute to locate actual imap server. avelsieve must do the same. This ugly hack provides this (hope it helps): - diff -u config_sample.php config.php.new --- config_sample.php 2006-07-24 15:48:27.000000000 +0200 +++ config.php.new 2009-11-16 15:55:43.000000000 +0100 @@ -127,6 +127,11 @@ 'localhost' => 'imap.example.org' ); +global $avelsieve_ldapimapproxymode, $avelsieve_ldapimapproxyserv, $avelsieve_ldapbaseimapproxymode; +$avelsieve_ldapimapproxymode = true; +$avelsieve_ldapimapproxyserv = 'ldap.example.org'; +$avelsieve_ldapbaseimapproxymode = 'ou=people,dc=example,dc=org'; + /** @var boolean Ldapuserdata mode: Gets user's email addresses (including * mailAlternate & mailAuthorized) from LDAP Prefs Backend plugin's cache */ - diff -u DO_Sieve_ManageSieve.class.php DO_Sieve_ManageSieve.class.php.new --- DO_Sieve_ManageSieve.class.php 2006-07-24 15:48:27.000000000 +0200 +++ DO_Sieve_ManageSieve.class.php.new 2009-11-16 15:47:33.000000000 +0100 @@ -46,7 +46,7 @@ global $imapServerAddress, $username, $avelsieve_imapproxymode, $avelsieve_cyrusadmins_map, $sieveport, $sieve_preferred_sasl_mech, - $avelsieve_imapproxyserv; + $avelsieve_imapproxyserv, $avelsieve_ldapimapproxymode, $avelsieve_ldapimapproxyserv, $avelsieve_ldapbaseimapproxymode; $this->sieveServerAddress = $imapServerAddress; $this->sieveUsername = $username; @@ -68,7 +68,22 @@ if ($avelsieve_imapproxymode == true) { /* Need to do mapping so as to connect directly to server */ $this->sieveServerAddress = $avelsieve_imapproxyserv[$this->sieveServerAddress]; - } + } else { + if ($avelsieve_ldapimapproxymode == true) { + $ldap = ldap_connect($avelsieve_ldapimapproxyserv); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + $ldapbind = ldap_bind($ldap) + or die("ldapimapproxy: Unable to bind to LDAP server, contact your administrator"); + $sr = ldap_search($ldap, $avelsieve_ldapbaseimapproxymode, "uid=$username"); + $info = ldap_get_entries($ldap, $sr); + /* $errormsg = sprintf( _("info: %s\n"), $info[0]["mailhost"][0]); + print_errormsg($errormsg); */ + + $this->sieveServerAddress = $info[0]["mailhost"][0]; + ldap_close($ldap); + } + } + } /** - diff -u DO_Sieve_PearManageSieve.class.php DO_Sieve_PearManageSieve.class.php.new --- DO_Sieve_PearManageSieve.class.php 2006-07-24 15:48:27.000000000 +0200 +++ DO_Sieve_PearManageSieve.class.php.new 2009-11-16 15:41:37.000000000 +0100 @@ -46,7 +46,7 @@ global $imapServerAddress, $username, $avelsieve_imapproxymode, $avelsieve_cyrusadmins_map, $sieveport, $sieve_preferred_sasl_mech, - $avelsieve_imapproxyserv; + $avelsieve_imapproxyserv, $avelsieve_ldapimapproxymode, $avelsieve_ldapimapproxyserv, $avelsieve_ldapbaseimapproxymode; $this->sieveServerAddress = $imapServerAddress; $this->sieveUsername = $username; @@ -65,10 +65,24 @@ } else { $this->sieveServerAddress = sqimap_get_user_server ($imapServerAddress, $username); } + if ($avelsieve_imapproxymode == true) { /* Need to do mapping so as to connect directly to server */ $this->sieveServerAddress = $avelsieve_imapproxyserv[$this->sieveServerAddress]; + } else { + if ($avelsieve_ldapimapproxymode == true) { + $ldap = ldap_connect($avelsieve_ldapimapproxyserv); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + $ldapbind = ldap_bind($ldap) + or die("ldapimapproxy: Unable to bind to LDAP server, contact your administrator"); + $sr = ldap_search($ldap, $avelsieve_ldapbaseimapproxymode, "uid=$username"); + $info = ldap_get_entries($ldap, $sr); + $this->sieveServerAddress = $info[0]["mailhost"][0]; + ldap_close($ldap); + } } + + } /** - diff -u managesieve_wrapper.inc.php managesieve_wrapper.inc.php.new --- managesieve_wrapper.inc.php 2006-07-24 15:48:27.000000000 +0200 +++ managesieve_wrapper.inc.php.new 2009-11-16 15:45:49.000000000 +0100 @@ -42,7 +42,7 @@ sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); sqgetGlobalVar('authz', $authz, SQ_SESSION); global $imapServerAddress, $username, $avelsieve_imapproxymode, $avelsieve_cyrusadmins_map, $sieveport, - $avelsieve_imapproxyserv, $sieve_preferred_sasl_mech; + $avelsieve_imapproxyserv, $sieve_preferred_sasl_mech, $avelsieve_ldapimapproxyserv, $avelsieve_ldapimapproxymode, $avelsieve_ldapbaseimapproxymode; /* Need the cleartext password to login to timsieved */ $acctpass = OneTimePadDecrypt($key, $onetimepad); @@ -54,7 +54,20 @@ if ($avelsieve_imapproxymode == true) { /* Need to do mapping so as to connect directly to server */ $imap_server = $avelsieve_imapproxyserv[$imap_server]; - } + } else { + if ($avelsieve_ldapimapproxymode == true) { + $ldap = ldap_connect($avelsieve_ldapimapproxyserv); + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); + $ldapbind = ldap_bind($ldap) + or die("ldapimapproxy: Unable to bind to LDAP server, contact your administrator"); + $sr = ldap_search($ldap, $avelsieve_ldapbaseimapproxymode, "uid=$username"); + $info = ldap_get_entries($ldap, $sr); + $imap_server = $info[0]["mailhost"][0]; + ldap_close($ldap); + } + } + } + } } if(isset($authz)) { if(isset($avelsieve_cyrusadmins_map[$username])) { "Este correo electronico y la informacion contenida en el mismo es de caracter confidencial y esta sometida al secreto profesional, dirigiendose exclusivamente al destinatario mencionado en el encabezamiento, cuyos datos forman parte de un fichero responsabilidad del GRUPO CARRERAS y cuya finalidad es contactar con el titular de los datos a traves del correo electronico. Le informamos que cuenta con los derechos de acceso, rectificacion y cancelacion que podra ejercitar mediante el envio de un correo electronico a la siguiente direccion: ca...@gr.... Si el receptor de la comunicacion fuera el destinatario, le informamos que cualquier divulgacion, copia, distribucion o utilizacion no autorizada de la informacion contenida en la misma esta prohibida por la legislacion vigente." http://www.grupocarreras.com ____________________________________________________________________________ |