rfc:ldap_exop

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:ldap_exop [2017/06/26 15:01] – Added examples section mcmicrfc:ldap_exop [2017/06/29 14:29] mcmic
Line 26: Line 26:
 </code> </code>
 Returns TRUE upon success and FALSE upon failure. Fills $retoid and $retdata with the data from $result object. Returns TRUE upon success and FALSE upon failure. Fills $retoid and $retdata with the data from $result object.
 +
 +This RFC also wish to introduce helper functions for common EXOP usage:
 +<code php>
 +bool ldap_exop_whoami(resource $link, string &$result)
 +bool ldap_exop_passwd(resource $link, string $user, string $oldpw, string $newpw [, string &$genpw])
 +</code>
 +The first one would call whoami EXOP and fill $result with the result. Return TRUE or FALSE upon failure.
 +The second one would call passwd EXOP and return TRUE or FALSE upon failure. If $newpw is empty, $genpw will be filled with the generated password for the user. If $user is empty, it affects the bound user.
 +
 +The author of the original patch stated that technically ldap_start_tls is an exop helper and therefore could be renamed ldap_exop_start_tls. We feel this would be a useless BC.
 +
 +The original patch (and current code) provided a possibility to get a result object from helpers as well, and provided ldap_parse_exop_* helpers to parse the result objects from these operations. We feel this is too complex and does not add anything to the RFC so we intend to leave them out.
  
 ===== Examples ===== ===== Examples =====
Line 39: Line 51:
 if (($r !== FALSE) && ldap_parse_exop($link, $r, $retoid, $retdata)) { if (($r !== FALSE) && ldap_parse_exop($link, $r, $retoid, $retdata)) {
   echo "Connected as $retdata\n";   echo "Connected as $retdata\n";
 +} else {
 +  echo "Operation failed\n";
 +}
 +// Same thing with the helper
 +if (ldap_exop_whoami($link, $identity)) {
 +  echo "Connected as $identity\n";
 +} else {
 +  echo "Operation failed\n";
 +}
 +// Changing password with the helper
 +if (ldap_exop_passwd($link, 'uid=johndoe,dc=example,dc=com', '', 'newpassword')) {
 +  echo "Password changed\n";
 } else { } else {
   echo "Operation failed\n";   echo "Operation failed\n";
Line 48: Line 72:
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
-7.2 if possible, 7.3/8 otherwise+Next PHP 7.x release
  
 ===== RFC Impact ===== ===== RFC Impact =====
Line 67: Line 91:
 ===== Open Issues ===== ===== Open Issues =====
   - Should the function names contain the word "exop" or is it a technical detail which should be hidden from the developer?   - Should the function names contain the word "exop" or is it a technical detail which should be hidden from the developer?
-  - Should we include a constant for LDAP_EXOP_REFRESH, for the sake of completeness, even if this EXOP won’t be used by PHP code as all PHP LDAP operations are synchrone (in the current code state).+  - Should we include a constant for LDAP_EXOP_CANCEL, for the sake of completeness, even if this EXOP won’t be used by PHP code as all PHP LDAP operations are synchrone (in the current code state)
 +  - The $retoid field seems useless for all EXOPs listed in the constant section, they either leave it empty or fill it with the same value as $reqoid. So maybe this field should be moved to the last position to be easily omitted. But this may result in a less natural order: //reqoid, reqdata, retdata, retoid// (though most of the time it will be //reqoid, reqdata, retdata//). 
 +  - Functions throws E_WARNING for all errors and failures. ldap_error() can be used to get the last error.
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
rfc/ldap_exop.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1