<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>PASSWD extended operation helper</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-escape.html">ldap_escape</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ldap-exop-refresh.html">ldap_exop_refresh</a></div> <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.ldap-exop-passwd" class="refentry"> <div class="refnamediv"> <h1 class="refname">ldap_exop_passwd</h1> <p class="verinfo">(PHP 7 >= 7.2.0)</p><p class="refpurpose"><span class="refname">ldap_exop_passwd</span> — <span class="dc-title">PASSWD extended operation helper</span></p> </div> <div class="refsect1 description" id="refsect1-function.ldap-exop-passwd-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>ldap_exop_passwd</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$user</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$oldpw</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$newpw</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$serverctrls</code></span> ]]]] )</div> <p class="para rdfs-comment"> Performs a PASSWD extended operation. </p> </div> <div class="refsect1 parameters" id="refsect1-function.ldap-exop-passwd-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">link</code></dt> <dd> <p class="para"> An LDAP link identifier, returned by <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span>. </p> </dd> <dt> <code class="parameter">user</code></dt> <dd> <p class="para"> dn of the user to change the password of. </p> </dd> <dt> <code class="parameter">oldpw</code></dt> <dd> <p class="para"> The old password of this user. May be ommited depending of server configuration. </p> </dd> <dt> <code class="parameter">newpw</code></dt> <dd> <p class="para"> The new password for this user. May be omitted or empty to have a generated password. </p> </dd> <dt> <code class="parameter">serverctrls</code></dt> <dd> <p class="para"> </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-function.ldap-exop-passwd-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the generated password if <code class="parameter">newpw</code> is empty or omitted. Otherwise returns <strong><code>TRUE</code></strong> on success and <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.ldap-exop-passwd-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5524"> <p><strong>Example #1 PASSWD extended operation</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$ds </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">); </span><span style="color: #FF8000">// assuming the LDAP server is on this host<br /><br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$ds</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// bind with appropriate dn to give update access<br /> </span><span style="color: #0000BB">$bind </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">, </span><span style="color: #DD0000">"cn=root, o=My Company, c=US"</span><span style="color: #007700">, </span><span style="color: #DD0000">"secret"</span><span style="color: #007700">);<br /> if (!</span><span style="color: #0000BB">$bind</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"Unable to bind to LDAP server"</span><span style="color: #007700">;<br /> exit;<br /> }<br /><br /> </span><span style="color: #FF8000">// use PASSWD EXOP to change the user password for a generated one<br /> </span><span style="color: #0000BB">$genpw </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_exop_passwd</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">, </span><span style="color: #DD0000">"cn=root, o=My Company, c=US"</span><span style="color: #007700">, </span><span style="color: #DD0000">"secret"</span><span style="color: #007700">);<br /> if (</span><span style="color: #0000BB">$genpw</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// use the generated password to bind<br /> </span><span style="color: #0000BB">$bind </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">, </span><span style="color: #DD0000">"cn=root, o=My Company, c=US"</span><span style="color: #007700">, </span><span style="color: #0000BB">$genpw</span><span style="color: #007700">);<br /> }<br /><br /> </span><span style="color: #FF8000">// set the password back to "secret"<br /> </span><span style="color: #0000BB">ldap_exop_passwd</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">, </span><span style="color: #DD0000">"cn=root, o=My Company, c=US"</span><span style="color: #007700">, </span><span style="color: #0000BB">$genpw</span><span style="color: #007700">, </span><span style="color: #DD0000">"secret"</span><span style="color: #007700">);<br /><br /> </span><span style="color: #0000BB">ldap_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">);<br />} else {<br /> echo </span><span style="color: #DD0000">"Unable to connect to LDAP server"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.ldap-exop-passwd-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><span class="function"><a href="function.ldap-exop.html" class="function" rel="rdfs-seeAlso">ldap_exop()</a> - Performs an extended operation</span></li> <li class="member"><span class="function"><a href="function.ldap-parse-exop.html" class="function" rel="rdfs-seeAlso">ldap_parse_exop()</a> - Parse result object from an LDAP extended operation</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-escape.html">ldap_escape</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ldap-exop-refresh.html">ldap_exop_refresh</a></div> <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>