summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_search.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-20 13:25:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:53:50 -0500
commitf0a8f718ff474009300af6746fa0fbb61c649ea9 (patch)
tree47c1c29215336691e96c2d2526883455f108d585 /source4/lib/ldb/ldb_tdb/ldb_search.c
parent0a083d1e08a7f7dfcf8abf5866ceb0eee52509e7 (diff)
downloadsamba-f0a8f718ff474009300af6746fa0fbb61c649ea9.tar.gz
samba-f0a8f718ff474009300af6746fa0fbb61c649ea9.tar.bz2
samba-f0a8f718ff474009300af6746fa0fbb61c649ea9.zip
r792: - changed the ldb ldif_* functions to be in the ldb_ namespace
- added better error reporting in ldbdel - fixed a bug in handling packing of records which contain elements with no values (it caused db corruption) - allow search with "dn" as target attribute (This used to be commit 36575396234e3d35dbd442c8f1ff54a17ae64e64)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_search.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 6b38a28296..d97444a6e8 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -34,6 +34,7 @@
#include "includes.h"
#include "ldb/ldb_tdb/ldb_tdb.h"
+#include "ldb/include/ldb_parse.h"
/*
free a message that has all parts separately allocated
@@ -192,6 +193,31 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_context *ldb,
continue;
}
+ if (ldb_attr_cmp(attrs[i], "dn") == 0) {
+ struct ldb_message_element el2;
+ struct ldb_val val;
+
+ el2.flags = 0;
+ el2.name = ldb_strdup(ldb, "dn");
+ if (!el2.name) {
+ msg_free_all_parts(ldb, ret);
+ ldb_free(ldb, el2.name);
+ return NULL;
+ }
+ el2.num_values = 1;
+ el2.values = &val;
+ val.data = ret->dn;
+ val.length = strlen(ret->dn);
+
+ if (msg_add_element(ldb, ret, &el2) != 0) {
+ msg_free_all_parts(ldb, ret);
+ ldb_free(ldb, el2.name);
+ return NULL;
+ }
+ ldb_free(ldb, el2.name);
+ continue;
+ }
+
el = ldb_msg_find_element(msg, attrs[i]);
if (!el) {
continue;
@@ -290,7 +316,7 @@ int ltdb_search_dn1(struct ldb_context *ldb, const char *dn, struct ldb_message
ret = ltdb_unpack_data(ldb, &tdb_data2, msg);
if (ret == -1) {
- free(tdb_data2.dptr);
+ ldb_free(ldb, tdb_data2.dptr);
return -1;
}