diff options
Diffstat (limited to 'plugins/dovecot_impersonate/dovecot_impersonate.php')
-rw-r--r-- | plugins/dovecot_impersonate/dovecot_impersonate.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/plugins/dovecot_impersonate/dovecot_impersonate.php b/plugins/dovecot_impersonate/dovecot_impersonate.php new file mode 100644 index 000000000..48165fb4e --- /dev/null +++ b/plugins/dovecot_impersonate/dovecot_impersonate.php @@ -0,0 +1,52 @@ +<?php + +/** + * This plugin lets you impersonate another user using a master login. Only works with dovecot. + * + * http://wiki.dovecot.org/Authentication/MasterUsers + * + * @author Cor Bosman (roundcube@wa.ter.net) + */ + +class dovecot_impersonate extends rcube_plugin { + + public function init() + { + $this->add_hook('imap_connect', array($this, 'impersonate')); + $this->add_hook('managesieve_connect', array($this, 'impersonate')); + $this->add_hook('sieverules_connect', array($this, 'impersonate_sieverules')); + $this->add_hook('authenticate', array($this, 'login')); + } + + function login($data) { + // find the seperator character + $rcmail = rcmail::get_instance(); + $this->load_config(); + + $seperator = $rcmail->config->get('dovecot_impersonate_seperator', '*'); + + if(strpos($data['user'], $seperator)) { + $arr = explode($seperator, $data['user']); + if(count($arr) == 2) { + $data['user'] = $arr[0]; + $_SESSION['plugin.dovecot_impersonate_master'] = $seperator . $arr[1]; + } + } + return($data); + } + + function impersonate($data) { + if(isset($_SESSION['plugin.dovecot_impersonate_master'])) { + $data['user'] = $data['user'] . $_SESSION['plugin.dovecot_impersonate_master']; + } + return($data); + } + + function impersonate_sieverules($data) { + if(isset($_SESSION['plugin.dovecot_impersonate_master'])) { + $data['username'] = $data['username'] . $_SESSION['plugin.dovecot_impersonate_master']; + } + return($data); + } +} +?> |