com php-src: Added support for controls to ldap_get_option : ext/ldap/ldap.c
| From: | Côme Bernigaud | Date: | Wed, 05 Jul 2017 14:41:52 +0000 |
| Subject: | com php-src: Added support for controls to ldap_get_option : ext/ldap/ldap.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98397@lists.php.net to get a copy of this message | ||
Commit: 3a09c1246cb5f084ffb00827d829d0da4f505c3c
Author: Côme Chilliet <mcmic@php.net> Tue, 4 Jul 2017 17:08:57 +0200
Parents: 6164ec91c6341f34e5a1d30c658c15ca9c5bcbaa
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3a09c1246cb5f084ffb00827d829d0da4f505c3c
Log:
Added support for controls to ldap_get_option
Changed paths:
M ext/ldap/ldap.c
Diff:
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 8e0b908..8263e70 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -2129,6 +2129,8 @@ PHP_FUNCTION(ldap_sort)
PHP_FUNCTION(ldap_get_option)
{
zval *link, *retval;
+ zval tmp1;
+ int num_entries;
ldap_linkdata *ld;
zend_long option;
@@ -2273,9 +2275,37 @@ PHP_FUNCTION(ldap_get_option)
ZVAL_STRING(retval, val);
ldap_memfree(val);
} break;
-/* options not implemented
case LDAP_OPT_SERVER_CONTROLS:
case LDAP_OPT_CLIENT_CONTROLS:
+ {
+ LDAPControl **ctrls = NULL, **ctrlp;
+
+ if (ldap_get_option(ld->link, option, &ctrls) || ctrls == NULL) {
+ if (ctrls) {
+ ldap_memfree(ctrls);
+ }
+ RETURN_FALSE;
+ }
+
+ zval_ptr_dtor(retval);
+ array_init(retval);
+ num_entries = 0;
+ ctrlp = ctrls;
+ while (*ctrlp != NULL)
+ {
+ array_init(&tmp1);
+ add_assoc_string(&tmp1, "oid", (*ctrlp)->ldctl_oid);
+ add_assoc_bool(&tmp1, "iscritical", ((*ctrlp)->ldctl_iscritical != 0));
+ if ((*ctrlp)->ldctl_value.bv_len) {
+ add_assoc_stringl(&tmp1, "value", (*ctrlp)->ldctl_value.bv_val,
(*ctrlp)->ldctl_value.bv_len);
+ }
+ zend_hash_index_update(Z_ARRVAL_P(retval), num_entries, &tmp1);
+ num_entries++;
+ ctrlp++;
+ }
+ ldap_controls_free(ctrls);
+ } break;
+/* options not implemented
case LDAP_OPT_API_INFO:
case LDAP_OPT_API_FEATURE_INFO:
*/