FusionDirectory
|
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... | |
__wakeup () | |
Remove bogus resources after unserialize. | |
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=[], $scope='subtree', array $controls=NULL) | |
Search about filter. More... | |
parse_result ($srp) | |
Parse last result. More... | |
object_match_filter ($dn, $filter) | |
Search object from a filter. More... | |
set_size_limit ($size) | |
Set a size limit. More... | |
fetch ($srp, bool $cleanUpNumericIndices=FALSE) | |
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 (array $attrs) | |
Modify a entry of the directory LDAP. More... | |
modify_batch (array $changes) | |
Modify a entry of the directory LDAP with fine control. More... | |
add ($attrs) | |
Add entry in the LDAP directory. More... | |
get_additional_error () | |
Get the LDAP additional error. More... | |
success () | |
Success. More... | |
get_error ($details=TRUE) | |
Get the error. | |
get_errno () | |
Get the errno. More... | |
hitSizeLimit () | |
Check if the search hit the size limit. More... | |
generateLdif (string $dn, string $filter='(objectClass=*)', string $scope='sub', int $limit=0, int $wrap=NULL) | |
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 | init (string $server, string $base, string $binddn='', string $pass='') |
Initialize a LDAP connection. More... | |
static | prepare4filter ($dn) |
Function to fix problematic characters in DN's that are used for search requests. I.e. member=.... More... | |
static | invalidCredentialsError () |
Error text that must be returned for invalid user or password. More... | |
Protected Member Functions | |
import_single_entry ($srp, $data, $modify, $delete) | |
Function to Imports a single entry. More... | |
This class contains all ldap function needed to make ldap operations easy.
Definition at line 34 of file class_ldap.inc.
__construct | ( | $binddn, | |
$bindpw, | |||
$hostname, | |||
$follow_referral = FALSE , |
|||
$tls = FALSE |
|||
) |
Create a LDAP connection.
string | $binddn | Bind of the DN |
string | $bindpw | Bind |
string | $hostname | The hostname |
boolean | $follow_referral | FALSE |
boolean | $tls | FALSE |
Definition at line 86 of file class_ldap.inc.
References connect().
add | ( | $attrs | ) |
Add entry in the LDAP directory.
string | $attrs | The entry to add |
Definition at line 892 of file class_ldap.inc.
References connect(), logging\debug(), DEBUG_LDAP, reconnect(), and success().
cd | ( | $dir | ) |
Change directory.
string | $dir | The new directory |
Definition at line 315 of file class_ldap.inc.
References getParentDir().
Referenced by import_single_entry(), parse_result(), and rmdir_recursive().
clearResult | ( | $srp | ) |
Clear a result.
integer | $srp | The result to clear |
Definition at line 576 of file class_ldap.inc.
Referenced by parse_result(), and search().
connect | ( | ) |
Create a connection to LDAP server.
The string $error containts result of the connection
Definition at line 184 of file class_ldap.inc.
References class_available(), logging\debug(), DEBUG_LDAP, and reconnect().
Referenced by __construct(), add(), import_complete_ldif(), import_single_entry(), modify(), modify_batch(), object_match_filter(), parse_result(), rename_dn(), rm(), rmdir(), rmdir_recursive(), and search().
count | ( | $srp | ) |
Return the numbers of entries.
$srp | srp |
Definition at line 616 of file class_ldap.inc.
References logging\debug(), and DEBUG_LDAP.
Referenced by import_complete_ldif(), modify(), and modify_batch().
fetch | ( | $srp, | |
bool | $cleanUpNumericIndices = FALSE |
||
) |
Fetch.
integer | $srp | |
bool | $cleanUpNumericIndices | whether to remove numeric indices and "count" index at top level ("count" index in each attribute value is kept) |
Definition at line 520 of file class_ldap.inc.
References logging\debug(), and DEBUG_LDAP.
Referenced by rmdir_recursive().
generateLdif | ( | string | $dn, |
string | $filter = '(objectClass=*)' , |
||
string | $scope = 'sub' , |
||
int | $limit = 0 , |
||
int | $wrap = NULL |
||
) |
Generates an ldif for all entries matching the filter settings, scope and limit.
string | $dn | The entry to export. |
string | $filter | Limit the exported object to those maching this filter. |
string | $scope | 'base', 'sub' .. see manpage for 'ldapmodify' for details. |
int | $limit | Limits the result. |
?int | $wrap Wraps line around this length (0 to disable). |
Definition at line 1148 of file class_ldap.inc.
References logging\debug(), and DEBUG_LDAP.
get_additional_error | ( | ) |
Get the LDAP additional error.
Definition at line 1049 of file class_ldap.inc.
Referenced by get_error(), and rmdir_recursive().
get_errno | ( | ) |
Get the errno.
Must be run right after the ldap request
Definition at line 1094 of file class_ldap.inc.
Referenced by hitSizeLimit().
get_objectclasses | ( | $force_reload = FALSE | ) |
Get the object classes.
boolean | $force_reload | FALSE |
Definition at line 1419 of file class_ldap.inc.
References class_available(), session\get(), session\is_set(), and session\set().
getCn | ( | $dn | ) |
Function to get cn.
$dn | The DN |
Definition at line 1544 of file class_ldap.inc.
References logging\debug(), and DEBUG_LDAP.
getDN | ( | $srp | ) |
getParentDir | ( | $basedn = '' | ) |
Accessor of the parent directory of the basedn.
string | $basedn | The basedn which we want the parent directory |
Definition at line 331 of file class_ldap.inc.
Referenced by cd().
getSearchResource | ( | ) |
hitSizeLimit | ( | ) |
Check if the search hit the size limit.
Must be run right after the search
Definition at line 1108 of file class_ldap.inc.
References get_errno().
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.
integer | $srp | |
string | $str_attr | |
boolean | $JustModify | |
boolean | $DeleteOldEntries |
Definition at line 1295 of file class_ldap.inc.
References connect(), count(), import_single_entry(), and reconnect().
|
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.
integer | $srp | |
array | $data | |
boolean | $modify | |
boolean | $delete |
Definition at line 1332 of file class_ldap.inc.
References cd(), connect(), reconnect(), and rmdir_recursive().
Referenced by import_complete_ldif().
|
static |
Initialize a LDAP connection.
Initializes a LDAP connection.
string | $server | The server we are connecting to |
string | $base | The base of our ldap tree |
string | $binddn | Default: empty |
string | $pass | Default: empty |
Definition at line 127 of file class_ldap.inc.
References htmlescape().
Referenced by config\get_ldap_link().
|
static |
Error text that must be returned for invalid user or password.
This is useful to make sure the same error text is shown whether a user exists or not, when the password is not correct.
Definition at line 174 of file class_ldap.inc.
Referenced by userinfo\loginUser().
log | ( | $string | ) |
Add a string in log file.
string | $string |
Definition at line 1527 of file class_ldap.inc.
References session\get(), and session\is_set().
Referenced by search().
modify | ( | array | $attrs | ) |
Modify a entry of the directory LDAP.
array | $attrs | The new entry |
Definition at line 839 of file class_ldap.inc.
References connect(), count(), logging\debug(), DEBUG_LDAP, reconnect(), and success().
modify_batch | ( | array | $changes | ) |
Modify a entry of the directory LDAP with fine control.
array | $changes | The changes |
Definition at line 867 of file class_ldap.inc.
References connect(), count(), logging\debug(), DEBUG_LDAP, and reconnect().
object_match_filter | ( | $dn, | |
$filter | |||
) |
Search object from a filter.
string | $dn | The DN |
string | $filter | The filter of the research |
Definition at line 479 of file class_ldap.inc.
References connect(), logging\debug(), DEBUG_LDAP, and reconnect().
parse_result | ( | $srp | ) |
Parse last result.
integer | $srp | srp |
Definition at line 410 of file class_ldap.inc.
References cd(), clearResult(), connect(), logging\debug(), DEBUG_LDAP, reconnect(), resetResult(), and search().
|
static |
Function to fix problematic characters in DN's that are used for search requests. I.e. member=....
string | $dn | The DN |
Definition at line 163 of file class_ldap.inc.
rename_dn | ( | $source, | |
$dest | |||
) |
Move the given Ldap entry from $source to $dest.
String | $source | The source dn. |
String | $dest | The destination dn. |
Definition at line 718 of file class_ldap.inc.
References connect(), logging\debug(), DEBUG_LDAP, and reconnect().
resetResult | ( | $srp | ) |
Reset the result.
integer | $srp | Value to be reset |
Definition at line 566 of file class_ldap.inc.
Referenced by parse_result(), and search().
rm | ( | $attrs = "" , |
|
$dn = "" |
|||
) |
Remove.
string | $attrs | Empty string |
string | $dn | Empty string |
Definition at line 644 of file class_ldap.inc.
References connect(), logging\debug(), DEBUG_LDAP, and reconnect().
rmdir | ( | $deletedn | ) |
Remove directory.
string | $deletedn | The DN to be deleted |
Definition at line 691 of file class_ldap.inc.
References connect(), logging\debug(), DEBUG_LDAP, and reconnect().
rmdir_recursive | ( | $srp, | |
$deletedn | |||
) |
Function rmdir_recursive.
Based on recursive_remove, adding two thing: full subtree remove, and delete own node.
$srp | srp | |
string | $deletedn | The dn to delete |
Definition at line 773 of file class_ldap.inc.
References cd(), connect(), logging\debug(), DEBUG_LDAP, fetch(), get_additional_error(), reconnect(), search(), and success().
Referenced by import_single_entry().
search | ( | $srp, | |
$filter, | |||
$attrs = [] , |
|||
$scope = 'subtree' , |
|||
array | $controls = NULL |
||
) |
Search about filter.
integer | $srp | srp |
string | $filter | The filter |
array | $attrs | |
string | $scope | Scope of the search: subtree/base/one |
Definition at line 350 of file class_ldap.inc.
References clearResult(), connect(), logging\debug(), DEBUG_LDAP, htmlescape(), log(), reconnect(), and resetResult().
Referenced by parse_result(), and rmdir_recursive().
set_size_limit | ( | $size | ) |
Set a size limit.
$size | The limit |
Definition at line 500 of file class_ldap.inc.
References logging\debug(), and DEBUG_LDAP.
success | ( | ) |
Success.
Definition at line 1061 of file class_ldap.inc.
Referenced by add(), modify(), and rmdir_recursive().