<HTML ><HEAD ><TITLE >ldap_set_option</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="LDAP functions" HREF="ref.ldap.html"><LINK REL="PREVIOUS" TITLE="ldap_search" HREF="function.ldap-search.html"><LINK REL="NEXT" TITLE="ldap_set_rebind_proc" HREF="function.ldap-set-rebind-proc.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.ldap-search.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ldap-set-rebind-proc.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ldap-set-option" ></A >ldap_set_option</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN43610" ></A ><P > (PHP 4 >= 4.0.4)</P >ldap_set_option -- Set the value of the given option</DIV ><DIV CLASS="refsect1" ><A NAME="AEN43613" ></A ><H2 >Description</H2 >bool <B CLASS="methodname" >ldap_set_option</B > ( resource link_identifier, int option, mixed newval)<BR ></BR ><P > Sets the value of the specified option to be <TT CLASS="parameter" ><I >newval</I ></TT >. Returns <TT CLASS="constant" ><B >TRUE</B ></TT > on success or <TT CLASS="constant" ><B >FALSE</B ></TT > on failure. on error.</P ><P > The parameter <TT CLASS="parameter" ><I >option</I ></TT > can be one of: 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. Here's a brief description, see <A HREF="http://www.openldap.org/devel/cvsweb.cgi/~checkout~/doc/drafts/draft-ietf-ldapext-ldap-c-api-xx.txt" TARGET="_top" >draft-ietf-ldapext-ldap-c-api-xx.txt</A > for details.</P ><P > The options LDAP_OPT_DEREF, LDAP_OPT_SIZELIMIT, LDAP_OPT_TIMELIMIT, LDAP_OPT_PROTOCOL_VERSION and LDAP_OPT_ERROR_NUMBER have integer value, LDAP_OPT_REFERRALS and LDAP_OPT_RESTART have boolean value, and the options LDAP_OPT_HOST_NAME, LDAP_OPT_ERROR_STRING and LDAP_OPT_MATCHED_DN have string value. The first example illustrates their use. The options LDAP_OPT_SERVER_CONTROLS and LDAP_OPT_CLIENT_CONTROLS require a list of controls, this means that the value must be an array of controls. A control consists of an <SPAN CLASS="emphasis" ><I CLASS="emphasis" >oid</I ></SPAN > identifying the control, an optional <SPAN CLASS="emphasis" ><I CLASS="emphasis" >value</I ></SPAN >, and an optional flag for <SPAN CLASS="emphasis" ><I CLASS="emphasis" >criticality</I ></SPAN >. In PHP a control is given by an array containing an element with the key <SPAN CLASS="emphasis" ><I CLASS="emphasis" >oid</I ></SPAN > and string value, and two optional elements. The optional elements are key <SPAN CLASS="emphasis" ><I CLASS="emphasis" >value</I ></SPAN > with string value and key <SPAN CLASS="emphasis" ><I CLASS="emphasis" >iscritical</I ></SPAN > with boolean value. <SPAN CLASS="emphasis" ><I CLASS="emphasis" >iscritical</I ></SPAN > defaults to <SPAN CLASS="emphasis" ><I CLASS="emphasis" ><TT CLASS="constant" ><B >FALSE</B ></TT ></I ></SPAN > if not supplied. See also the second example below. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > This function is only available when using OpenLDAP 2.x.x OR Netscape Directory SDK x.x, and was added in PHP 4.0.4. </P ></BLOCKQUOTE ></DIV ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN43647" ></A ><P ><B >Example 1. Set protocol version</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >// $ds is a valid link identifier for a directory server if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) echo "Using LDAPv3"; else echo "Failed to set protocol version to 3";</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN43650" ></A ><P ><B >Example 2. Set server controls</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >// $ds is a valid link identifier for a directory server // control with no value $ctrl1 = array("oid" => "1.2.752.58.10.1", "iscritical" => TRUE); // iscritical defaults to FALSE $ctrl2 = array("oid" => "1.2.752.58.1.10", "value" => "magic"); // try to set both controls if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1, $ctrl2))) echo "Failed to set server controls";</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > See also <A HREF="function.ldap-get-option.html" ><B CLASS="function" >ldap_get_option()</B ></A >.</P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.ldap-search.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ldap-set-rebind-proc.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >ldap_search</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.ldap.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ldap_set_rebind_proc</TD ></TR ></TABLE ></DIV ></BODY ></HTML >