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

Class: Net_LDAP_Entry

Source Location: /Net_LDAP-0.7.2/LDAP/Entry.php

Class Overview

PEAR
   |
   --Net_LDAP_Entry

Object representation of a directory entry


Author(s):

Version:

  • $Revision: 1.36 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 42]
Object representation of a directory entry

This class represents a directory entry. You can add, delete, replace attributes and their values, rename the entry, delete the entry.

  • Author: Tarjej Huse
  • Author: Jan Wagner <wagner@netsols.de>
  • Version: $Revision: 1.36 $


[ Top ]


Method Detail

Net_LDAP_Entry (Constructor)   [line 149]

none Net_LDAP_Entry( &$ldap, [string|ressource $entry = null], Net_LDAP|ressource|array $ldap)

Constructor

Constructor of the entry. Sets up the distinguished name and the entries attributes.

  • Access: protected

Parameters:

Net_LDAP|ressource|array   $ldap   —  Net_LDAP object, ldap-link ressource or array of attributes
string|ressource   $entry   —  Either a DN or a LDAP-Entry
   &$ldap   — 

[ Top ]

add   [line 377]

void add( [array $attr = array()])

Adds a new attribute or a new value to an existing attribute

The paramter has to be an array of the form: array('attributename' => 'single value', 'attributename' => array('value1', 'value2)) When the attribute already exists the values will be added, else the attribute will be created. These changes are local to the entry and do not affect the entry on the server until update() is called.

Note, that you can add values of attributes that you haven't selected, but if you do so, getValue() and getValues() will only return the values you added, _NOT_ all values present on the server. To avoid this, just refetch the entry after calling update() or select the attribute.

  • Access: public

Parameters:

array   $attr   — 

[ Top ]

attributes   [line 341]

array attributes( )

Returns an array of attributes names
  • Return: Array of attribute names
  • Access: public

[ Top ]

copy   [line 645]

Net_LDAP_Entry|Net_LDAP_Error &copy( &$ldap, string $dn, [boolean $relative = false], Net_LDAP $ldap)

Copy the current entry to another place in the directory
  • Return: Reference to the copied Net_LDAP_Entry or Net_LDAP_Error
  • Access: public

Parameters:

Net_LDAP   $ldap   —  Net_LDAP
string   $dn   —  New distinguished name
boolean   $relative   —  Is the new name relative to current parent
   &$ldap   — 

[ Top ]

delete   [line 430]

void delete( [string|array $attr = null])

Deletes an attribute or a value

The parameter can be one of the following:

"attributename" - The attribute as a whole will be deleted array("attributename1", "attributename2) - All given attributes will be deleted array("attributename" => "value") - The value will be deleted array("attributename" => array("value1", "value2") - The given values will be deleted If $attr is null or omitted , then the whole Entry will be deleted!

These changes are local to the entry and do not affect the entry on the server until update() is called.

Please note that you must select the attribute (at $ldap->search() for example) to be able to delete values of it, Otherwise update() will silently fail and remove nothing.

  • Access: public

Parameters:

string|array   $attr   — 

[ Top ]

dn   [line 189]

string|true dn( [string $dn = null])

Get or set the distinguished name of the entry

If called without an argument the current (or the new DN if set) DN gets returned. If you provide an DN, this entry is moved to the new location specified if a DN existed. If the DN was not set, the DN gets initialized. Call update() to actually create the new Entry in the directory.

Please note that special characters (eg german umlauts) should be encoded using utf8_encode().

  • Return: Distinguished name (or true if a new DN was provided)
  • Access: public

Parameters:

string   $dn   —  New distinguished name

[ Top ]

exists   [line 353]

boolean exists( string $attr)

Returns whether an attribute exists or not
  • Access: public

Parameters:

string   $attr   —  Attribute name

[ Top ]

getLDAP   [line 680]

Net_LDAP|Net_LDAP_Error &getLDAP( )

Returns a reference to the LDAP-Object of this entry
  • Return: Reference to the Net_LDAP Object (the connection) or Net_LDAP_Error
  • Access: public

[ Top ]

getValue   [line 307]

string|array|PEAR_Error getValue( string $attr, [string $option = null])

Get the value of a specific attribute

The first parameter is the name of the attribute The second parameter influences the way the value is returned: 'single': only the first value is returned as string 'all': all values including the value count are returned in an array 'default': in all other cases an attribute value with a single value is returned as string, if it has multiple values it is returned as an array (without value count)

  • Return: string, array or PEAR_Error
  • Access: public

Parameters:

string   $attr   —  Attribute name
string   $option   —  Option

[ Top ]

getValues   [line 281]

array getValues( )

Get the values of all attributes in a hash

The returned hash has the form array('attributename' => 'single value', 'attributename' => array('value1', value2', value3'))

  • Return: Hash of all attributes with their values
  • Access: public

[ Top ]

get_value   [line 329]

void get_value( )

Alias function of getValue for perl-ldap interface

[ Top ]

preg_match   [line 729]

boolean|Net_LDAP_Error preg_match( string $regex, string $attr_name, [array $matches = array()])

Applies a regular expression onto a single- or multivalued attribute (like preg_match())

This method behaves like PHPs preg_match() but with some exceptions. If you want to retrieve match information, then you MUST pass the $matches parameter via reference! otherwise you will get no matches. Since it is possible to have multi valued attributes the $matches array will have a additionally numerical dimension (one for each value):

  1.  $matches = array(
  2.          0 => array (usual preg_match(returnarray),
  3.          1 => array (usual preg_match(returnarray)
  4.      )
Please note, that $matches will be initialized to an empty array inside.

Usage example:

  1.  $result $entry->preg_match('/089(\d+)/''telephoneNumber'&$matches);
  2.  if $result === true ){
  3.      echo "First match: ".$matches[0][1];   // Match of value 1, content of first bracket
  4.  else {
  5.      if Net_LDAP::isError($result) ) {
  6.          echo "Error: ".$result->getMessage();
  7.      else {
  8.          echo "No match found.";
  9.      }
  10.  }

Please note that it is important to test for an Net_LDAP_Error, because objects are evaluating to true by default, thus if a error occured, and you only check using "==" then you get misleading results. Use the "identical" (===) operator to test for matches to avoid this as shown above.

  • Return: TRUE, if we had a match in one of the values, otherwise false. Net_LDAP_Error in case something went wrong

Parameters:

string   $regex   —  The regular expression
string   $attr_name   —  The attribute to search in
array   $matches   —  (optional, PASS BY REFERENCE!) Array to store matches in

[ Top ]

replace   [line 492]

void replace( [array $attr = array()])

Replaces attributes or its values

The parameter has to an array of the following form: array("attributename" => "single value", "attribute2name" => array("value1", "value2")) If the attribute does not yet exist it will be added instead. If the attribue value is null, the attribute will de deleted

These changes are local to the entry and do not affect the entry on the server until update() is called.

  • Access: public

Parameters:

array   $attr   — 

[ Top ]

update   [line 526]

mixed update( [Net_LDAP $ldap = false])

Update the entry on the directory server
  • Access: public

Parameters:

Net_LDAP   $ldap   —  (optional) If you provide a Net_LDAP object, be sure to PASS IT VIA REFERENCE!

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:01:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.