summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_ldap
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-10-20 19:28:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:02:20 -0500
commita9bd40549767c19207f3ec520a3e4346beeabef4 (patch)
tree055d67a79bdd2cb9098284fabdbf8a9cba6e95a9 /source4/lib/ldb/ldb_ldap
parent8d48ca63db0ec8dc47a386bd1fa38be2827755f3 (diff)
downloadsamba-a9bd40549767c19207f3ec520a3e4346beeabef4.tar.gz
samba-a9bd40549767c19207f3ec520a3e4346beeabef4.tar.bz2
samba-a9bd40549767c19207f3ec520a3e4346beeabef4.zip
r3093: - implment ldb_rename() and ldbrename
- add tests for ldbrename - disable all tests which regenerate the index (this is broken for me...the process hangs, tridge we need to discuss that) - link only the needed stuff to the ldb tools - build ldbtest inside samba metze (This used to be commit 18552f4786c24e0019cc87726ef4c05365fe586e)
Diffstat (limited to 'source4/lib/ldb/ldb_ldap')
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 06d3884c16..5b682a493a 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -92,6 +92,41 @@ static int lldb_close(struct ldb_context *ldb)
}
/*
+ rename a record
+*/
+static int lldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn)
+{
+ struct lldb_private *lldb = ldb->private_data;
+ int ret = 0;
+ char *newrdn, *p;
+ const char *parentdn = "";
+
+ /* ignore ltdb specials */
+ if (olddn[0] == '@' ||newdn[0] == '@') {
+ return 0;
+ }
+
+ newrdn = ldb_strdup(ldb, newdn);
+ if (!newrdn) {
+ return -1;
+ }
+
+ p = strchr(newrdn, ',');
+ if (p) {
+ *p++ = '\0';
+ parentdn = p;
+ }
+
+ lldb->last_rc = ldap_rename_s(lldb->ldap, olddn, newrdn, parentdn, 1, NULL, NULL);
+ ldb_free(ldb, newrdn);
+ if (lldb->last_rc != LDAP_SUCCESS) {
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/*
delete a record
*/
static int lldb_delete(struct ldb_context *ldb, const char *dn)
@@ -465,6 +500,7 @@ static const struct ldb_backend_ops lldb_ops = {
lldb_add,
lldb_modify,
lldb_delete,
+ lldb_rename,
lldb_errstring
};
@@ -478,7 +514,7 @@ struct ldb_context *lldb_connect(const char *url,
{
struct ldb_context *ldb = NULL;
struct lldb_private *lldb = NULL;
- int i;
+ int i, version = 3;
ldb = calloc(1, sizeof(struct ldb_context));
if (!ldb) {
@@ -501,6 +537,11 @@ struct ldb_context *lldb_connect(const char *url,
goto failed;
}
+ lldb->last_rc = ldap_set_option(lldb->ldap, LDAP_OPT_PROTOCOL_VERSION, &version);
+ if (lldb->last_rc != LDAP_SUCCESS) {
+ goto failed;
+ }
+
ldb->ops = &lldb_ops;
ldb->private_data = lldb;