当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_utils::idn_to_ascii方法代码示例

本文整理汇总了PHP中rcube_utils::idn_to_ascii方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_utils::idn_to_ascii方法的具体用法?PHP rcube_utils::idn_to_ascii怎么用?PHP rcube_utils::idn_to_ascii使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcube_utils的用法示例。


在下文中一共展示了rcube_utils::idn_to_ascii方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * Establish a connection to the LDAP server
  */
 public function connect($host = null)
 {
     // Net_LDAP3 does not support IDNA yet
     // also parse_host() here is very Roundcube specific
     $host = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
     return parent::connect($host);
 }
开发者ID:noikiy,项目名称:roundcubemail,代码行数:10,代码来源:rcube_ldap_generic.php

示例2: save_data

 /**
  * Handler for submitted form (ajax request)
  *
  * Check fields and save to default identity if valid.
  * Afterwards the session flag is removed and we're done.
  */
 function save_data()
 {
     $rcmail = rcmail::get_instance();
     $identity = $rcmail->user->get_identity();
     $ident_level = intval($rcmail->config->get('identities_level', 0));
     $save_data = array('name' => rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST), 'email' => rcube_utils::get_input_value('_email', rcube_utils::INPUT_POST), 'organization' => rcube_utils::get_input_value('_organization', rcube_utils::INPUT_POST), 'signature' => rcube_utils::get_input_value('_signature', rcube_utils::INPUT_POST));
     // don't let the user alter the e-mail address if disabled by config
     if (in_array($ident_level, array(1, 3, 4))) {
         $save_data['email'] = $identity['email'];
     }
     if (empty($save_data['name']) || empty($save_data['email'])) {
         $rcmail->output->show_message('formincomplete', 'error');
     } else {
         if (!rcube_utils::check_email($save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']))) {
             $rcmail->output->show_message('emailformaterror', 'error', array('email' => $save_data['email']));
         } else {
             // save data
             $rcmail->user->update_identity($identity['identity_id'], $save_data);
             $rcmail->session->remove('plugin.newuserdialog');
             // hide dialog
             $rcmail->output->command('new_user_dialog_close');
             $rcmail->output->show_message('successfullysaved', 'confirmation');
         }
     }
     $rcmail->output->send();
 }
开发者ID:BIGGANI,项目名称:zpanelx,代码行数:32,代码来源:new_user_dialog.php

示例3: lookup_user_name

 function lookup_user_name($args)
 {
     if ($this->init_ldap($args['host'])) {
         $results = $this->ldap->search('*', $args['user'], true);
         if (count($results->records) == 1) {
             $user_name = is_array($results->records[0]['name']) ? $results->records[0]['name'][0] : $results->records[0]['name'];
             $user_email = is_array($results->records[0]['email']) ? $results->records[0]['email'][0] : $results->records[0]['email'];
             $args['user_name'] = $user_name;
             $args['email_list'] = array();
             if (!$args['user_email'] && strpos($user_email, '@')) {
                 $args['user_email'] = rcube_utils::idn_to_ascii($user_email);
             }
             foreach (array_keys($results[0]) as $key) {
                 if (!preg_match('/^email($|:)/', $key)) {
                     continue;
                 }
                 foreach ((array) $results->records[0][$key] as $alias) {
                     if (strpos($alias, '@')) {
                         $args['email_list'][] = rcube_utils::idn_to_ascii($alias);
                     }
                 }
             }
         }
     }
     return $args;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:26,代码来源:new_user_identity.php

示例4: create_identity

 public function create_identity($p)
 {
     $rcmail = rcmail::get_instance();
     // prefs are set in create_user()
     if ($this->prefs) {
         if ($this->prefs['full_name']) {
             $p['record']['name'] = $this->prefs['full_name'];
         }
         if (($this->identities_level == 0 || $this->identities_level == 2) && $this->prefs['email_address']) {
             $p['record']['email'] = $this->prefs['email_address'];
         }
         if ($this->prefs['___signature___']) {
             $p['record']['signature'] = $this->prefs['___signature___'];
         }
         if ($this->prefs['reply_to']) {
             $p['record']['reply-to'] = $this->prefs['reply_to'];
         }
         if (($this->identities_level == 0 || $this->identities_level == 1) && isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
             for ($i = 1; $i < $this->prefs['identities']; $i++) {
                 unset($ident_data);
                 $ident_data = array('name' => '', 'email' => '');
                 // required data
                 if ($this->prefs['full_name' . $i]) {
                     $ident_data['name'] = $this->prefs['full_name' . $i];
                 }
                 if ($this->identities_level == 0 && $this->prefs['email_address' . $i]) {
                     $ident_data['email'] = $this->prefs['email_address' . $i];
                 } else {
                     $ident_data['email'] = $p['record']['email'];
                 }
                 if ($this->prefs['reply_to' . $i]) {
                     $ident_data['reply-to'] = $this->prefs['reply_to' . $i];
                 }
                 if ($this->prefs['___sig' . $i . '___']) {
                     $ident_data['signature'] = $this->prefs['___sig' . $i . '___'];
                 }
                 // insert identity
                 $rcmail->user->insert_identity($ident_data);
             }
         }
         // copy address book
         $contacts = $rcmail->get_address_book(null, true);
         if ($contacts && count($this->abook)) {
             foreach ($this->abook as $rec) {
                 // #1487096 handle multi-address and/or too long items
                 $rec['email'] = array_shift(explode(';', $rec['email']));
                 if (rcube_utils::check_email(rcube_utils::idn_to_ascii($rec['email']))) {
                     $rec['email'] = rcube_utils::idn_to_utf8($rec['email']);
                     $contacts->insert($rec, true);
                 }
             }
         }
         // mark identity as complete for following hooks
         $p['complete'] = true;
     }
     return $p;
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:57,代码来源:squirrelmail_usercopy.php

示例5: lookup_user_name

 function lookup_user_name($args)
 {
     if ($this->init_ldap($args['host'])) {
         $results = $this->ldap->search('*', $args['user'], true);
         if (count($results->records) == 1) {
             $user_name = is_array($results->records[0]['name']) ? $results->records[0]['name'][0] : $results->records[0]['name'];
             $user_email = is_array($results->records[0]['email']) ? $results->records[0]['email'][0] : $results->records[0]['email'];
             $args['user_name'] = $user_name;
             if (!$args['user_email'] && strpos($user_email, '@')) {
                 $args['user_email'] = rcube_utils::idn_to_ascii($user_email);
             }
         }
     }
     return $args;
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:15,代码来源:new_user_identity.php

示例6: user2email

 /**
  * User > Email
  */
 function user2email($p)
 {
     $r = $this->findinvirtual('/\\s' . preg_quote($p['user'], '/') . '\\s*$/');
     $result = array();
     for ($i = 0; $i < count($r); $i++) {
         $arr = preg_split('/\\s+/', $r[$i]);
         if (count($arr) > 0 && strpos($arr[0], '@')) {
             $result[] = rcube_utils::idn_to_ascii(trim(str_replace('\\@', '@', $arr[0])));
             if ($p['first']) {
                 $p['email'] = $result[0];
                 break;
             }
         }
     }
     $p['email'] = empty($result) ? NULL : $result;
     return $p;
 }
开发者ID:rcg2015,项目名称:roundcubemail,代码行数:20,代码来源:virtuser_file.php

示例7: user2email

 /**
  * User > Email
  */
 function user2email($p)
 {
     $dbh = $this->get_dbh();
     $sql_result = $dbh->query(preg_replace('/%u/', $dbh->escape($p['user']), $this->config['email']));
     while ($sql_arr = $dbh->fetch_array($sql_result)) {
         if (strpos($sql_arr[0], '@')) {
             if ($p['extended'] && count($sql_arr) > 1) {
                 $result[] = array('email' => rcube_utils::idn_to_ascii($sql_arr[0]), 'name' => (string) $sql_arr[1], 'organization' => (string) $sql_arr[2], 'reply-to' => (string) rcube_utils::idn_to_ascii($sql_arr[3]), 'bcc' => (string) rcube_utils::idn_to_ascii($sql_arr[4]), 'signature' => (string) $sql_arr[5], 'html_signature' => (int) $sql_arr[6]);
             } else {
                 $result[] = $sql_arr[0];
             }
             if ($p['first']) {
                 break;
             }
         }
     }
     $p['email'] = $result;
     return $p;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:22,代码来源:virtuser_query.php

示例8: authenticate

 /**
  * Authenticate hook handler
  */
 function authenticate($args)
 {
     if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
         // Load plugin's config file
         $this->load_config();
         $rcmail = rcmail::get_instance();
         $host = $rcmail->config->get('krb_authentication_host');
         if (is_string($host) && trim($host) !== '' && empty($args['host'])) {
             $args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
         }
         if (!empty($_SERVER['REMOTE_USER'])) {
             $args['user'] = $_SERVER['REMOTE_USER'];
             $args['pass'] = null;
         }
         $args['cookiecheck'] = false;
         $args['valid'] = true;
     }
     return $args;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:22,代码来源:krb_authentication.php

示例9: authenticate

 function authenticate($args)
 {
     // Load plugin's config file
     $this->load_config();
     $host = rcmail::get_instance()->config->get('http_authentication_host');
     if (is_string($host) && trim($host) !== '' && empty($args['host'])) {
         $args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
     }
     // Allow entering other user data in login form,
     // e.g. after log out (#1487953)
     if (!empty($args['user'])) {
         return $args;
     }
     if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
         $args['user'] = $_SERVER['PHP_AUTH_USER'];
         $args['pass'] = $_SERVER['PHP_AUTH_PW'];
     }
     $args['cookiecheck'] = false;
     $args['valid'] = true;
     return $args;
 }
开发者ID:rasky,项目名称:roundcubemail,代码行数:21,代码来源:http_authentication.php

示例10: user2email

 function user2email($params)
 {
     $this->log_msg('Search email for user: ' . $params['user']);
     if ($this->init_ldap()) {
         foreach ($this->ldap->search('*', $params['user'], 1)->records as $record) {
             $email = rcube_utils::idn_to_ascii(self::record_attr('email', $record));
             $this->log_msg("Found email: {$email}");
             if ($params['extended']) {
                 $params['email'][] = array('email' => $email, 'name' => self::record_attr('name', $record), 'organization' => self::record_attr('organization', $record));
             } else {
                 $params['email'][] = $email;
             }
             if ($params['first']) {
                 break;
             }
         }
     }
     if (!$params['email']) {
         $this->log_msg('No email found');
     }
     return $params;
 }
开发者ID:jirutka,项目名称:roundcube-virtuser_ldap,代码行数:22,代码来源:virtuser_ldap.php

示例11: mail_domain

 /**
  * Return the mail domain configured for the given host
  *
  * @param string  $host   IMAP host
  * @param boolean $encode If true, domain name will be converted to IDN ASCII
  *
  * @return string Resolved SMTP host
  */
 public function mail_domain($host, $encode = true)
 {
     $domain = $host;
     if (is_array($this->prop['mail_domain'])) {
         if (isset($this->prop['mail_domain'][$host])) {
             $domain = $this->prop['mail_domain'][$host];
         }
     } else {
         if (!empty($this->prop['mail_domain'])) {
             $domain = rcube_utils::parse_host($this->prop['mail_domain']);
         }
     }
     if ($encode) {
         $domain = rcube_utils::idn_to_ascii($domain);
     }
     return $domain;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:25,代码来源:rcube_config.php

示例12: start

 /**
  * Loads configuration, initializes plugin (including sieve connection)
  */
 function start($mode = null)
 {
     // register UI objects
     $this->rc->output->add_handlers(array('filterslist' => array($this, 'filters_list'), 'filtersetslist' => array($this, 'filtersets_list'), 'filterframe' => array($this, 'filter_frame'), 'filterform' => array($this, 'filter_form'), 'filtersetform' => array($this, 'filterset_form')));
     // Get connection parameters
     $host = $this->rc->config->get('managesieve_host', 'localhost');
     $port = $this->rc->config->get('managesieve_port');
     $tls = $this->rc->config->get('managesieve_usetls', false);
     $host = rcube_utils::parse_host($host);
     $host = rcube_utils::idn_to_ascii($host);
     // remove tls:// prefix, set TLS flag
     if (($host = preg_replace('|^tls://|i', '', $host, 1, $cnt)) && $cnt) {
         $tls = true;
     }
     if (empty($port)) {
         $port = getservbyname('sieve', 'tcp');
         if (empty($port)) {
             $port = self::PORT;
         }
     }
     $plugin = $this->rc->plugins->exec_hook('managesieve_connect', array('user' => $_SESSION['username'], 'password' => $this->rc->decrypt($_SESSION['password']), 'host' => $host, 'port' => $port, 'usetls' => $tls, 'auth_type' => $this->rc->config->get('managesieve_auth_type'), 'disabled' => $this->rc->config->get('managesieve_disabled_extensions'), 'debug' => $this->rc->config->get('managesieve_debug', false), 'auth_cid' => $this->rc->config->get('managesieve_auth_cid'), 'auth_pw' => $this->rc->config->get('managesieve_auth_pw')));
     // try to connect to managesieve server and to fetch the script
     $this->sieve = new rcube_sieve($plugin['user'], $plugin['password'], $plugin['host'], $plugin['port'], $plugin['auth_type'], $plugin['usetls'], $plugin['disabled'], $plugin['debug'], $plugin['auth_cid'], $plugin['auth_pw']);
     if (!($error = $this->sieve->error())) {
         // Get list of scripts
         $list = $this->list_scripts();
         // reset current script when entering filters UI (#1489412)
         if ($this->rc->action == 'plugin.managesieve') {
             $this->rc->session->remove('managesieve_current');
         }
         if ($mode != 'vacation') {
             if (!empty($_GET['_set']) || !empty($_POST['_set'])) {
                 $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
             } else {
                 if (!empty($_SESSION['managesieve_current'])) {
                     $script_name = $_SESSION['managesieve_current'];
                 }
             }
         }
         if ($script_name === null || $script_name === '') {
             // get (first) active script
             if (!empty($this->active[0])) {
                 $script_name = $this->active[0];
             } else {
                 if ($list) {
                     $script_name = $list[0];
                 } else {
                     // if script not exists build default script contents
                     $script_file = $this->rc->config->get('managesieve_default');
                     $script_name = $this->rc->config->get('managesieve_script_name');
                     if (empty($script_name)) {
                         $script_name = 'roundcube';
                     }
                     if ($script_file && is_readable($script_file)) {
                         $content = file_get_contents($script_file);
                     }
                     // add script and set it active
                     if ($this->sieve->save_script($script_name, $content)) {
                         $this->activate_script($script_name);
                         $this->list[] = $script_name;
                     }
                 }
             }
         }
         if ($script_name) {
             $this->sieve->load($script_name);
         }
         $error = $this->sieve->error();
     }
     // finally set script objects
     if ($error) {
         switch ($error) {
             case SIEVE_ERROR_CONNECTION:
             case SIEVE_ERROR_LOGIN:
                 $this->rc->output->show_message('managesieve.filterconnerror', 'error');
                 rcube::raise_error(array('code' => 403, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Unable to connect to managesieve on {$host}:{$port}"), true, false);
                 break;
             default:
                 $this->rc->output->show_message('managesieve.filterunknownerror', 'error');
                 break;
         }
         // reload interface in case of possible error when specified script wasn't found (#1489412)
         if ($script_name !== null && !empty($list) && !in_array($script_name, $list)) {
             $this->rc->output->command('reload', 500);
         }
         // to disable 'Add filter' button set env variable
         $this->rc->output->set_env('filterconnerror', true);
         $this->script = array();
     } else {
         $this->exts = $this->sieve->get_extensions();
         $this->init_script();
         $this->rc->output->set_env('currentset', $this->sieve->current);
         $_SESSION['managesieve_current'] = $this->sieve->current;
     }
     return $error;
 }
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:99,代码来源:rcube_sieve_engine.php

示例13: action_save

 /**
  * Handler for ACL update/create action
  */
 private function action_save()
 {
     $mbox = trim(rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true));
     // UTF7-IMAP
     $user = trim(rcube_utils::get_input_value('_user', rcube_utils::INPUT_GPC));
     $acl = trim(rcube_utils::get_input_value('_acl', rcube_utils::INPUT_GPC));
     $oldid = trim(rcube_utils::get_input_value('_old', rcube_utils::INPUT_GPC));
     $acl = array_intersect(str_split($acl), $this->rights_supported());
     $users = $oldid ? array($user) : explode(',', $user);
     $result = 0;
     foreach ($users as $user) {
         $user = trim($user);
         if (!empty($this->specials) && in_array($user, $this->specials)) {
             $username = $this->gettext($user);
         } else {
             if (!empty($user)) {
                 if (!strpos($user, '@') && ($realm = $this->get_realm())) {
                     $user .= '@' . rcube_utils::idn_to_ascii(preg_replace('/^@/', '', $realm));
                 }
                 $username = $user;
             }
         }
         if (!$acl || !$user || !strlen($mbox)) {
             continue;
         }
         $user = $this->mod_login($user);
         $username = $this->mod_login($username);
         if ($user != $_SESSION['username'] && $username != $_SESSION['username']) {
             if ($this->rc->storage->set_acl($mbox, $user, $acl)) {
                 $ret = array('id' => rcube_utils::html_identifier($user), 'username' => $username, 'acl' => implode($acl), 'old' => $oldid);
                 $this->rc->output->command('acl_update', $ret);
                 $result++;
             }
         }
     }
     if ($result) {
         $this->rc->output->show_message($oldid ? 'acl.updatesuccess' : 'acl.createsuccess', 'confirmation');
     } else {
         $this->rc->output->show_message($oldid ? 'acl.updateerror' : 'acl.createerror', 'error');
     }
 }
开发者ID:BIGGANI,项目名称:zpanelx,代码行数:44,代码来源:acl.php

示例14: login

 /**
  * Perfom login to the mail server and to the webmail service.
  * This will also create a new user entry if auto_create_user is configured.
  *
  * @param string Mail storage (IMAP) user name
  * @param string Mail storage (IMAP) password
  * @param string Mail storage (IMAP) host
  *
  * @return boolean True on success, False on failure
  */
 function login($username, $pass, $host = NULL)
 {
     if (empty($username)) {
         return false;
     }
     $config = $this->config->all();
     if (!$host) {
         $host = $config['default_host'];
     }
     // Validate that selected host is in the list of configured hosts
     if (is_array($config['default_host'])) {
         $allowed = false;
         foreach ($config['default_host'] as $key => $host_allowed) {
             if (!is_numeric($key)) {
                 $host_allowed = $key;
             }
             if ($host == $host_allowed) {
                 $allowed = true;
                 break;
             }
         }
         if (!$allowed) {
             return false;
         }
     } else {
         if (!empty($config['default_host']) && $host != rcube_utils::parse_host($config['default_host'])) {
             return false;
         }
     }
     // parse $host URL
     $a_host = parse_url($host);
     if ($a_host['host']) {
         $host = $a_host['host'];
         $ssl = isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl', 'imaps', 'tls')) ? $a_host['scheme'] : null;
         if (!empty($a_host['port'])) {
             $port = $a_host['port'];
         } else {
             if ($ssl && $ssl != 'tls' && (!$config['default_port'] || $config['default_port'] == 143)) {
                 $port = 993;
             }
         }
     }
     if (!$port) {
         $port = $config['default_port'];
     }
     /* Modify username with domain if required
           Inspired by Marco <P0L0_notspam_binware.org>
        */
     // Check if we need to add domain
     if (!empty($config['username_domain']) && strpos($username, '@') === false) {
         if (is_array($config['username_domain']) && isset($config['username_domain'][$host])) {
             $username .= '@' . rcube_utils::parse_host($config['username_domain'][$host], $host);
         } else {
             if (is_string($config['username_domain'])) {
                 $username .= '@' . rcube_utils::parse_host($config['username_domain'], $host);
             }
         }
     }
     // Convert username to lowercase. If storage backend
     // is case-insensitive we need to store always the same username (#1487113)
     if ($config['login_lc']) {
         $username = mb_strtolower($username);
     }
     // try to resolve email address from virtuser table
     if (strpos($username, '@') && ($virtuser = rcube_user::email2user($username))) {
         $username = $virtuser;
     }
     // Here we need IDNA ASCII
     // Only rcube_contacts class is using domain names in Unicode
     $host = rcube_utils::idn_to_ascii($host);
     if (strpos($username, '@')) {
         // lowercase domain name
         list($local, $domain) = explode('@', $username);
         $username = $local . '@' . mb_strtolower($domain);
         $username = rcube_utils::idn_to_ascii($username);
     }
     // user already registered -> overwrite username
     if ($user = rcube_user::query($username, $host)) {
         $username = $user->data['username'];
     }
     $storage = $this->get_storage();
     // try to log in
     if (!($login = $storage->connect($host, $username, $pass, $port, $ssl))) {
         // try with lowercase
         $username_lc = mb_strtolower($username);
         if ($username_lc != $username) {
             // try to find user record again -> overwrite username
             if (!$user && ($user = rcube_user::query($username_lc, $host))) {
                 $username_lc = $user->data['username'];
             }
//.........这里部分代码省略.........
开发者ID:npk,项目名称:roundcubemail,代码行数:101,代码来源:rcmail.php

示例15: _connect

 /**
  * Establish a connection to the LDAP server
  */
 private function _connect()
 {
     $rcube = rcube::get_instance();
     if (!function_exists('ldap_connect')) {
         rcube::raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "No ldap support in this installation of PHP"), true, true);
     }
     if (is_resource($this->conn)) {
         return true;
     }
     if (!is_array($this->prop['hosts'])) {
         $this->prop['hosts'] = array($this->prop['hosts']);
     }
     if (empty($this->prop['ldap_version'])) {
         $this->prop['ldap_version'] = 3;
     }
     foreach ($this->prop['hosts'] as $host) {
         $host = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
         $hostname = $host . ($this->prop['port'] ? ':' . $this->prop['port'] : '');
         $this->_debug("C: Connect [{$hostname}] [{$this->prop['name']}]");
         if ($lc = @ldap_connect($host, $this->prop['port'])) {
             if ($this->prop['use_tls'] === true) {
                 if (!ldap_start_tls($lc)) {
                     continue;
                 }
             }
             $this->_debug("S: OK");
             ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, $this->prop['ldap_version']);
             $this->prop['host'] = $host;
             $this->conn = $lc;
             if (isset($this->prop['referrals'])) {
                 ldap_set_option($lc, LDAP_OPT_REFERRALS, $this->prop['referrals']);
             }
             break;
         }
         $this->_debug("S: NOT OK");
     }
     // See if the directory is writeable.
     if ($this->prop['writable']) {
         $this->readonly = false;
     }
     if (!is_resource($this->conn)) {
         rcube::raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not connect to any LDAP server, last tried {$hostname}"), true);
         return false;
     }
     $bind_pass = $this->prop['bind_pass'];
     $bind_user = $this->prop['bind_user'];
     $bind_dn = $this->prop['bind_dn'];
     $this->base_dn = $this->prop['base_dn'];
     $this->groups_base_dn = $this->prop['groups']['base_dn'] ? $this->prop['groups']['base_dn'] : $this->base_dn;
     // User specific access, generate the proper values to use.
     if ($this->prop['user_specific']) {
         // No password set, use the session password
         if (empty($bind_pass)) {
             $bind_pass = $rcube->decrypt($_SESSION['password']);
         }
         // Get the pieces needed for variable replacement.
         if ($fu = $rcube->get_user_name()) {
             list($u, $d) = explode('@', $fu);
         } else {
             $d = $this->mail_domain;
         }
         $dc = 'dc=' . strtr($d, array('.' => ',dc='));
         // hierarchal domain string
         $replaces = array('%dn' => '', '%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u);
         if ($this->prop['search_base_dn'] && $this->prop['search_filter']) {
             if (!empty($this->prop['search_bind_dn']) && !empty($this->prop['search_bind_pw'])) {
                 $this->bind($this->prop['search_bind_dn'], $this->prop['search_bind_pw']);
             }
             // Search for the dn to use to authenticate
             $this->prop['search_base_dn'] = strtr($this->prop['search_base_dn'], $replaces);
             $this->prop['search_filter'] = strtr($this->prop['search_filter'], $replaces);
             $this->_debug("S: searching with base {$this->prop['search_base_dn']} for {$this->prop['search_filter']}");
             $res = @ldap_search($this->conn, $this->prop['search_base_dn'], $this->prop['search_filter'], array('uid'));
             if ($res) {
                 if (($entry = ldap_first_entry($this->conn, $res)) && ($bind_dn = ldap_get_dn($this->conn, $entry))) {
                     $this->_debug("S: search returned dn: {$bind_dn}");
                     $dn = ldap_explode_dn($bind_dn, 1);
                     $replaces['%dn'] = $dn[0];
                 }
             } else {
                 $this->_debug("S: " . ldap_error($this->conn));
             }
             // DN not found
             if (empty($replaces['%dn'])) {
                 if (!empty($this->prop['search_dn_default'])) {
                     $replaces['%dn'] = $this->prop['search_dn_default'];
                 } else {
                     rcube::raise_error(array('code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, 'message' => "DN not found using LDAP search."), true);
                     return false;
                 }
             }
         }
         // Replace the bind_dn and base_dn variables.
         $bind_dn = strtr($bind_dn, $replaces);
         $this->base_dn = strtr($this->base_dn, $replaces);
         $this->groups_base_dn = strtr($this->groups_base_dn, $replaces);
         if (empty($bind_user)) {
//.........这里部分代码省略.........
开发者ID:nmrugg,项目名称:roundcubemail,代码行数:101,代码来源:rcube_ldap.php


注:本文中的rcube_utils::idn_to_ascii方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。