| | |
| | | |
| | | foreach ($p as $prop => $value) |
| | | if (preg_match('/^(.+)_field$/', $prop, $matches)) |
| | | $this->fieldmap[$matches[1]] = strtolower($value); |
| | | $this->fieldmap[$matches[1]] = $this->_attr_name(strtolower($value)); |
| | | |
| | | // make sure 'required_fields' is an array |
| | | if (!is_array($this->prop['required_fields'])) |
| | | $this->prop['required_fields'] = (array) $this->prop['required_fields']; |
| | | |
| | | foreach ($this->prop['required_fields'] as $key => $val) |
| | | $this->prop['required_fields'][$key] = $this->_attr_name(strtolower($val)); |
| | | |
| | | $this->sort_col = $p['sort']; |
| | | |
| | |
| | | $res = null; |
| | | if ($this->conn && $dn) |
| | | { |
| | | $this->ldap_result = ldap_read($this->conn, base64_decode($dn), '(objectclass=*)', array_values($this->fieldmap)); |
| | | $this->ldap_result = @ldap_read($this->conn, base64_decode($dn), '(objectclass=*)', array_values($this->fieldmap)); |
| | | $entry = @ldap_first_entry($this->conn, $this->ldap_result); |
| | | |
| | | if ($entry && ($rec = ldap_get_attributes($this->conn, $entry))) |
| | |
| | | } // end if |
| | | } // end foreach |
| | | |
| | | return true; |
| | | return count($dns); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @access private |
| | | */ |
| | | function _exec_search() |
| | | private function _exec_search() |
| | | { |
| | | if ($this->ready) |
| | | { |
| | | $filter = $this->filter ? $this->filter : '(objectclass=*)'; |
| | | $function = $this->prop['scope'] == 'sub' ? 'ldap_search' : ($this->prop['scope'] == 'base' ? 'ldap_read' : 'ldap_list'); |
| | | $this->ldap_result = $function($this->conn, $this->prop['base_dn'], $filter, array_values($this->fieldmap), 0, 0); |
| | | $this->ldap_result = @$function($this->conn, $this->prop['base_dn'], $filter, array_values($this->fieldmap), 0, 0); |
| | | return true; |
| | | } |
| | | else |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function _ldap2result($rec) |
| | | private function _ldap2result($rec) |
| | | { |
| | | global $RCMAIL; |
| | | |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function _map_field($field) |
| | | private function _map_field($field) |
| | | { |
| | | return $this->fieldmap[$field]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @access private |
| | | */ |
| | | private function _attr_name($name) |
| | | { |
| | | // list of known attribute aliases |
| | | $aliases = array( |
| | | 'gn' => 'givenname', |
| | | 'rfc822mailbox' => 'mail', |
| | | 'userid' => 'uid', |
| | | 'emailaddress' => 'email', |
| | | 'pkcs9email' => 'email', |
| | | ); |
| | | return isset($aliases[$name]) ? $aliases[$name] : $name; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @static |
| | | */ |
| | | function quote_string($str) |