PHP Doku:: Setzt den Wert der gegebenen Option - function.ldap-set-option.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteLightweight Directory Access ProtocolLDAP Funktionenldap_set_option

Ein Service von Reinhard Neidl - Webprogrammierung.

LDAP Funktionen

<<ldap_search

ldap_set_rebind_proc>>

ldap_set_option

(PHP 4 >= 4.0.4, PHP 5)

ldap_set_optionSetzt den Wert der gegebenen Option

Beschreibung

bool ldap_set_option ( resource $Verbindungs-Kennung , int $option , mixed $neuerwert )

Setzt den Wert der bestimmten Option auf neuerwert.Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Der Parameter option kann einer der folgenden sein: LDAP_OPT_DEREF, LDAP_OPT_SIZELIMIT, LDAP_OPT_TIMELIMIT, LDAP_OPT_PROTOCOL_VERSION, LDAP_OPT_ERROR_NUMBER, LDAP_OPT_REFERRALS, LDAP_OPT_RESTART, LDAP_OPT_HOST_NAME, LDAP_OPT_ERROR_STRING, LDAP_OPT_MATCHED_DN, LDAP_OPT_SERVER_CONTROLS, LDAP_OPT_CLIENT_CONTROLS. Hier eine kurze Beschreibung, schauen Sie unter » draft-ietf-ldapext-ldap-c- api-xx.txt nach Details.

Die Optionen LDAP_OPT_DEREF, LDAP_OPT_SIZELIMIT, LDAP_OPT_TIMELIMIT, LDAP_OPT_PROTOCOL_VERSION und LDAP_OPT_ERROR_NUMBER haben einen ganzzahligen Wert, LDAP_OPT_REFERRALS und LDAP_OPT_RESTART haben einen boolschen Wert und die Optionen LDAP_OPT_HOST_NAME, LDAP_OPT_ERROR_STRING und LDAP_OPT_MATCHED_DN bestehen aus einer Zeichenkette. Das erste Beispiel veranschaulicht deren Gebrauch. Die Optionen LDAP_OPT_SERVER_CONTROLS and LDAP_OPT_CLIENT_CONTROLS benötigen eine Kontrolliste, d.h. der Wert muss ein Array aus Kontrollen sein. Eine Kontrolle besteht aus einer oid die die Kontrolle identifiziert, einem wahlweisen wert, und einem wahlweisen Kennzeichen für criticality. Bei PHP wird eine Kontrolle durch ein Array angegeben. Dieses Array enthält ein Element mit dem Schlüssel oid und einer Zeichenkette als Wert und zwei optionalen Elementen. Die optionalen Elemente sind Schlüssel wert mit einer Zeichenkette als Wert und dem Schlüssel iscritical mit einem boolschen Wert. Der vorgegebene Wert von iscritical ist FALSE falls Sie nichts angeben. Schauen Sie sich das zweite Beispiel weiter unten an.

Hinweis:

Diese Funktion steht nur zur Verfügung, wenn Sie OpenLDAP 2.x.x ODER Netscape Directory SDK x.x verwenden und wurde in PHP 4.0.4 hinzugefügt.

Beispiel #1 Setzen der Protokollversion

// $ds ist eine gültige Verbindungs-Kennung für einen Verzeichnis-
// Server
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
    echo "Verwenden von LDAPv3";
else
    echo "Kann das Protokoll nicht auf Version 3 setzen";

Beispiel #2 Setzen der Server Kontrollen

// $ds ist eine gültige Verbingund-Kennung für einen Verzeichnis-
// Server
// Kontrolle ohne Wert
$ctrl1 = array("oid" => "1.2.752.58.10.1", "iscritical" => TRUE);
// iscritical hat den vorgegebenen Wert FALSE
$ctrl2 = array("oid" => "1.2.752.58.1.10", "value" => "magic");
// Versuch, beide Kontrollen zu setzen
if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1,
$ctrl2)))
    echo "Kann die Server Kontrollen nicht setzen";

Siehe auch ldap_get_option().


6 BenutzerBeiträge:
- Beiträge aktualisieren...
Anonymous
19.11.2010 10:56
LDAP options description

http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fldap_set_option.htm
technosophos
7.03.2007 23:00
The following flags are valid integer values for the LDAP_OPT_DEREF (as taken from the documentation for ldap_read()):

LDAP_DEREF_NEVER (int 0) - (default) aliases are never dereferenced.

LDAP_DEREF_SEARCHING (int 1) - aliases should be dereferenced during the search but not when locating the base object of the search.

LDAP_DEREF_FINDING (int 2) - aliases should be dereferenced when locating the base object but not during the search.

LDAP_DEREF_ALWAYS (int 3) - aliases should be dereferenced always.

Example:
<?php
ldap_set_option
($ds, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS);
?>

These are defined in the draft C API (presumably from the original LDAP API). See draft-ietf-ldapext-ldap-c-api-xx.txt included in the OpenLDAP source code distribution.
hansfn at gmail dot com
23.05.2006 13:23
Luckily you can turn on debugging before you open a connection:

  ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);

This way you at least can see in the logs if the connection fails...
minusf at gmail dot com
31.10.2005 10:59
it seems that ldap_set_option returns 1 for bogus ldap_connect -ions also.
ldap_connect always returns a resource (documented in the
comments of ldap_connect) so it is not possible to check if the
ldap server is there or alive or what.  and because ldap_set_option
must be between ldap_connect and ldap_bind, there seems to
be no sense in checking the return value.

it is a bit strange that ldap_bind is the first function which can
really check if a ldap resource is usable because it is the third
function in line to use when working with openldap.

<?php
$connect
= ldap_connect("whatever");
$set = ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
echo
$set;
?>
soulbros at yahoo dot com
27.02.2002 0:56
As john.hallam@compaq.com above mentioned ,one  has to set option LDAP_OPT_PROTOCOL_VERSION=3
ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3);
to use the ldap_rename function.

However, the ldap_set_option() line has to be written immediately after ldap_connect() and before ldap_bind() statements.

Christos Soulios
john dot hallam at compaq dot com
28.01.2002 19:00
To get this to work I had to set the LDAP version to 3 using ldap_set_option. Here is an example that might help:

$TheDN = "cn=john smith,ou=users,dc=acme,dc=com";
$newRDN = "cn=bill brown";
$newParent = "ou=users,dc=acme,dc=com";
ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3);
@$result = ldap_rename($ds, $TheDN, $newRDN, $newParent, TRUE);



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)