summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Venaas <venaas@php.net>2001-01-08 18:13:08 +0000
committerStig Venaas <venaas@php.net>2001-01-08 18:13:08 +0000
commit897f293d1390e59afac8a9ac0471f32af1c7a27b (patch)
treebe202a051cb941edfa6d2ef587570a8c00e40478
parent735b8ed6edcf94a8438ece7800375676bec7426d (diff)
downloadphp-git-897f293d1390e59afac8a9ac0471f32af1c7a27b.tar.gz
Added ldap_rename(). Currently requires API with ldap_rename().
@- Added ldap_rename() function (Stig Venaas)
-rw-r--r--ext/ldap/ldap.c43
-rw-r--r--ext/ldap/php_ldap.h1
2 files changed, 43 insertions, 1 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 59d1ec6e17..ca2d4c3c90 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -102,6 +102,7 @@ function_entry ldap_functions[] = {
PHP_FE(ldap_first_reference, NULL)
PHP_FE(ldap_next_reference, NULL)
PHP_FE(ldap_parse_reference, third_argument_force_ref)
+ PHP_FE(ldap_rename, NULL)
#endif
#ifdef STR_TRANSLATION
@@ -1635,7 +1636,7 @@ PHP_FUNCTION(ldap_set_option) {
/* options with string value */
case LDAP_OPT_HOST_NAME:
case LDAP_OPT_ERROR_STRING:
-#ifndef HAVE_NSLDAP
+#ifdef LDAP_OPT_MATCHED_DN
case LDAP_OPT_MATCHED_DN:
#endif
{
@@ -1919,6 +1920,46 @@ PHP_FUNCTION(ldap_parse_reference)
RETURN_TRUE;
}
/* }}} */
+
+
+/* {{{ proto boolean ldap_rename(int link, string dn, string newrdn,
+ string newparent, boolean deleteoldrdn);
+ Modify the name of an entry */
+PHP_FUNCTION(ldap_rename)
+{
+ pval **link, **dn, **newrdn, **newparent, **deleteoldrdn;
+ LDAP *ldap;
+ int rc;
+
+ if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &link, &dn, &newrdn, &newparent, &deleteoldrdn) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ldap = _get_ldap_link(link);
+ if (ldap == NULL) RETURN_FALSE;
+
+ convert_to_string_ex(dn);
+ convert_to_string_ex(newrdn);
+ convert_to_string_ex(newparent);
+ convert_to_boolean_ex(deleteoldrdn);
+
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
+ rc = ldap_rename_s(ldap, Z_STRVAL_PP(dn), Z_STRVAL_PP(newrdn), Z_STRVAL_PP(newparent), Z_BVAL_PP(deleteoldrdn), NULL, NULL);
+#else
+ if (Z_STRLEN_PP(newparent) != 0) {
+ php_error(E_WARNING, "You are using old LDAP API, newparent must be the empty string, can only modify RDN");
+ RETURN_FALSE;
+ }
+/* could support old APIs but need check for ldap_modrdn2()/ldap_modrdn() */
+ rc = ldap_modrdn2_s(ldap, Z_STRVAL_PP(dn), Z_STRVAL_PP(newrdn), Z_BVAL_PP(deleteoldrdn));
+#endif
+
+ if (rc == LDAP_SUCCESS) {
+ RETURN_TRUE;
+ }
+ RETURN_FALSE;
+}
+/* }}} */
#endif
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index bfe73edf94..4fd84a2369 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -88,6 +88,7 @@ PHP_FUNCTION(ldap_parse_result);
PHP_FUNCTION(ldap_first_reference);
PHP_FUNCTION(ldap_next_reference);
PHP_FUNCTION(ldap_parse_reference);
+PHP_FUNCTION(ldap_rename);
#endif
#ifdef STR_TRANSLATION