Net_LDAP
[ class tree: Net_LDAP ] [ index: Net_LDAP ] [ all elements ]

Source for file Entry.php

Documentation is available at Entry.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +--------------------------------------------------------------------------+
  4. // | Net_LDAP                                                                 |
  5. // +--------------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                    |
  7. // +--------------------------------------------------------------------------+
  8. // | This library is free software; you can redistribute it and/or            |
  9. // | modify it under the terms of the GNU Lesser General Public               |
  10. // | License as published by the Free Software Foundation; either             |
  11. // | version 2.1 of the License, or (at your option) any later version.       |
  12. // |                                                                          |
  13. // | This library is distributed in the hope that it will be useful,          |
  14. // | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
  15. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        |
  16. // | Lesser General Public License for more details.                          |
  17. // |                                                                          |
  18. // | You should have received a copy of the GNU Lesser General Public         |
  19. // | License along with this library; if not, write to the Free Software      |
  20. // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA |
  21. // +--------------------------------------------------------------------------+
  22. // | Authors: Jan Wagner                                                     |
  23. // +--------------------------------------------------------------------------+
  24. //
  25. // $Id: Entry.php,v 1.29 2007/01/10 07:38:02 beni Exp $
  26.  
  27. require_once("PEAR.php");
  28.  
  29. /**
  30.  * Object representation of a directory entry
  31.  *
  32.  * This class represents a directory entry. You can add, delete, replace
  33.  * attributes and their values, rename the entry, delete the entry.
  34.  *
  35.  * @package Net_LDAP
  36.  * @author Jan Wagner <wagner@netsols.de>
  37.  * @author Tarjej Huse
  38.  * @version $Revision: 1.29 $
  39.  */
  40.  
  41. class Net_LDAP_Entry extends PEAR
  42. {
  43.     /**
  44.      * Entry ressource identifier
  45.      *
  46.      * @access private
  47.      * @var ressourcee 
  48.      */
  49.     var $_entry = null;
  50.  
  51.     /**
  52.      * LDAP ressource identifier
  53.      *
  54.      * @access private
  55.      * @var ressource 
  56.      */
  57.     var $_link = null;
  58.  
  59.     /**
  60.      * Net_LDAP object
  61.      *
  62.      * This object will be used for updating and schema checking
  63.      *
  64.      * @access private
  65.      * @var object Net_LDAP 
  66.      */
  67.     var $_ldap = null;
  68.  
  69.     /**
  70.      * Distinguished name of the entry
  71.      *
  72.      * @access private
  73.      * @var string 
  74.      */
  75.     var $_dn = null;
  76.  
  77.     /**
  78.      * Attributes
  79.      *
  80.      * @access private
  81.      * @var array 
  82.      */
  83.     var $_attributes = array();
  84.  
  85.     /**
  86.      * Original attributes before any modification
  87.      *
  88.      * @access private
  89.      * @var array 
  90.      */
  91.     var $_original = array();
  92.  
  93.  
  94.     /**
  95.      * Map of attribute names
  96.      *
  97.      * @access private
  98.      * @var array 
  99.      */
  100.     var $_map = array();
  101.  
  102.  
  103.     /**
  104.      * Is this a new entry?
  105.      *
  106.      * @access private
  107.      * @var boolean 
  108.      */
  109.     var $_new = true;
  110.  
  111.     /**
  112.      * New distinguished name
  113.      *
  114.      * @access private
  115.      * @var string 
  116.      */
  117.     var $_newdn = null;
  118.  
  119.     /**
  120.      * Shall the entry be deleted?
  121.      *
  122.      * @access private
  123.      * @var boolean 
  124.      */
  125.     var $_delete = false;
  126.  
  127.     /**
  128.      * Map with changes to the entry
  129.      *
  130.      * @access private
  131.      * @var array 
  132.      */
  133.     var $_changes = array("add"     => array(),
  134.                           "delete"  => array(),
  135.                           "replace" => array()
  136.                           );
  137.     /**
  138.      * Constructor
  139.      *
  140.      * Constructor of the entry. Sets up the distinguished name and the entries
  141.      * attributes.
  142.      *
  143.      * @access protected
  144.      * @param Net_LDAP|ressource|array$ldap   Net_LDAP object, ldap-link ressource or array of attributes
  145.      * @param string|ressource        $entry  Either a DN or a LDAP-Entry
  146.      * @return none 
  147.      */
  148.     function Net_LDAP_Entry(&$ldap$entry = null)
  149.     {
  150.         $this->PEAR('Net_LDAP_Error');
  151.  
  152.         if (is_resource($entry)) {
  153.             $this->_entry &$entry;
  154.         else {
  155.             $this->_dn $entry;
  156.         }
  157.  
  158.         if (is_a($ldap'Net_LDAP')) {
  159.             $this->_ldap &$ldap;
  160.             $this->_link $ldap->getLink();
  161.         elseif (is_resource($ldap)) {
  162.             $this->_link $ldap;
  163.         elseif (is_array($ldap)) {
  164.             $this->_setAttributes($ldap);
  165.         }
  166.  
  167.         if (is_resource($this->_entry&& is_resource($this->_link)) {
  168.             $this->_new = false;
  169.             $this->_dn  @ldap_get_dn($this->_link$this->_entry);
  170.             $this->_setAttributes();
  171.         }
  172.     }
  173.  
  174.     /**
  175.      * Get or set the distinguished name of the entry
  176.      *
  177.      * If called without an argument the current (or the new DN if set) DN gets returned.
  178.      * If you provide an DN, this entry is moved to the new location specified if a DN existed.
  179.      * If the DN was not set, the DN gets initialized. Call {@link update()} to actually create
  180.      * the new Entry in the directory.
  181.      *
  182.      * Please note that special characters (eg german umlauts) should be encoded using utf8_encode().
  183.      *
  184.      * @access public
  185.      * @param string $dn New distinguished name
  186.      * @return string|trueDistinguished name (or true if a new DN was provided)
  187.      */
  188.     function dn($dn = null)
  189.     {
  190.         if (false == is_null($dn)) {
  191.             if (is_null($this->_dn)) {
  192.                 $this->_dn $dn;
  193.             else {
  194.                 $this->_newdn $dn;
  195.             }
  196.             return true;
  197.         }
  198.         return (isset($this->_newdn$this->_newdn $this->_dn);
  199.     }
  200.  
  201.     /**
  202.      * Sets the internal attributes array
  203.      *
  204.      * This fetches the values for the attributes from the server.
  205.      *
  206.      * @access private
  207.      * @param array $attributes 
  208.      */
  209.     function _setAttributes($attributes = null)
  210.     {
  211.         // fetch attributes from the server
  212.         if (is_null($attributes&& is_resource($this->_entry&& is_resource($this->_link))
  213.         {
  214.             // fetch schema
  215.             if (is_a($this->_ldap'Net_LDAP')) {
  216.                 $schema $this->_ldap->schema();
  217.             }
  218.             // fetch attributes
  219.             $attributes = array();
  220.             do {
  221.                 if (empty($attr)) {
  222.                     $ber = null;
  223.                     $attr @ldap_first_attribute($this->_link$this->_entry$ber);
  224.                 else {
  225.                     $attr @ldap_next_attribute($this->_link$this->_entry$ber);
  226.                 }
  227.                 if ($attr{
  228.                     $func 'ldap_get_values'// function to fetch value
  229.                     if (is_a($schema'Net_LDAP_Schema')) {
  230.                         // try to get binary values as binary data
  231.                         $attr_s $schema->get('attribute'$attr);
  232.                         if (false === Net_LDAP::isError($attr_s)) {
  233.                             if (false !== strpos($attr_s['syntax']NET_LDAP_SYNTAX_OCTET_STRING)) {
  234.                                 $func 'ldap_get_values_len';
  235.                             }
  236.                         }
  237.                     }
  238.                     // fetch attribute value (needs error checking?)
  239.                     $attributes[$attr$func($this->_link$this->_entry$attr);
  240.                 }
  241.             while ($attr);
  242.         }
  243.  
  244.         if (is_array($attributes&& count($attributes> 0{
  245.             if (isset($attributes["count"]&& is_numeric($attributes["count"])) {
  246.                 unset($attributes["count"]);
  247.             }
  248.             foreach ($attributes as $k => $v{
  249.                 // attribute names should not be numeric
  250.                 if (is_numeric($k)) {
  251.                     continue;
  252.                 }
  253.                 // map generic attribute name to real one
  254.                 $this->_map[strtolower($k)$k;
  255.                 // attribute values should be in an array
  256.                 if (false == is_array($v)) {
  257.                     $v = array($v);
  258.                 }
  259.                 // remove the value count (comes from ldap server)
  260.                 if (isset($v["count"])) {
  261.                     unset($v["count"]);
  262.                 }
  263.                 $this->_attributes[$k$v;
  264.             }
  265.         }
  266.         // save a copy for later use
  267.         $this->_original $this->_attributes;
  268.     }
  269.     /**
  270.      * Get the values of all attributes in a hash
  271.      *
  272.      * The returned hash has the form
  273.      * array('attributename' => 'single value',
  274.      *       'attributename' => array('value1', value2', value3'))
  275.      *
  276.      * @access public
  277.      * @return array Hash of all attributes with their values
  278.      */
  279.     function getValues()
  280.     {
  281.         $attrs = array();
  282.         foreach ($this->_attributes as $attr => $value{
  283.             $attrs[$attr$this->getValue($attr);
  284.         }
  285.         return $attrs;
  286.     }
  287.  
  288.     /**
  289.      * Get the value of a specific attribute
  290.      *
  291.      * The first parameter is the name of the attribute
  292.      * The second parameter influences the way the value is returned:
  293.      * 'single': only the first value is returned as string
  294.      * 'all': all values including the value count are returned in an
  295.      *               array
  296.      * 'default': in all other cases an attribute value with a single value is
  297.      *            returned a string, if it has multiple values it is returned
  298.      *            as an array (without value count)
  299.      *
  300.      * @access public
  301.      * @param string $attr Attribute name
  302.      * @param string $option Option
  303.      * @return string|array|PEAR_Errorstring, array or PEAR_Error
  304.      */
  305.     function getValue($attr$option = null)
  306.     {
  307.         $attr $this->_getAttrName($attr);
  308.  
  309.         if (false == array_key_exists($attr$this->_attributes)) {
  310.             return PEAR::raiseError("Unknown attribute ($attr) requested");
  311.         }
  312.  
  313.         $value $this->_attributes[$attr];
  314.  
  315.         if ($option == "single" || (count($value== 1 && $option != 'all')) {
  316.             $value array_shift($value);
  317.         }
  318.  
  319.         return $value;
  320.     }
  321.  
  322.     /**
  323.      * Alias function of getValue for perl-ldap interface
  324.      *
  325.      * @see getValue()
  326.      */
  327.     function get_value()
  328.     {
  329.         $args func_get_args();
  330.         return call_user_func_array(array&$this'getValue' )$args);
  331.     }
  332.  
  333.     /**
  334.      * Returns an array of attributes names
  335.      *
  336.      * @access public
  337.      * @return array Array of attribute names
  338.      */
  339.     function attributes()
  340.     {
  341.         return array_keys($this->_attributes);
  342.     }
  343.  
  344.     /**
  345.      * Returns whether an attribute exists or not
  346.      *
  347.      * @access public
  348.      * @param string $attr Attribute name
  349.      * @return boolean 
  350.      */
  351.     function exists($attr)
  352.     {
  353.         $attr $this->_getAttrName($attr);
  354.         return array_key_exists($attr$this->_attributes);
  355.     }
  356.  
  357.     /**
  358.      * Adds a new attribute or a new value to an existing attribute
  359.      *
  360.      * The paramter has to be an array of the form:
  361.      * array('attributename' => 'single value',
  362.      *       'attributename' => array('value1', 'value2))
  363.      * When the attribute already exists the values will be added, else the
  364.      * attribute will be created. These changes are local to the entry and do
  365.      * not affect the entry on the server until update() is called.
  366.      *
  367.      * Note, that you can add values of attributes that you haven't selected, but if
  368.      * you do so, {@link getValue()} and {@link getValues()} will only return the
  369.      * values you added, _NOT_ all values present on the server. To avoid this, just refetch
  370.      * the entry after calling {@link update()} or select the attribute.
  371.      *
  372.      * @access public
  373.      * @param array $attr 
  374.      */
  375.     function add($attr = array())
  376.     {
  377.         if (false == is_array($attr)) {
  378.             return PEAR::raiseError("Parameter must be an array");
  379.         }
  380.         foreach ($attr as $k => $v{
  381.             $k $this->_getAttrName($k);
  382.             if (false == is_array($v)) {
  383.                 // Do not add empty values
  384.                 if ($v == null{
  385.                     continue;
  386.                 else {
  387.                     $v = array($v);
  388.                 }
  389.             }
  390.             // add new values to existing attribute
  391.             if ($this->exists($k)) {
  392.                 $this->_attributes[$karray_merge($this->_attributes[$k]$v);
  393.             else {
  394.                 $this->_map[strtolower($k)$k;
  395.                 $this->_attributes[$k$v;
  396.             }
  397.             // save changes for update()
  398.             if (empty($this->_changes["add"][$k])) {
  399.                 $this->_changes["add"][$k= array();
  400.             }
  401.             $this->_changes["add"][$karray_merge($this->_changes["add"][$k]$v);
  402.         }
  403.     }
  404.  
  405.     /**
  406.      * Deletes an attribute or a value
  407.      *
  408.      * The parameter can be one of the following:
  409.      *
  410.      * "attributename" - The attribute as a whole will be deleted
  411.      * array("attributename1", "attributename2) - All given attributes will be
  412.      *                                            deleted
  413.      * array("attributename" => "value") - The value will be deleted
  414.      * array("attributename" => array("value1", "value2") - The given values
  415.      *                                                      will be deleted
  416.      * If $attr is null or omitted , then the whole Entry will be deleted!
  417.      *
  418.      * These changes are local to the entry and do
  419.      * not affect the entry on the server until {@link update()} is called.
  420.      *
  421.      * Please note that you must select the attribute (at $ldap->search() for example)
  422.      * to be able to delete values of it, Otherwise {@link update()} will silently fail
  423.      * and remove nothing.
  424.      *
  425.      * @access public
  426.      * @param string|array$attr 
  427.      */
  428.     function delete($attr = null)
  429.     {
  430.         if (is_null($attr)) {
  431.             $this->_delete = true;
  432.             return;
  433.         }
  434.         if (is_string($attr)) {
  435.             $attr = array($attr);
  436.         }
  437.         // Make the assumption that attribute names cannot be numeric,
  438.         // therefore this has to be a simple list of attribute names to delete
  439.         if (is_numeric(key($attr))) {
  440.             foreach ($attr as $name{
  441.                 $name $this->_getAttrName($name);
  442.                 if ($this->exists($name)) {
  443.                     $this->_changes["delete"][$name= null;
  444.                     unset($this->_attributes[$name]);
  445.                 }
  446.             }
  447.         else {
  448.             // Here we have a hash with "attributename" => "value to delete"
  449.             foreach ($attr as $name => $values{
  450.                 // get the correct attribute name
  451.                 $name $this->_getAttrName($name);
  452.                 if ($this->exists($name)) {
  453.                     if (false == is_array($values)) {
  454.                         $values = array($values);
  455.                     }
  456.                     // save values to be deleted
  457.                     if (empty($this->_changes["delete"][$name])) {
  458.                         $this->_changes["delete"][$name= array();
  459.                     }
  460.                     $this->_changes["delete"][$name=
  461.                         array_merge($this->_changes["delete"][$name]$values);
  462.                     foreach ($values as $value{
  463.                         // find the key for the value that should be deleted
  464.                         $key array_search($value$this->_attributes[$name]);
  465.                         if (false !== $key{
  466.                             // delete the value
  467.                             unset($this->_attributes[$name][$key]);
  468.                         }
  469.                     }
  470.                 }
  471.             }
  472.         }
  473.     }
  474.  
  475.     /**
  476.      * Replaces attributes or its values
  477.      *
  478.      * The parameter has to an array of the following form:
  479.      * array("attributename" => "single value",
  480.      *       "attribute2name" => array("value1", "value2"))
  481.      * If the attribute does not yet exist it will be added instead.
  482.      * If the attribue value is null, the attribute will de deleted
  483.      *
  484.      * These changes are local to the entry and do
  485.      * not affect the entry on the server until {@link update()} is called.
  486.      *
  487.      * @access public
  488.      * @param array $attr 
  489.      */
  490.     function replace($attr = array())
  491.     {
  492.         if (false == is_array($attr)) {
  493.             return PEAR::raiseError("Parameter must be an array");
  494.         }
  495.         foreach ($attr as $k => $v{
  496.             $k $this->_getAttrName($k);
  497.             if (false == is_array($v)) {
  498.                 // delete attributes with empty values
  499.                 if ($v == null{
  500.                     $this->delete($k);
  501.                     continue;
  502.                 else {
  503.                     $v = array($v);
  504.                 }
  505.             }
  506.             // existing attributes will get replaced
  507.             if ($this->exists($k)) {
  508.                 $this->_changes["replace"][$k$v;
  509.                 $this->_attributes[$k$v;
  510.             else {
  511.                 // new ones just get added
  512.                 $this->add(array($k => $v));
  513.             }
  514.         }
  515.     }
  516.  
  517.     /**
  518.      * Update the entry on the directory server
  519.      *
  520.      * @access public
  521.      * @param Net_LDAP $ldap (optional) If you provide a Net_LDAP object, be sure to PASS IT VIA REFERENCE!
  522.      * @return mixed 
  523.      */
  524.     function update($ldap=false)
  525.     {
  526.         if (!$ldap{  // If object is not provided, then use this entrys ldap object
  527.             $ldap =$this->_ldap;
  528.         else {
  529.             if (!is_a($ldap'Net_LDAP')) {
  530.                 return PEAR::raiseError("Need a Net_LDAP object as parameter");
  531.             }
  532.         }
  533.  
  534.         $link $ldap->getLink();
  535.  
  536.         // Delete the entry
  537.         if ($this->_delete === true{
  538.             return $ldap->delete($this);
  539.         }
  540.         // New entry
  541.         if ($this->_new === true{
  542.             $msg $ldap->add($this);
  543.             if (Net_LDAP::isError($msg)) {
  544.                 return $msg;
  545.             }
  546.             $this->_new = false;
  547.             $this->_changes['add'= array();
  548.             $this->_changes['delete'= array();
  549.             $this->_changes['replace'= array();
  550.             $this->_original $this->_attributes;
  551.             return;
  552.         }
  553.         // Rename/move entry
  554.         if (false == is_null($this->_newdn)) {
  555.             if ($ldap->getLDAPVersion(!== 3{
  556.                 return PEAR::raiseError("Renaming/Moving an entry is only supported in LDAPv3");
  557.             }
  558.             // make dn relative to parent (needed for ldap rename)
  559.             $parent $this->ldap_explode_dn_escaped($this->_newdn0);
  560.             $child array_shift($parent);
  561.             $parent join(","$parent);
  562.             // rename
  563.             if (false == @ldap_rename($link$this->_dn$child$parenttrue)) {
  564.                 return PEAR::raiseError("Entry not renamed: " .
  565.                                         @ldap_error($link)@ldap_errno($link));
  566.             }
  567.             // reflect changes to local copy
  568.             $this->_dn $this->_newdn;
  569.             $this->_newdn = null;
  570.         }
  571.         // Modified entry
  572.         foreach ($this->_changes["add"as $attr => $value{
  573.             // if attribute exists, add new values
  574.             if ($this->exists($attr)) {
  575.                 if (false === @ldap_mod_add($link$this->dn()array($attr => $value))) {
  576.                     return PEAR::raiseError("Could not add new values to attribute $attr" .
  577.                                             @ldap_error($link)@ldap_errno($link));
  578.                 }
  579.             else {
  580.                 // new attribute
  581.                 if (false === @ldap_modify($link$this->dn()array($attr => $value))) {
  582.                     return PEAR::raiseError("Could not add new attribute $attr" .
  583.                                             @ldap_error($link)@ldap_errno($link));
  584.                 }
  585.             }
  586.             // all went well here, I guess
  587.             unset($this->_changes["add"][$attr]);
  588.         // add
  589.  
  590.         foreach ($this->_changes["delete"as $attr => $value{
  591.             // In LDAPv3 you need to specify the old values for deleting
  592.             if (is_null($value&& $ldap->getLDAPVersion(=== 3{
  593.                 $value $this->_original[$attr];
  594.             }
  595.             if (false === @ldap_mod_del($link$this->dn()array($attr => $value))) {
  596.                 return PEAR::raiseError("Could not delete attribute $attr" .
  597.                                         @ldap_error($link)@ldap_errno($link));
  598.             }
  599.             unset($this->_changes["delete"][$attr]);
  600.         // delete
  601.  
  602.         foreach ($this->_changes["replace"as $attr => $value{
  603.             if (false === @ldap_modify($link$this->dn()array($attr => $value))) {
  604.                 return PEAR::raiseError("Could not replace attribute $attr values: " .
  605.                                         @ldap_error($link)@ldap_errno($link));
  606.             }
  607.             unset($this->_changes["replace"][$attr]);
  608.         // replace
  609.  
  610.         // all went well, so _original (server) becomes _attributes (local copy)
  611.         $this->_original $this->_attributes;
  612.     }
  613.  
  614.     /**
  615.      * Returns the right attribute name
  616.      *
  617.      * @access private
  618.      * @param string $attr Name of attribute
  619.      * @return string The right name of the attribute
  620.      */
  621.     function _getAttrName($attr)
  622.     {
  623.         $name strtolower($attr);
  624.         if (array_key_exists($name$this->_map)) {
  625.             $attr $this->_map[$name];
  626.         }
  627.         return $attr;
  628.     }
  629.  
  630.     /**
  631.      * Copy the current entry to another place in the directory
  632.      *
  633.      * @access public
  634.      * @param Net_LDAP $ldap       Net_LDAP
  635.      * @param string   $dn         New distinguished name
  636.      * @param boolean  $relative   Is the new name relative to current parent
  637.      * @return Net_LDAP_Entry|Net_LDAP_Error  Reference to the copied Net_LDAP_Entry or Net_LDAP_Error
  638.      */
  639.     function &copy(&$ldap$dn$relative = false)
  640.     {
  641.         if ($relative == true{
  642.             $dn = "$dn," . $this->dn();
  643.         }
  644.         // get the attribute which makes up the rdn
  645.         $parts @ldap_explode_dn($this->dn()0);
  646.         list($attr$valueexplode('='$parts[0]);
  647.  
  648.         // remove it from the entry (not valid in copy)
  649.         $old_e $this// backup
  650.         $old_e->delete(array($attr => $value));
  651.  
  652.         // get the attribute which makes up the new rdn
  653.         $parts @ldap_explode_dn($dn0);
  654.         list($attr$valueexplode('='$parts[0]);
  655.  
  656.         $old_e->add(array($attr => $value));
  657.  
  658.         $entry = new Net_LDAP_Entry(null$dn);
  659.  
  660.         $entry->add($old_e->getValues());
  661.         $msg $entry->update($ldap);
  662.         if (Net_LDAP::isError($msg)) {
  663.             return $msg;
  664.         }
  665.         return $entry;
  666.     }
  667.  
  668.     /**
  669.      * Returns a reference to the LDAP-Object of this entry
  670.      *
  671.      * @access public
  672.      * @return Net_LDAP|Net_LDAP_Error  Reference to the Net_LDAP Object (the connection) or Net_LDAP_Error
  673.      */
  674.     function &getLDAP()
  675.     {
  676.         if (!is_a($this->_ldap'Net_LDAP')) {
  677.             return PEAR::raiseError("LDAP is not a valid Net_LDAP object");
  678.         else {
  679.             return $this->_ldap;
  680.         }
  681.     }
  682.  
  683.     /**
  684.      * Wrapper function for PHPs ldap_explode_dn()
  685.      *
  686.      * PHPs ldap_explode_dn() does not escape DNs so it will fail
  687.      * if the parameter $dn is something like <kbd>"<foobar>"</kbd> or contains
  688.      * Umlauts.
  689.      * This method ensures, that the DN is properly escaped and encoded.
  690.      *
  691.      * It is taken from http://php.net/ldap_explode_dn and slightly modified.
  692.      *
  693.      * @author DavidSmith@byu.net
  694.      * @param string $dn    The DN that should be split
  695.      * @param string $only 
  696.      * @static
  697.      */
  698.     function ldap_explode_dn_escaped($dn$only_values=0)
  699.     {
  700.         $dn addcslashes$dn"<>" );
  701.         $result = ldap_explode_dn$dn$only_values );
  702.         if (isset($result["count"])) {
  703.             unset($result["count"]);
  704.         }
  705.         //translate hex code into ascii again
  706.         foreach$result as $key => $value )
  707.             $result[$keypreg_replace("/\\\([0-9A-Fa-f]{2})/e""''.chr(hexdec('\\1')).''"$value);
  708.         return $result;
  709.      }
  710. }
  711. ?>

Documentation generated on Mon, 11 Mar 2019 14:56:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.