FusionDirectory
 All Data Structures Files Functions Variables
Public Member Functions | Static Public Member Functions | Protected Member Functions
LDAP Class Reference

This class contains all ldap function needed to make ldap operations easy. More...

Public Member Functions

 __construct ($binddn, $bindpw, $hostname, $follow_referral=FALSE, $tls=FALSE)
 Create a LDAP connection. More...
 
 getSearchResource ()
 Get the search ressource. More...
 
 connect ()
 Create a connection to LDAP server. More...
 
 rebind ($ldap, $referral)
 Rebind.
 
 reconnect ()
 Reconnect to LDAP server.
 
 unbind ()
 Unbind to LDAP server.
 
 disconnect ()
 Disconnect to LDAP server.
 
 cd ($dir)
 Change directory. More...
 
 getParentDir ($basedn= '')
 Accessor of the parent directory of the basedn. More...
 
 search ($srp, $filter, $attrs=array(), $scope= 'subtree')
 Search about filter. More...
 
 object_match_filter ($dn, $filter)
 Search object from a filter. More...
 
 set_size_limit ($size)
 Set a size limit. More...
 
 fetch ($srp)
 Fetch. More...
 
 resetResult ($srp)
 Reset the result. More...
 
 clearResult ($srp)
 Clear a result. More...
 
 getDN ($srp)
 Accessor of the DN. More...
 
 count ($srp)
 Return the numbers of entries. More...
 
 rm ($attrs="", $dn="")
 Remove. More...
 
 rmdir ($deletedn)
 Remove directory. More...
 
 rename_dn ($source, $dest)
 Move the given Ldap entry from $source to $dest. More...
 
 rmdir_recursive ($srp, $deletedn)
 Function rmdir_recursive. More...
 
 modify ($attrs)
 Modify a entry of the directory LDAP. More...
 
 add ($attrs)
 Add entry in the LDAP directory. More...
 
 get_attribute ($dn, $name, $r_array=0)
 Read a entry from a directory. More...
 
 get_additional_error ()
 Get the LDAP additional error. More...
 
 success ()
 Success. More...
 
 get_error ()
 Get the error.
 
 generateLdif ($dn, $filter="(objectClass=*)", $scope= 'sub', $limit=0)
 Generates an ldif for all entries matching the filter settings, scope and limit. More...
 
 import_complete_ldif ($srp, $str_attr, $JustModify, $DeleteOldEntries)
 Function to imports ldifs. More...
 
 get_objectclasses ($force_reload=FALSE)
 Get the object classes. More...
 
 log ($string)
 Add a string in log file. More...
 
 getCn ($dn)
 Function to get cn. More...
 

Static Public Member Functions

static prepare4filter ($dn)
 Function to fix problematic characters in DN's that are used for search requests. I.e. member=.... More...
 

Protected Member Functions

 import_single_entry ($srp, $data, $modify, $delete)
 Function to Imports a single entry. More...
 

Detailed Description

This class contains all ldap function needed to make ldap operations easy.

Definition at line 34 of file class_ldap.inc.

Constructor & Destructor Documentation

__construct (   $binddn,
  $bindpw,
  $hostname,
  $follow_referral = FALSE,
  $tls = FALSE 
)

Create a LDAP connection.

Parameters
string$binddnBind of the DN
string$bindpwBind
string$hostnameThe hostname
boolean$follow_referralFALSE
boolean$tlsFALSE

Definition at line 82 of file class_ldap.inc.

References connect().

Member Function Documentation

add (   $attrs)

Add entry in the LDAP directory.

Parameters
string$attrsThe entry to add

Definition at line 705 of file class_ldap.inc.

References connect(), reconnect(), and success().

Referenced by import_single_entry().

cd (   $dir)

Change directory.

Parameters
string$dirThe new directory

Definition at line 213 of file class_ldap.inc.

References getParentDir().

Referenced by import_single_entry(), and rmdir_recursive().

clearResult (   $srp)

Clear a result.

Parameters
integer$srpThe result to clear

Definition at line 428 of file class_ldap.inc.

Referenced by search().

connect ( )

Create a connection to LDAP server.

The string $error containts result of the connection

Definition at line 129 of file class_ldap.inc.

References reconnect().

Referenced by __construct(), add(), get_attribute(), import_complete_ldif(), import_single_entry(), modify(), object_match_filter(), rename_dn(), rm(), rmdir(), rmdir_recursive(), and search().

count (   $srp)

Return the numbers of entries.

Parameters
$srpsrp

Definition at line 468 of file class_ldap.inc.

Referenced by import_complete_ldif(), import_single_entry(), and modify().

fetch (   $srp)

Fetch.

Parameters
integer$srp

Definition at line 379 of file class_ldap.inc.

Referenced by import_single_entry(), and rmdir_recursive().

generateLdif (   $dn,
  $filter = "(objectClass=*)",
  $scope = 'sub',
  $limit = 0 
)

Generates an ldif for all entries matching the filter settings, scope and limit.

Parameters
$dnThe entry to export.
$filterLimit the exported object to those maching this filter.
array$attributesAttributes
$scope'base', 'sub' .. see manpage for 'ldapmodify' for details.
$limitLimits the result.

Definition at line 964 of file class_ldap.inc.

get_additional_error ( )

Get the LDAP additional error.

Returns
string $error containts LDAP_OPT_ERROR_STRING

Definition at line 895 of file class_ldap.inc.

Referenced by get_error().

get_attribute (   $dn,
  $name,
  $r_array = 0 
)

Read a entry from a directory.

Parameters
string$dnThe DN
string$nameThe name of the entry
integer$r_arrayInitialized at 0

Definition at line 865 of file class_ldap.inc.

References connect(), and reconnect().

get_objectclasses (   $force_reload = FALSE)

Get the object classes.

Parameters
boolean$force_reloadFALSE

Definition at line 1222 of file class_ldap.inc.

References class_available(), session\global_get(), session\global_is_set(), and session\global_set().

getCn (   $dn)

Function to get cn.

Parameters
$dnThe DN

Definition at line 1350 of file class_ldap.inc.

getDN (   $srp)

Accessor of the DN.

Parameters
$srpsrp

Definition at line 441 of file class_ldap.inc.

getParentDir (   $basedn = '')

Accessor of the parent directory of the basedn.

Parameters
string$basednThe basedn which we want the parent directory
Returns
String, the parent directory

Definition at line 229 of file class_ldap.inc.

Referenced by cd().

getSearchResource ( )

Get the search ressource.

Returns
increase srp

Definition at line 105 of file class_ldap.inc.

import_complete_ldif (   $srp,
  $str_attr,
  $JustModify,
  $DeleteOldEntries 
)

Function to imports ldifs.

If DeleteOldEntries is TRUE, the destination entry will be deleted first. If JustModify is TRUE the destination entry will only be touched by the attributes specified in the ldif. if JustMofify is FALSE the destination dn will be overwritten by the new ldif.

Parameters
integer$srp
string$str_attr
string$error
boolean$JustModify
boolean$DeleteOldEntries

Definition at line 1042 of file class_ldap.inc.

References connect(), count(), import_single_entry(), and reconnect().

import_single_entry (   $srp,
  $data,
  $modify,
  $delete 
)
protected

Function to Imports a single entry.

If $delete is TRUE; The old entry will be deleted if it exists. if $modify is TRUE; All variables that are not touched by the new ldif will be kept. if $modify is FALSE; The new ldif overwrites the old entry, and all untouched attributes get lost.

Parameters
integer$srp
array$data
boolean$modify
boolean$delete

Definition at line 1145 of file class_ldap.inc.

References add(), cd(), connect(), count(), msg_dialog\display(), fetch(), get_error(), msgPool\ldaperror(), modify(), reconnect(), rmdir_recursive(), and success().

Referenced by import_complete_ldif().

log (   $string)

Add a string in log file.

Parameters
striif(ng $string

Definition at line 1333 of file class_ldap.inc.

References session\global_get(), and session\global_is_set().

Referenced by search().

modify (   $attrs)

Modify a entry of the directory LDAP.

Parameters
string$attrsThe new entry

Definition at line 679 of file class_ldap.inc.

References connect(), count(), reconnect(), and success().

Referenced by import_single_entry().

object_match_filter (   $dn,
  $filter 
)

Search object from a filter.

Parameters
string$dnThe DN
string$filterThe filter of the research

Definition at line 341 of file class_ldap.inc.

References connect(), and reconnect().

static prepare4filter (   $dn)
static

Function to fix problematic characters in DN's that are used for search requests. I.e. member=....

Parameters
string$dnThe DN

Definition at line 118 of file class_ldap.inc.

rename_dn (   $source,
  $dest 
)

Move the given Ldap entry from $source to $dest.

Parameters
String$sourceThe source dn.
String$destThe destination dn.
Returns
Boolean TRUE on success else FALSE.

Definition at line 561 of file class_ldap.inc.

References connect(), and reconnect().

resetResult (   $srp)

Reset the result.

Parameters
integer$srpValue to be reset

Definition at line 418 of file class_ldap.inc.

Referenced by search().

rm (   $attrs = "",
  $dn = "" 
)

Remove.

Parameters
string$attrsEmpty string
string$dnEmpty string

Definition at line 493 of file class_ldap.inc.

References connect(), and reconnect().

rmdir (   $deletedn)

Remove directory.

Parameters
string$deletednThe DN to be deleted

Definition at line 536 of file class_ldap.inc.

References connect(), and reconnect().

rmdir_recursive (   $srp,
  $deletedn 
)

Function rmdir_recursive.

Based on recursive_remove, adding two thing: full subtree remove, and delete own node.

Parameters
$srpsrp
string$deletednThe dn to delete
Returns
TRUE on sucessfull , 0 in error, and "" when we don't get a ldap conection

Definition at line 615 of file class_ldap.inc.

References cd(), connect(), fetch(), reconnect(), and search().

Referenced by import_single_entry().

search (   $srp,
  $filter,
  $attrs = array(),
  $scope = 'subtree' 
)

Search about filter.

Parameters
integer$srpsrp
string$filterThe filter
array$attrs

Definition at line 246 of file class_ldap.inc.

References clearResult(), connect(), msg_dialog\display(), log(), reconnect(), and resetResult().

Referenced by rmdir_recursive().

set_size_limit (   $size)

Set a size limit.

Parameters
$sizeThe limit

Definition at line 361 of file class_ldap.inc.

success ( )

Success.

Returns
boolean TRUE if Success is found in $error, else return FALSE

Definition at line 907 of file class_ldap.inc.

Referenced by add(), import_single_entry(), and modify().


The documentation for this class was generated from the following file: