* @author Benedikt Hallinger <beni@php.net>
* @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: LDAP2.php 332308 2013-12-09 09:15:47Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
* @access public
* @return Net_LDAP2_Error|Net_LDAP2 Net_LDAP2_Error or Net_LDAP2 object
*/
- public static function &connect($config = array())
+ public static function connect($config = array())
{
$ldap_check = self::checkLDAPExtension();
if (self::iserror($ldap_check)) {
*/
public function __construct($config = array())
{
- $this->PEAR('Net_LDAP2_Error');
+ parent::__construct('Net_LDAP2_Error');
$this->setConfig($config);
}
public function start_tls()
{
$args = func_get_args();
- return call_user_func_array(array( &$this, 'startTLS' ), $args);
+ return call_user_func_array(array( $this, 'startTLS' ), $args);
}
/**
* This also links the entry to the connection used for the add,
* if it was a fresh entry ({@link Net_LDAP2_Entry::createFresh()})
*
- * @param Net_LDAP2_Entry &$entry Net_LDAP2_Entry
+ * @param Net_LDAP2_Entry $entry Net_LDAP2_Entry
*
* @return Net_LDAP2_Error|true Net_LDAP2_Error object or true
*/
- public function add(&$entry)
+ public function add($entry)
{
if (!$entry instanceof Net_LDAP2_Entry) {
return PEAR::raiseError('Parameter to Net_LDAP2::add() must be a Net_LDAP2_Entry object.');
* @return Net_LDAP2_Entry|Net_LDAP2_Error Reference to a Net_LDAP2_Entry object or Net_LDAP2_Error object
* @todo Maybe check against the shema should be done to be sure the attribute type exists
*/
- public function &getEntry($dn, $attr = array())
+ public function getEntry($dn, $attr = array())
{
if (!is_array($attr)) {
$attr = array($attr);
if (is_string($entry)) {
$entry_o = $this->getEntry($entry);
} else {
- $entry_o =& $entry;
+ $entry_o = $entry;
}
if (!$entry_o instanceof Net_LDAP2_Entry) {
return PEAR::raiseError('Parameter $entry is expected to be a Net_LDAP2_Entry object! (If DN was passed, conversion failed)');
* Please note that only attributes you have
* selected will be copied.
*
- * @param Net_LDAP2_Entry &$entry Entry object
+ * @param Net_LDAP2_Entry $entry Entry object
* @param string $newdn New FQF-DN of the entry
*
* @return Net_LDAP2_Error|Net_LDAP2_Entry Error Message or reference to the copied entry
*/
- public function ©(&$entry, $newdn)
+ public function copy($entry, $newdn)
{
if (!$entry instanceof Net_LDAP2_Entry) {
return PEAR::raiseError('Parameter $entry is expected to be a Net_LDAP2_Entry object!');
* @access public
* @return Net_LDAP2_Error|Net_LDAP2_RootDSE Net_LDAP2_Error or Net_LDAP2_RootDSE object
*/
- public function &rootDse($attrs = null)
+ public function rootDse($attrs = null)
{
if ($attrs !== null && !is_array($attrs)) {
return PEAR::raiseError('Parameter $attr is expected to be an array!');
// see if we need to fetch a fresh object, or if we already
// requested this object with the same attributes
if (true || !array_key_exists($attrs_signature, $this->_rootDSE_cache)) {
- $rootdse =& Net_LDAP2_RootDSE::fetch($this, $attrs);
+ $rootdse = Net_LDAP2_RootDSE::fetch($this, $attrs);
if ($rootdse instanceof Net_LDAP2_Error) {
return $rootdse;
}
* @see rootDse()
* @return Net_LDAP2_Error|Net_LDAP2_RootDSE
*/
- public function &root_dse()
+ public function root_dse()
{
$args = func_get_args();
- return call_user_func_array(array(&$this, 'rootDse'), $args);
+ return call_user_func_array(array($this, 'rootDse'), $args);
}
/**
* @access public
* @return Net_LDAP2_Schema|Net_LDAP2_Error Net_LDAP2_Schema or Net_LDAP2_Error object
*/
- public function &schema($dn = null)
+ public function schema($dn = null)
{
// Schema caching by Knut-Olav Hoven
// If a schema caching object is registered, we use that to fetch
* @access public
* @return resource LDAP link
*/
- public function &getLink()
+ public function getLink()
{
if ($this->_config['auto_reconnect']) {
while (true) {
$level = E_USER_NOTICE, $debuginfo = null)
{
if (is_int($code)) {
- $this->PEAR_Error($message . ': ' . Net_LDAP2::errorMessage($code), $code, $mode, $level, $debuginfo);
+ parent::__construct($message . ': ' . Net_LDAP2::errorMessage($code), $code, $mode, $level, $debuginfo);
} else {
- $this->PEAR_Error("$message: $code", NET_LDAP2_ERROR, $mode, $level, $debuginfo);
+ parent::__construct("$message: $code", NET_LDAP2_ERROR, $mode, $level, $debuginfo);
}
}
}
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Tarjej Huse, Jan Wagner, Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: Entry.php 332301 2013-12-09 08:17:14Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
* You should not call this method manually! Use {@link Net_LDAP2_Entry::createFresh()}
* or {@link Net_LDAP2_Entry::createConnected()} instead!
*
- * @param Net_LDAP2|ressource|array &$ldap Net_LDAP2 object, ldap-link ressource or array of attributes
+ * @param Net_LDAP2|ressource|array $ldap Net_LDAP2 object, ldap-link ressource or array of attributes
* @param string|ressource $entry Either a DN or a LDAP-Entry ressource
*
* @access protected
* @return none
*/
- protected function __construct(&$ldap, $entry = null)
+ public function __construct($ldap, $entry = null)
{
- $this->PEAR('Net_LDAP2_Error');
+ parent::__construct('Net_LDAP2_Error');
// set up entry resource or DN
if (is_resource($entry)) {
- $this->_entry = &$entry;
+ $this->_entry = $entry;
} else {
$this->_dn = $entry;
}
// set up LDAP link
if ($ldap instanceof Net_LDAP2) {
- $this->_ldap = &$ldap;
+ $this->_ldap = $ldap;
$this->_link = $ldap->getLink();
} elseif (is_resource($ldap)) {
$this->_link = $ldap;
if (is_null($attributes) && is_resource($this->_entry) && is_resource($this->_link)) {
// fetch schema
if ($this->_ldap instanceof Net_LDAP2) {
- $schema =& $this->_ldap->schema();
+ $schema = $this->_ldap->schema();
}
// fetch attributes
$attributes = array();
public function get_value()
{
$args = func_get_args();
- return call_user_func_array(array( &$this, 'getValue' ), $args);
+ return call_user_func_array(array( $this, 'getValue' ), $args);
}
/**
}
// ensure we have a valid LDAP object
- $ldap =& $this->getLDAP();
+ $ldap = $this->getLDAP();
if (!$ldap instanceof Net_LDAP2) {
return PEAR::raiseError("The entries LDAP object is not valid");
}
* @access public
* @return Net_LDAP2|Net_LDAP2_Error Reference to the Net_LDAP2 Object (the connection) or Net_LDAP2_Error
*/
- public function &getLDAP()
+ public function getLDAP()
{
if (!$this->_ldap instanceof Net_LDAP2) {
$err = new PEAR_Error('LDAP is not a valid Net_LDAP2 object');
* After setting a Net_LDAP2 object, calling update() will use that object for
* updating directory contents. Use this to dynamicly switch directorys.
*
- * @param Net_LDAP2 &$ldap Net_LDAP2 object that this entry should be connected to
+ * @param Net_LDAP2 $ldap Net_LDAP2 object that this entry should be connected to
*
* @access public
* @return true|Net_LDAP2_Error
*/
- public function setLDAP(&$ldap)
+ public function setLDAP($ldap)
{
if (!$ldap instanceof Net_LDAP2) {
return PEAR::raiseError("LDAP is not a valid Net_LDAP2 object");
} else {
- $this->_ldap =& $ldap;
+ $this->_ldap = $ldap;
return true;
}
}
*
* Usage example:
* <code>
- * $result = $entry->preg_match('/089(\d+)/', 'telephoneNumber', &$matches);
+ * $result = $entry->preg_match('/089(\d+)/', 'telephoneNumber', $matches);
* if ( $result === true ){
* echo "First match: ".$matches[0][1]; // Match of value 1, content of first bracket
* } else {
public function preg_match()
{
$args = func_get_args();
- return call_user_func_array(array( &$this, 'pregMatch' ), $args);
+ return call_user_func_array(array( $this, 'pregMatch' ), $args);
}
/**
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: Filter.php 332305 2013-12-09 08:51:41Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
*
* @return Net_LDAP2_Filter|Net_LDAP2_Error
*/
- public static function &create($attr_name, $match, $value = '', $escape = true)
+ public static function create($attr_name, $match, $value = '', $escape = true)
{
$leaf_filter = new Net_LDAP2_Filter();
if ($escape) {
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: LDIF.php 324918 2012-04-06 12:31:04Z clockwerx $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
*/
public function __construct($file, $mode = 'r', $options = array())
{
- $this->PEAR('Net_LDAP2_Error'); // default error class
+ parent::__construct('Net_LDAP2_Error'); // default error class
// First, parse options
// todo: maybe implement further checks on possible values
* @author Jan Wagner <wagner@netsols.de>
* @copyright 2009 Jan Wagner
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: RootDSE.php 286718 2009-08-03 07:30:49Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
*
* @param Net_LDAP2_Entry &$entry Net_LDAP2_Entry object of the RootDSE
*/
- protected function __construct(&$entry)
+ public function __construct(&$entry)
{
$this->_entry = $entry;
}
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Jan Wagner, Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: Schema.php 296515 2010-03-22 14:46:41Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
* @todo see the comment at the end of the file
*/
*
* @access protected
*/
- protected function __construct()
+ public function __construct()
{
- $this->PEAR('Net_LDAP2_Error'); // default error class
+ parent::__construct('Net_LDAP2_Error'); // default error class
}
/**
* @access public
* @return Net_LDAP2_Schema|NET_LDAP2_Error
*/
- public function fetch($ldap, $dn = null)
+ public static function fetch($ldap, $dn = null)
{
if (!$ldap instanceof Net_LDAP2) {
return PEAR::raiseError("Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!");
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: SchemaCache.interface.php 286718 2009-08-03 07:30:49Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Tarjej Huse, Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: Search.php 328961 2013-01-03 09:04:30Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
/**
* Constructor
*
- * @param resource &$search Search result identifier
- * @param Net_LDAP2|resource &$ldap Net_LDAP2 object or just a LDAP-Link resource
+ * @param resource $search Search result identifier
+ * @param Net_LDAP2|resource $ldap Net_LDAP2 object or just a LDAP-Link resource
* @param array $attributes (optional) Array with searched attribute names. (see {@link $_searchedAttrs})
*
* @access public
*/
- public function __construct(&$search, &$ldap, $attributes = array())
+ public function __construct($search, $ldap, $attributes = array())
{
- $this->PEAR('Net_LDAP2_Error');
+ parent::__construct('Net_LDAP2_Error');
$this->setSearch($search);
if ($ldap instanceof Net_LDAP2) {
- $this->_ldap =& $ldap;
+ $this->_ldap = $ldap;
$this->setLink($this->_ldap->getLink());
} else {
$this->setLink($ldap);
*
* @return Net_LDAP2_Entry|false Reference to Net_LDAP2_Entry object or false
*/
- public function &shiftEntry()
+ public function shiftEntry()
{
if (is_null($this->_entry)) {
if(!$this->_entry = @ldap_first_entry($this->_link, $this->_search)) {
public function shift_entry()
{
$args = func_get_args();
- return call_user_func_array(array( &$this, 'shiftEntry' ), $args);
+ return call_user_func_array(array( $this, 'shiftEntry' ), $args);
}
/**
public function pop_entry()
{
$args = func_get_args();
- return call_user_func_array(array( &$this, 'popEntry' ), $args);
+ return call_user_func_array(array( $this, 'popEntry' ), $args);
}
/**
/**
* Set the search objects resource link
*
- * @param resource &$search Search result identifier
+ * @param resource $search Search result identifier
*
* @access public
* @return void
*/
- public function setSearch(&$search)
+ public function setSearch($search)
{
$this->_search = $search;
}
/**
* Set the ldap ressource link
*
- * @param resource &$link Link identifier
+ * @param resource $link Link identifier
*
* @access public
* @return void
*/
- public function setLink(&$link)
+ public function setLink($link)
{
$this->_link = $link;
}
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: SimpleFileSchemaCache.php 286718 2009-08-03 07:30:49Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
*
* @param array $cfg Config array
*/
- public function Net_LDAP2_SimpleFileSchemaCache($cfg)
+ public function __construct($cfg)
{
foreach ($cfg as $key => $value) {
if (array_key_exists($key, $this->config)) {
* @author Benedikt Hallinger <beni@php.net>
* @copyright 2009 Benedikt Hallinger
* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3
-* @version SVN: $Id: Util.php 332278 2013-12-05 11:01:15Z beni $
+* @version SVN: $Id$
* @link http://pear.php.net/package/Net_LDAP2/
*/
// MV RDN!
foreach ($rdns as $subrdn_k => $subrdn_v) {
// Casefolding
- if ($options['casefold'] == 'upper') $subrdn_v = preg_replace("/^(\w+=)/e", "''.strtoupper('\\1').''", $subrdn_v);
- if ($options['casefold'] == 'lower') $subrdn_v = preg_replace("/^(\w+=)/e", "''.strtolower('\\1').''", $subrdn_v);
+ if ($options['casefold'] == 'upper') {
+ $subrdn_v = preg_replace_callback(
+ "/^\w+=/",
+ function ($matches) {
+ return strtoupper($matches[0]);
+ },
+ $subrdn_v
+ );
+ } else if ($options['casefold'] == 'lower') {
+ $subrdn_v = preg_replace_callback(
+ "/^\w+=/",
+ function ($matches) {
+ return strtolower($matches[0]);
+ },
+ $subrdn_v
+ );
+ }
if ($options['onlyvalues']) {
preg_match('/(.+?)(?<!\\\\)=(.+)/', $subrdn_v, $matches);
// normal RDN
// Casefolding
- if ($options['casefold'] == 'upper') $value = preg_replace("/^(\w+=)/e", "''.strtoupper('\\1').''", $value);
- if ($options['casefold'] == 'lower') $value = preg_replace("/^(\w+=)/e", "''.strtolower('\\1').''", $value);
+ if ($options['casefold'] == 'upper') {
+ $value = preg_replace_callback(
+ "/^\w+=/",
+ function ($matches) {
+ return strtoupper($matches[0]);
+ },
+ $value
+ );
+ } else if ($options['casefold'] == 'lower') {
+ $value = preg_replace_callback(
+ "/^\w+=/",
+ function ($matches) {
+ return strtolower($matches[0]);
+ },
+ $value
+ );
+ }
if ($options['onlyvalues']) {
preg_match('/(.+?)(?<!\\\\)=(.+)/', $value, $matches);
*/
public static function hex2asc($string)
{
- $string = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $string);
+ $string = preg_replace_callback(
+ "/\\\[0-9A-Fa-f]{2}/",
+ function ($matches) {
+ return chr(hexdec($matches[0]));
+ },
+ $string
+ );
return $string;
}