diff options
author | Côme Chilliet <mcmic@php.net> | 2017-09-07 14:42:34 +0200 |
---|---|---|
committer | Côme Chilliet <mcmic@php.net> | 2017-09-21 10:05:41 +0200 |
commit | 81b27abac01e8241467d608b38ac17f3d1161e69 (patch) | |
tree | c687a245c4450a5bde62524e061fcd8f800b8f40 /ext/ldap | |
parent | 2b52cb74da92a2cc9b355a4b422168a1069ab321 (diff) | |
download | php-git-81b27abac01e8241467d608b38ac17f3d1161e69.tar.gz |
Added support for controls in ldap_modify_batch
Diffstat (limited to 'ext/ldap')
-rw-r--r-- | ext/ldap/ldap.c | 32 | ||||
-rw-r--r-- | ext/ldap/tests/ldap_modify_batch_error.phpt | 10 |
2 files changed, 34 insertions, 8 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 9c0d598d78..3b5bac8513 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -2083,10 +2083,11 @@ static void _ldap_hash_fetch(zval *hashTbl, const char *key, zval **out) } /* }}} */ -/* {{{ proto bool ldap_modify_batch(resource link, string dn, array modifs) +/* {{{ proto bool ldap_modify_batch(resource link, string dn, array modifs [, array servercontrols [, array clientcontrols]]) Perform multiple modifications as part of one operation */ PHP_FUNCTION(ldap_modify_batch) { + zval *serverctrls = NULL, *clientctrls = NULL; ldap_linkdata *ld; zval *link, *mods, *mod, *modinfo, *modval; zval *attrib, *modtype, *vals; @@ -2096,6 +2097,7 @@ PHP_FUNCTION(ldap_modify_batch) int i, j, k; int num_mods, num_modprops, num_modvals; LDAPMod **ldap_mods; + LDAPControl **lserverctrls = NULL, **lclientctrls = NULL; uint32_t oper; /* @@ -2122,7 +2124,7 @@ PHP_FUNCTION(ldap_modify_batch) ); */ - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsa/", &link, &dn, &dn_len, &mods) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsa/|aa", &link, &dn, &dn_len, &mods, &serverctrls, &clientctrls) != SUCCESS) { return; } @@ -2350,8 +2352,23 @@ PHP_FUNCTION(ldap_modify_batch) /* NULL-terminate modifications */ ldap_mods[num_mods] = NULL; + if (serverctrls) { + lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls); + if (lserverctrls == NULL) { + RETVAL_FALSE; + goto cleanup; + } + } + if (clientctrls) { + lclientctrls = _php_ldap_controls_from_array(ld->link, clientctrls); + if (lclientctrls == NULL) { + RETVAL_FALSE; + goto cleanup; + } + } + /* perform (finally) */ - if ((i = ldap_modify_ext_s(ld->link, dn, ldap_mods, NULL, NULL)) != LDAP_SUCCESS) { + if ((i = ldap_modify_ext_s(ld->link, dn, ldap_mods, lserverctrls, lclientctrls)) != LDAP_SUCCESS) { php_error_docref(NULL, E_WARNING, "Batch Modify: %s", ldap_err2string(i)); RETVAL_FALSE; } else RETVAL_TRUE; @@ -2382,6 +2399,13 @@ PHP_FUNCTION(ldap_modify_batch) /* the modifications array */ efree(ldap_mods); + + if (lserverctrls) { + _php_ldap_controls_free(&lserverctrls); + } + if (lclientctrls) { + _php_ldap_controls_free(&lclientctrls); + } } } /* }}} */ @@ -4100,6 +4124,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_modify_batch, 0, 0, 3) ZEND_ARG_INFO(0, link_identifier) ZEND_ARG_INFO(0, dn) ZEND_ARG_ARRAY_INFO(0, modifications_info, 0) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_mod_add, 0, 0, 3) diff --git a/ext/ldap/tests/ldap_modify_batch_error.phpt b/ext/ldap/tests/ldap_modify_batch_error.phpt index 2d72d491f8..3a1030f917 100644 --- a/ext/ldap/tests/ldap_modify_batch_error.phpt +++ b/ext/ldap/tests/ldap_modify_batch_error.phpt @@ -26,7 +26,7 @@ var_dump(ldap_modify_batch($link)); var_dump(ldap_modify_batch($link, "$base")); // Too many parameters -var_dump(ldap_modify_batch($link, "$base", $addGivenName, "Invalid additional parameter")); +var_dump(ldap_modify_batch($link, "$base", $addGivenName, [], [], "Invalid additional parameter")); // DN not found var_dump(ldap_modify_batch($link, "cn=not-found,$base", $addGivenName)); @@ -78,16 +78,16 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); ldap_delete($link, "dc=my-domain,$base"); ?> --EXPECTF-- -Warning: ldap_modify_batch() expects exactly 3 parameters, 0 given in %s on line %d +Warning: ldap_modify_batch() expects at least 3 parameters, 0 given in %s on line %d NULL -Warning: ldap_modify_batch() expects exactly 3 parameters, 1 given in %s on line %d +Warning: ldap_modify_batch() expects at least 3 parameters, 1 given in %s on line %d NULL -Warning: ldap_modify_batch() expects exactly 3 parameters, 2 given in %s on line %d +Warning: ldap_modify_batch() expects at least 3 parameters, 2 given in %s on line %d NULL -Warning: ldap_modify_batch() expects exactly 3 parameters, 4 given in %s on line %d +Warning: ldap_modify_batch() expects at most 5 parameters, 6 given in %s on line %d NULL Warning: ldap_modify_batch(): Batch Modify: No such object in %s on line %d |