Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: ../general-devel/lib/support/ldap/ldap.class.php
phpGeneral - support

Ldap

Ldap

Base class for ldap api

 

private class Ldap extends Locale

Base class for ldap api
Includes various function implementations to access the standard ldap apicalls for managing ldap trees. They all accept a distinguish name (dn) ofthe object which should be manipulated. A dn is the ldap representation of apath and consists of comma seperated parts. These parts are key/value pairsseperated by an equal sign and specify the type and the name of this part.An example dn would be "cn=newobj,ou=mynode,dc=example,dc=com".

AuthorsNorbert Sendetzky <norbert@linuxnetworks.de>

 
Direct known subclasses: OpenLdap

Public Method Summary

boolean

addObject(string $dn, array $entry, string &$errmsg)

Adds new object to the ldap tree
boolean

deleteObject(string $dn, string &$errmsg)

Removes an object from the ldap tree
boolean

modifyObject(string $dn, array $entry, string &$errmsg)

Modifies an object in the ldap tree
boolean

renameObject(string $dn, string $newrdn, string $newparent, boolean $delete, string &$errmsg)

Renames or moves an object in the ldap tree
boolean

searchSubLevel(string $basedn, string $filter, string $attr, array &$result, string &$errmsg)

Searches for objects in the subtree below the given node
boolean

searchOneLevel(string $basedn, string $filter, string $attr, array &$result, string &$errmsg)

Searches for objects in the tree only one level below the given node
boolean

searchBaseLevel(string $basedn, string $filter, string $attr, array &$result, string &$errmsg)

Compares the criterias with the attributes of the given node
boolean

addAttributes(string $dn, string $entry, string &$errmsg)

Adds new attributes to an existing object
boolean

deleteAttributes(string $dn, string $entry, string &$errmsg)

Deletes attributes in an existing object
boolean

replaceAttributes(string $dn, string $entry, string &$errmsg)

Replaces attributes in an existing object
boolean

dn2ufn(string $dn, string &$result, string &$errmsg)

Translates a dn to a user friendly name string

Private Method Summary

object Ldap

Ldap(array $param, string &$errmsg)

Class constructor
void

_Ldap()

Class destructor
array

pCleanArray(array $array)

Removes unnecessary elements of the resulting array
array

pCleanObject(array $array)

Removes unnecessary elements of the resulting objects

Private Field Summary

integer

$id

Included files Summary, Type: include_once

../lib/include/locale.class.php Warning: documentation is missing.

Public Method Details

addObject

public boolean addObject( string $dn, array $entry, string &$errmsg )

  Adds new object to the ldap tree
A new object and its attributes are added to the location where $dnpoints to. All attributes which should belong to this object are storedin $entry, which is an associative array and contains subarrays with oneor more values.

Parameter
string $dn
Distinguish name (name and path) of the new object
array $entry
The associative array contains the attributes of this object
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


deleteObject

public boolean deleteObject( string $dn, string &$errmsg )

  Removes an object from the ldap tree
The dn string of the object which should be deleted is required toremove the object. It is not possible to delete all children by removingthe parent object. Prior to LDAPv3 this fails and an error is returned,but since then behaviour has changed. Now it is possible to delete theparent without the need to remove the children first, but then thesechildren are not deleted and are accessible as before.

Parameter
string $dn
Distinguish name (name and path) of the object
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


modifyObject

public boolean modifyObject( string $dn, array $entry, string &$errmsg )

  Modifies an object in the ldap tree
Add new attributes to the object where $dn points to. The attributes arestored in $entry, which is an associative array and contains subarrayswith one or more values.

Parameter
string $dn
Distinguish name (name and path) of the object
array $entry
The associative array contains the new attributes for this object
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


renameObject

public boolean renameObject( string $dn, string $newrdn, string $newparent, boolean $delete, string &$errmsg )

  Renames or moves an object in the ldap tree
If only $newrdn differs from the former name in $dn, then the object isrenamed to $newrdn. Otherwise the object is renamed and moved to thelocation specified by $newparent. If $delete ist set to false, the objectis only copied.

Parameter
string $dn
Distinguish name (name and path) of the object
string $newrdn
New name of the object, e.g. "cn=newname"
string $newparent
Dn of the new parent node
boolean $delete
Flag to indicate if the object should be moved or only be copied
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


searchSubLevel

public boolean searchSubLevel( string $basedn, string $filter, string $attr, array &$result, string &$errmsg )

  Searches for objects in the subtree below the given node
It compares each object which is located in the subtree below the basenode with the filter string in $filter. The content of the filter must bean ldap compatible expression and if $attr is set, then only theseattributes are returned.

Parameter
string $basedn
Distinguish name of the base node
string $filter
Ldap search filter, e.g. "(&(uid=t*)(sn=test))"
string $attr
Return only these attriutes
array &$result
Array of objects matching the criteria
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


searchOneLevel

public boolean searchOneLevel( string $basedn, string $filter, string $attr, array &$result, string &$errmsg )

  Searches for objects in the tree only one level below the given node
Unlike searchSubLevel(), this functions searches only for objectswhich are one level below the base node given by $basedn.The content of the filter must be an ldap compatible expression and if$attr is set, then only these attributes are returned.

Parameter
string $basedn
Distinguish name of the base node
string $filter
Ldap search filter, e.g. "(uid=test)"
string $attr
Return only these attriutes
array &$result
Array of objects matching the criteria
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


searchBaseLevel

public boolean searchBaseLevel( string $basedn, string $filter, string $attr, array &$result, string &$errmsg )

  Compares the criterias with the attributes of the given node
This function checks if the object given by $basedn matches the criteriasin $filter. The content of the filter must be an ldap compatibleexpression and if $attr is set, then only these attributes are returned.

Parameter
string $basedn
Distinguish name of the base node
string $filter
Ldap search filter, e.g. "(|(cn=test)(sn=test))"
string $attr
Return only these attriutes
array &$result
Array of objects matching the criteria
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


addAttributes

public boolean addAttributes( string $dn, string $entry, string &$errmsg )

  Adds new attributes to an existing object
The attribute arrays in $entry are added to an existing object specifiedby $dn.

Parameter
string $dn
Distinguish name of the object
string $entry
Associative array containing arrays of values
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


deleteAttributes

public boolean deleteAttributes( string $dn, string $entry, string &$errmsg )

  Deletes attributes in an existing object
The $entry array contains the name of the attributes, which should bedeleted from the object specified by $dn.

Parameter
string $dn
Distinguish name of the object
string $entry
Array containing the names of the attributes
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


replaceAttributes

public boolean replaceAttributes( string $dn, string $entry, string &$errmsg )

  Replaces attributes in an existing object
The attributes stored in the associative array $entry replace thecorresponding attributes in the object. If only new attribute valuesshould be added, then the old values of the object attribute must be partof the subarray of $entry. Furthermore new attributes are addadautomatically and existing attributes are only replaced if they differfrom the values of the $entry subarrays.

Parameter
string $dn
Distinguish name of the object
string $entry
Associative array containing arrays of new values
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


dn2ufn

public boolean dn2ufn( string $dn, string &$result, string &$errmsg )

  Translates a dn to a user friendly name string
Cuts the type and the equal sign of each dn part and returns a commaseperated string of the names, e.g. "cn=test,ou=mynode" is translated to"test,mynode".

Parameter
string $dn
Distinguish name of an object
string &$result
Reference for storing the resulting user friendly name
string &$errmsg
Reference for storing error messages in case of a failure
Returns boolean

True on success, false otherwise


Private Method Details

Ldap

private object Ldap Ldap( array $param, string &$errmsg )

  Class constructor
Initializes localization support for error messages and connects to astandard compliant ldap server. It also tries to authenticate the userby providing the given password to the server.

Parameter
array $param
Associative array contains userid, password, realm and others
string &$errmsg
Reference for storing error messages in case of a failure
Returns object Ldap


_Ldap

private void _Ldap( )

  Class destructor
Shut down the connections to the ldap server

Returns void


pCleanArray

private array pCleanArray( array $array )

  Removes unnecessary elements of the resulting array
The ldap search operations return result arrays with additional,unnecessary infomations like the "count" attribute. These attributesare deleted from the result array.

Parameter
array $array
Result array returned by one of the search functions
Returns array

Clean array without the unnecessary attributes


pCleanObject

private array pCleanObject( array $array )

  Removes unnecessary elements of the resulting objects
The ldap search operations return objects with additional,unnecessary infomations like the "count" attribute. These attributesare deleted from the attribute arrays.

Parameter
array $array
Result object array from pCleanArray()
Returns array

Clean object array without the unnecessary attributes


Private Field Details

$id

private integer $id

>><<



Included Files, Type: include_once

../lib/include/locale.class.php

include_once( ../lib/include/locale.class.php )




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta