Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 public function list_replicas()
 {
     $this->_debug("Finding replicas for this server.");
     // Search any host that is a replica for the current host
     $replica_hosts = $this->config_get('replica_hosts', array());
     $root_dn = $this->config_get('config_root_dn');
     if (!empty($replica_hosts)) {
         return $replica_hosts;
     }
     $ldap = new Net_LDAP3($this->config);
     $ldap->connect();
     $ldap->bind($this->_current_bind_dn, $this->_current_bind_pw);
     $result = $ldap->search($root_dn, '(objectclass=nsds5replicationagreement)', 'sub', array('nsds5replicahost'));
     if (!$result) {
         $this->_debug("No replicas configured");
         return $replica_hosts;
     }
     $this->_debug("Replication agreements found: " . var_export($result->entries(true), true));
     foreach ($result->entries(true) as $dn => $attrs) {
         if (!in_array($attrs['nsds5replicahost'], $replica_hosts)) {
             $replica_hosts[] = $attrs['nsds5replicahost'];
         }
     }
     // $replica_hosts now holds the IDs of servers we are currently NOT
     // connected to. We might need this later in order to set
     $this->_server_id_not = $replica_hosts;
     $this->_debug("So far, we have the following replicas: " . var_export($replica_hosts, true));
     $ldap->close();
     foreach ($replica_hosts as $replica_host) {
         $ldap->config_set('hosts', array($replica_host));
         $ldap->connect();
         $ldap->bind($this->_current_bind_dn, $this->_current_bind_pw);
         $result = $ldap->search($root_dn, '(objectclass=nsds5replicationagreement)', 'sub', array('nsds5replicahost'));
         if (!$result) {
             $this->_debug("No replicas configured on {$replica_host}");
             $ldap->close();
             continue;
         }
         foreach ($result->entries(true) as $dn => $attrs) {
             if (!in_array($attrs['nsds5replicahost'], $replica_hosts)) {
                 $replica_hosts[] = $attrs['nsds5replicahost'];
             }
         }
         $ldap->close();
     }
     $this->config_set('replica_hosts', $replica_hosts);
     return $replica_hosts;
 }