Zend_LdapZend_Ldap is the base interface into a LDAP
server. It provides connection and binding methods as well as methods to operate on the
LDAP tree.
Zend_Ldap APIMethodDescriptionstring filterEscape(string $str)
Escapes a value to be used in a LDAP filter according to
RFC 2254. This method is deprecated, please use
Zend_Ldap_Filter_Abstract::escapeValue()
instead.
boolean explodeDn($dn, array &$keys = null, array &$vals = null)
Checks if a given DN $dn is malformed. If
$keys or $keys and $vals are
given, these arrays will be filled with the appropriate DN keys and
values. This method is deprecated, please use
Zend_Ldap_Dn::checkDn() instead.
__construct($options)
Constructor. The $options parameter is optional
and can be set to an array or a Zend_Config instance.
If no options are provided at instantiation, the connection
parameters must be passed to the instance using
Zend_Ldap::setOptions(). The allowed options are
specified in Zend_Ldap
Options
resource getResource()Returns the raw LDAP extension (ext/ldap) resource.integer getLastErrorCode()
Returns the LDAP error number of the last LDAP
command.
string getLastError(integer &$errorCode, array &$errorMessages)
Returns the LDAP error message of the last LDAP command. The
optional $errorCode parameter is set to the LDAP error
number when given. The optional $errorMessages array
will be filled with the raw error messages when given. The various
LDAP error retrieval functions can return different things, so they
are all collected if $errorMessages is given.
Zend_Ldap setOptions($options)
Sets the LDAP connection and binding parameters.
$options can be an array or an instance of
Zend_Config. The allowed options are specified in
Zend_Ldap Options
array getOptions()
Returns the current connection and binding
parameters.
string getBaseDn()
Returns the base DN this LDAP connection is bound
to.
string getCanonicalAccountName(string $acctname, integer $form)
Returns the canonical account name of the given account name
$acctname. $form specifies the format
into which the account name is canonicalized. See Account Name Canonicalization
for more details.
Zend_Ldap disconnect()
Disconnects the Zend_Ldap instance from the LDAP
server.
Zend_Ldap connect(string $host, integer $port, boolean $useSsl, boolean $useStartTls)
Connects the Zend_Ldap instance to the given LDAP server.
All parameters are optional and will be taken from the LDAP
connection and binding parameters passed to the instance via the
construtor or via Zend_Ldap::setOptions() when set to
NULL.
Zend_Ldap bind(string $username, string $password)
Authenticates $username with
$password at the LDAP server. If both paramaters are
omitted the binding will be carried out with the credentials given
in the connection and binding parameters. If no credentials are
given in the connection and binding parameters an anonymous bind
will be performed. Note that this requires anonymous binds to be
allowed on the LDAP server. An empty string '' can be
passed as $password together with a username if, and
only if, allowEmptyPassword is set to
TRUE in the connection and binding parameters.
Zend_Ldap_Collection search(string|Zend_Ldap_Filter_Abstract $filter, string|Zend_Ldap_Dn $basedn, integer $scope, array $attributes, string $sort, string $collectionClass)
Searches the LDAP tree with the given $filter
and the given search parameters.
string|Zend_Ldap_Filter_Abstract
$filter
The filter string to be used in the search, e.g.
(objectClass=posixAccount).
string|Zend_Ldap_Dn $basedn
The search base for the search. If omitted or
NULL, the baseDn from the
connection and binding parameters is used.
integer $scope
The search scope.
Zend_Ldap::SEARCH_SCOPE_SUB searches the
complete subtree including the $baseDn node.
Zend_Ldap::SEARCH_SCOPE_ONE restricts search
to one level below $baseDn.
Zend_Ldap::SEARCH_SCOPE_BASE restricts search
to the $baseDn itself; this can be used to
efficiently retrieve a single entry by its DN. The default
value is
Zend_Ldap::SEARCH_SCOPE_SUB.
array $attributes
Specifies the attributes contained in the
returned entries. To include all possible attributes (ACL
restrictions can disallow certain attribute to be retrieved
by a given user) pass either an empty array
array() or array('*') to the
method. On some LDAP servers you can retrieve special
internal attributes by passing array('*', '+')
to the method.
string $sort
If given the result collection will be sorted
after the attribute $sort. Results can only be
sorted after one single attribute as this parameter uses
the ext/ldap function ldap_sort().
string $collectionClass
If given the result will be wrapped in an object
of type $collectionClass. By default an object
of type Zend_Ldap_Collection will be returned.
The custom class must extend
Zend_Ldap_Collection and will be passed a
Zend_Ldap_Collection_Iterator_Default on
instantiation.
integer count(string|Zend_Ldap_Filter_Abstract
$filter, string|Zend_Ldap_Dn $basedn, integer
$scope)
Counts the elements returned by the given search parameters.
See Zend_Ldap::search() for a detailed description of
the method parameters.
integer countChildren(string|Zend_Ldap_Dn
$dn)
Counts the direct descendants (children) of the entry
identified by the given $dn.
boolean exists(string|Zend_Ldap_Dn $dn)
Checks whether the entry identified by the given
$dn exists.
array searchEntries(string|Zend_Ldap_Filter_Abstract
$filter, string|Zend_Ldap_Dn $basedn, integer $scope, array
$attributes, string $sort)
Performs a search operation and returns the result as an PHP
array. This is essentially the same method as
Zend_Ldap::search() except for the return type. See
Zend_Ldap::search() for a detailed description of the
method parameters.
array getEntry(string|Zend_Ldap_Dn $dn, array
$attributes, boolean $throwOnNotFound)
Retrieves the LDAP entry identified by $dn with
the attributes specified in $attributes. If
$attributes is ommitted, all attributes
(array()) are included in the result.
$throwOnNotFound is FALSE by default, so
the method will return NULL if the specified entry
cannot be found. If set to TRUE, a
Zend_Ldap_Exception will be thrown instead.
void prepareLdapEntryArray(array
&$entry)
Bereitet ein Array für die Verwendung in Modifikations Operationen von
LDAP vor. Diese Methode muß nicht von Endbenutzern
aufgerufen werden da Sie implizit bei jeder Methode die Daten verändert
aufgerufen wird.
Zend_Ldap add(string|Zend_Ldap_Dn $dn, array
$entry)
Fügt den Eintrag der durch $dn mit seinen
$entry identifiziert wird im LDAP
Baum hinzu. Wirft eine Zend_Ldap_Exception wenn der
Eintrag nicht hinzugefügt werden konnte.
Zend_Ldap update(string|Zend_Ldap_Dn $dn, array
$entry)
Aktualisiert den Eintrag der durch $dn mit seinen
$entry Attributen identifiziert wird im
LDAP Baum. Wirft eine
Zend_Ldap_Exception wenn der Eintrag nicht geändert
werden konnte.
Zend_Ldap save(string|Zend_Ldap_Dn $dn, array
$entry)
Speichert den Eintrag der durch $dn mit seinen
$entry Attributen identifiziert wird im
LDAP Baum. Wirft eine
Zend_Ldap_Exception wenn der Eintrag nicht
gespeichert werden konnte. Diese Methode wählt durch eine Suche im
LDAP Baum ob der Eintrag hinzugefügt oder aktualisiert
wird.
Zend_Ldap delete(string|Zend_Ldap_Dn $dn, boolean
$recursively)
Löscht den Eintrag der durch $dn identifiziert wird vom
LDAP Baum. Wirft eine
Zend_Ldap_Exception Exception wenn der Eintrag nicht
gelöscht werden kann. $recursively ist standardmäßig
FALSE. Auf TRUE gesetzt wird
das Löschen rekursiv durchgeführt und löscht effektiver Weise den kompletten
Unterbaum. Das Löschen wird fehlschlagen wenn
$recursivelyFALSE ist und der
$dn Eintrag kein Blatteintrag ist.
Zend_Ldap moveToSubtree(string|Zend_Ldap_Dn $from,
string|Zend_Ldap_Dn $to, boolean $recursively, boolean
$alwaysEmulate)
Verschiebt den Eintrag der von $from identifiziert wird
auf einen Ort nach $to wobei sein RDN
unverändert bleibt. $recursively spezifiziert ob die
Operation rekursiv ausgeführt wird (standardmäßig
FALSE) so dass der Eintrag $from und
alle seine Untereinträge verschoben werden. Das Verschieben wird
fehlschlagen wenn $recursivelyFALSE
ist und der Eintrag $from kein Blatteintrag ist.
$alwaysEmulate kontrolliert ob die ext/ldap Funktion
ldap_rename() verwendet werden soll wenn Sie
vorhanden ist. Das kann nur für Blatteinträge funktionieren und für Server
und für ext/ldap die diese Funktion unterstützen. Auf
TRUE gesetzt wird immer eine emulierte Rename Operation
verwendet.
Alle Verschiebe-Operationen werden ausgeführt indem die
betreffenden Einträge im LDAP Baum kopiert und
anschließend gelöscht werden. Diese Operationen sind nicht
atomar so dass Fehler wärend der Operation zu einem
inkonsistenten Status am LDAP
Server führen. Das selbe gilt auch für alle rekursiven Operationen. Auch
diese sind in keiner Weise atomar. Man sollte das immer beachten.
Zend_Ldap move(string|Zend_Ldap_Dn $from,
string|Zend_Ldap_Dn $to, boolean $recursively, boolean
$alwaysEmulate)
Das ist ein Alias für Zend_Ldap::rename().
Zend_Ldap rename(string|Zend_Ldap_Dn $from,
string|Zend_Ldap_Dn $to, boolean $recursively, boolean
$alwaysEmulate)
Benennt den Eintrag der von $from bis
$to identifiziert wird um.
$recursively spezifiziert ob die Operation rekursiv
durchgeführt werden soll (standardmäßig FALSE) so das
der Eintrag $from und alle seine Abhängigkeiten
verschoben werden. Das Umbenennen wird fehlschlagen wenn
$recursivelyFALSE ist und der
Eintrag $from kein Blatteintrag ist.
$alwaysEmulate kontrolliert ob die ext/ldap Funktion
ldap_rename() verwendet werden soll wenn Sie
vorhanden ist. Das kann nur für Blatteinträge und für Server funktionieren
und für ext/ldap welches diese Funktion unterstützt. Wird es auf
TRUE gesetzt wird immer die emulierte rename
Operation verwendet.
Zend_Ldap copyToSubtree(string|Zend_Ldap_Dn $from,
string|Zend_Ldap_Dn $to, boolean $recursively)
Kopiert den Eintrag der von $from bis zu einem Ort
unterhalb von $to identifiziert wird und lässt dessen
RDN unverändert. $recursively
spezifiziert ob die Operation rekursiv durchgeführt werden soll
(standardmäßig FALSE) so das der Eintrag
$from und alle seine Abhängigkeiten kopiert werden.
Das Kopieren wird fehlschlagen wenn $recursivelyFALSE ist und der Eintrag $from
kein Blatteintrag ist.
Zend_Ldap copy(string|Zend_Ldap_Dn $from,
string|Zend_Ldap_Dn $to, boolean $recursively)
Kopiert den Eintrag der von $from bis
$to identifiziert wird. $recursively
spezifiziert ob die Operation rekursiv durchgeführt werden soll
(standardmäßig FALSE) so das der Eintrag
$from und alle seine Abhängigkeiten kopiert werden.
Das Kopieren wird fehlschlagen wenn $recursivelyFALSE ist und der Eintrag $from
kein Blatteintrag ist.
Zend_Ldap_Node getNode(string|Zend_Ldap_Dn
$dn)
Gibt den $dn Eintrag zurück der in einem
Zend_Ldap_Node gewrappt ist.
Zend_Ldap_Node getBaseNode()
Gibt den Eintrag für den Basis DN $baseDn zurück
der in einer Zend_Ldap_Node gewrappt ist.
Zend_Ldap_Node_RootDse getRootDse()Gibt den RootDSE für den aktuellen Server zurück.Zend_Ldap_Node_Schema getSchema()
Gibt das LDAP Schema für den aktuellen Server zurück.
Zend_Ldap_CollectionZend_Ldap_Collection implementiert Iterator um
das Durchlaufen von Einträgen zu erlauben indem foreach() und
Countable verwendet werden welche in der Lage sind auf
count() zu Antworten. Mit seiner geschützten _createEntry()
Methode bietet es einen einfachen Punkt der Erweiterung für Entwickler welche die
Notwendigkeit für eigene Ergebnisobjekte haben.
API für Zend_Ldap_CollectionMethodeBeschreibung__construct(Zend_Ldap_Collection_Iterator_Interface
$iterator)
Constructor. Der Constructor muß von einem
Zend_Ldap_Collection_Iterator_Interface angeboten
werden welches die echte Iteration der Resultate durchführt.
Zend_Ldap_Collection_Iterator_Default ist die
standardmäßige Implementation für die Interation durch ext/ldap Ergebnisse.
boolean close()
Schließt den internen Iterator. Wird auch im Destructor aufgerufen.
array toArray()Gibt alle Einträge als Array zurück.array getFirst()
Gibt den ersten Eintrag der Collection zurück, oder NULL wenn
die Collection leer ist.