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

Class: Net_LDAP2_Entry

Source Location: /Net_LDAP2-2.0.0RC2/LDAP2/Entry.php

Class Overview

PEAR
   |
   --Net_LDAP2_Entry

Object representation of a directory entry


Author(s):

Version:

  • CVS: $Id: Entry.php,v 1.2 2008/03/20 09:32:39 beni Exp $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 22]
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.



[ Top ]


Class Variables

$_attributes = array()

[line 64]

Attributes
  • Access: protected

Type:   array


[ Top ]

$_changes = array("add"     => array(),"delete"=>array(),"replace"=>array())

[line 114]

Map with changes to the entry
  • Access: protected

Type:   array


[ Top ]

$_delete =  false

[line 106]

Shall the entry be deleted?
  • Access: protected

Type:   boolean


[ Top ]

$_dn =  null

[line 56]

Distinguished name of the entry
  • Access: protected

Type:   string


[ Top ]

$_entry =  null

[line 30]

Entry ressource identifier
  • Access: protected

Type:   ressource


[ Top ]

$_ldap =  null

[line 48]

Net_LDAP2 object

This object will be used for updating and schema checking

  • Access: protected

Type:   object Net_LDAP2


[ Top ]

$_link =  null

[line 38]

LDAP ressource identifier
  • Access: protected

Type:   ressource


[ Top ]

$_map = array()

[line 81]

Map of attribute names
  • Access: protected

Type:   array


[ Top ]

$_new =  true

[line 90]

Is this a new entry?
  • Access: protected

Type:   boolean


[ Top ]

$_newdn =  null

[line 98]

New distinguished name
  • Access: protected

Type:   string


[ Top ]

$_original = array()

[line 72]

Original attributes before any modification
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 132]

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

Internal Constructor

Constructor of the entry. Sets up the distinguished name and the entries attributes. You should not call this method manually! Use Net_LDAP2_Entry::createFresh() or Net_LDAP2_Entry::createConnected() instead!

  • Access: protected

Parameters:

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

[ Top ]

add   [line 460]

true|Net_LDAP2_Error 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   —  Attributes to add

[ Top ]

attributes   [line 421]

array attributes( )

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

[ Top ]

createConnected   [line 212]

Net_LDAP2_Entry|Net_LDAP2_Error createConnected( &$ldap, resource $entry, Net_LDAP2 $ldap)

Creates a Net_LDAP2_Entry object out of an ldap entry resource

Use this method, if you want to initialize a fresh entry.

The method should be called statically: $entry = Net_LDAP2_Entry::createConnected();

  • Access: public

Parameters:

Net_LDAP2   $ldap   —  Net_LDA2 object
resource   $entry   —  PHP LDAP entry resource
   &$ldap   — 

[ Top ]

createFresh   [line 189]

Net_LDAP2_Entry|Net_LDAP2_Error createFresh( string $dn, [array $attrs = array()])

Creates a fresh entry that may be added to the directory later on

Use this method, if you want to initialize a fresh entry.

The method should be called statically: $entry = Net_LDAP2_Entry::createFresh(); You should put a 'objectClass' attribute into the $attrs so the directory server knows which object you want to create. However, you may omit this in case you don't want to add this entry to a directory server.

The attributes parameter is as following:

  1.  $attrs = array'attribute1' => array('value1''value2'),
  2.                  'attribute2' => 'single value'
  3.           );

  • Access: public

Parameters:

string   $dn   —  DN of the Entry
array   $attrs   —  Attributes of the entry

[ Top ]

currentDN   [line 920]

string currentDN( )

Returns always the original DN

If an entry will be moved but update() was not called, dn() will return the new DN. This method however, returns always the current active DN.

  • Access: public

[ Top ]

delete   [line 517]

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

Deletes an whole attribute or a value or the whole entry

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   —  Attributes to delete (NULL or missing to delete whole entry)

[ Top ]

dn   [line 243]

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. To fetch the current active DN after setting a new DN but before an update(), you can use currentDN() to retrieve the DN that is currently active.

Please note that special characters (eg german umlauts) should be encoded using utf8_encode(). You may use Net_LDAP2_Util::canonical_dn() for properly encoding of the DN.

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

Parameters:

string   $dn   —  New distinguished name

[ Top ]

exists   [line 434]

boolean exists( string $attr)

Returns whether an attribute exists or not
  • Access: public

Parameters:

string   $attr   —  Attribute name

[ Top ]

getChanges   [line 930]

array getChanges( )

Returns the attribute changes to be carried out once update() is called
  • Access: public

[ Top ]

getLDAP   [line 778]

Net_LDAP2|Net_LDAP2_Error &getLDAP( )

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

[ Top ]

getValue   [line 386]

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 359]

array getValues( )

Get the values of all attributes in a hash

The returned hash has the form

  1. array('attributename' => 'single value',
  2.        'attributename' => array('value1'value2', value3'))

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

[ Top ]

get_value   [line 409]

string|array|PEAR_Error get_value( )

Alias function of getValue for perl-ldap interface

[ Top ]

markAsNew   [line 821]

void markAsNew( [boolean $mark = true])

Marks the entry as new/existing.

If an Entry is marked as new, it will be added to the directory when calling update(). If the entry is marked as old ($mark = false), then the entry is assumed to be present in the directory server wich results in modification when calling update().

  • Access: public

Parameters:

boolean   $mark   —  Value to set, defaults to "true"

[ Top ]

move   [line 265]

true move( string $newdn)

Renames or moves the entry

This is just a convinience alias to dn() to make your code more meaningful.

  • Access: public

Parameters:

string   $newdn   —  The new DN

[ Top ]

preg_match   [line 867]

boolean|Net_LDAP2_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_LDAP2::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_LDAP2_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_LDAP2_Error in case something went wrong
  • Access: public

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 594]

true|Net_LDAP2_Error 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   —  Attributes to replace

[ Top ]

setLDAP   [line 799]

true|Net_LDAP2_Error setLDAP( Net_LDAP2 &$ldap)

Sets a reference to the LDAP-Object of this entry

After setting a Net_LDAP2 object, calling update() will use that object for updating directory contents. Use this to dynamicly switch directorys.

  • Access: public

Parameters:

Net_LDAP2   &$ldap   —  Net_LDAP2 object that this entry should be connected to

[ Top ]

update   [line 632]

true|Net_LDAP2_Error update( [Net_LDAP2 $ldap = null])

Update the entry on the directory server
  • Todo: Entry rename with a DN containing special characters needs testing!
  • Access: public

Parameters:

Net_LDAP2   $ldap   —  If passed, a call to setLDAP() is issued prior update, thus switching the LDAP-server. This is for perl-ldap interface compliance

[ Top ]

willBeDeleted   [line 896]

boolean willBeDeleted( )

Is this entry going to be deleted once update() is called?
  • Access: public

[ Top ]

willBeMoved   [line 906]

boolean willBeMoved( )

Is this entry going to be moved once update() is called?
  • Access: public

[ Top ]

_getAttrName   [line 763]

string _getAttrName( string $attr)

Returns the right attribute name
  • Return: The right name of the attribute
  • Access: protected

Parameters:

string   $attr   —  Name of attribute

[ Top ]

_setAttributes   [line 285]

void _setAttributes( [array $attributes = null])

Sets the internal attributes array

This fetches the values for the attributes from the server. The attribute Syntax will be checked so binary attributes will be returned as binary values.

Attributes may be passed directly via the $attributes parameter to setup this entry manually. This overrides attribute fetching from the server.

  • Access: protected

Parameters:

array   $attributes   —  Attributes to set for this entry

[ Top ]


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