summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-10-12 06:10:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:41 -0500
commita599edf04cbdeef9014923ba0d3713b8ff84f266 (patch)
tree3754385df962fd26fe8bd0e16f3c3b706a385c24 /source4/lib/ldb/modules
parent655138602c75925a6d655841ee80cf5346a9a399 (diff)
downloadsamba-a599edf04cbdeef9014923ba0d3713b8ff84f266.tar.gz
samba-a599edf04cbdeef9014923ba0d3713b8ff84f266.tar.bz2
samba-a599edf04cbdeef9014923ba0d3713b8ff84f266.zip
r10913: This patch isn't as big as it looks ...
most of the changes are fixes to make all the ldb code compile without warnings on gcc4. Unfortunately That required a lot of casts :-( I have also added the start of an 'operational' module, which will replace the timestamp module, plus add support for some other operational attributes In ldb_msg_*() I added some new utility functions to make the operational module sane, and remove the 'ldb' argument from the ldb_msg_add_*() functions. That argument was only needed back in the early days of ldb when we didn't use the hierarchical talloc and thus needed a place to get the allocation function from. Now its just a pain to pass around everywhere. Also added a ldb_debug_set() function that calls ldb_debug() plus sets the result using ldb_set_errstring(). That saves on some awkward coding in a few places. (This used to be commit f6818daecca95760c12f79fd307770cbe3346f57)
Diffstat (limited to 'source4/lib/ldb/modules')
-rw-r--r--source4/lib/ldb/modules/ldb_map.c37
-rw-r--r--source4/lib/ldb/modules/operational.c217
-rw-r--r--source4/lib/ldb/modules/rdn_name.c6
-rw-r--r--source4/lib/ldb/modules/schema.c81
-rw-r--r--source4/lib/ldb/modules/timestamps.c2
5 files changed, 267 insertions, 76 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 246fc5709d..48aa7e2ef5 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -625,7 +625,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
for (j = 0; j < oldelm->num_values; j++)
elm->values[j] = ldb_val_dup(elm, &oldelm->values[j]);
- ldb_msg_add(module->ldb, msg, elm, oldelm->flags);
+ ldb_msg_add(msg, elm, oldelm->flags);
break;
case MAP_CONVERT:
@@ -642,7 +642,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
for (j = 0; j < oldelm->num_values; j++)
elm->values[j] = attr->u.convert.convert_remote(module, elm, &oldelm->values[j]);
- ldb_msg_add(module->ldb, msg, elm, oldelm->flags);
+ ldb_msg_add(msg, elm, oldelm->flags);
break;
case MAP_KEEP:
@@ -659,7 +659,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
elm->name = talloc_strdup(elm, oldelm->name);
- ldb_msg_add(module->ldb, msg, elm, oldelm->flags);
+ ldb_msg_add(msg, elm, oldelm->flags);
break;
case MAP_GENERATE:
@@ -671,7 +671,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
if (!elm)
continue;
- ldb_msg_add(module->ldb, msg, elm, elm->flags);
+ ldb_msg_add(msg, elm, elm->flags);
break;
default:
ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Unknown attr->type for %s", attr->local_name);
@@ -750,9 +750,11 @@ static int map_search_fb(struct ldb_module *module, const struct ldb_dn *base,
{
int ret;
struct ldb_parse_tree t_and, t_not, t_present, *childs[2];
+ char *ismapped;
t_present.operation = LDB_OP_PRESENT;
- t_present.u.present.attr = talloc_strdup(NULL, "isMapped");
+ ismapped = talloc_strdup(module, "isMapped");
+ t_present.u.present.attr = ismapped;
t_not.operation = LDB_OP_NOT;
t_not.u.isnot.child = &t_present;
@@ -765,7 +767,7 @@ static int map_search_fb(struct ldb_module *module, const struct ldb_dn *base,
ret = ldb_next_search_bytree(module, base, scope, &t_and, attrs, res);
- talloc_free(t_present.u.present.attr);
+ talloc_free(ismapped);
return ret;
}
@@ -847,7 +849,7 @@ static int map_search_mp(struct ldb_module *module, const struct ldb_dn *base,
int j;
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "Extra data found for remote DN: %s", ldb_dn_linearize(merged, merged->dn));
for (j = 0; j < extrares[0]->num_elements; j++) {
- ldb_msg_add(module->ldb, merged, &(extrares[0]->elements[j]), extrares[0]->elements[j].flags);
+ ldb_msg_add(merged, &(extrares[0]->elements[j]), extrares[0]->elements[j].flags);
}
}
@@ -941,7 +943,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
fb->dn = talloc_reference(fb, msg->dn);
/* We add objectClass, so 'top' should be no problem */
- ldb_msg_add_string(module->ldb, mp, "objectClass", "top");
+ ldb_msg_add_string(mp, "objectClass", "top");
/* make a list of remote objectclasses that can be used
* given the attributes that are available and add to
@@ -971,7 +973,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
/* Apparently, it contains all required elements */
if (has_musts && has_baseclasses) {
- ldb_msg_add_string(module->ldb, mp, "objectClass", privdat->objectclass_maps[i].remote_name);
+ ldb_msg_add_string(mp, "objectClass", privdat->objectclass_maps[i].remote_name);
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "map_add: Adding objectClass %s", privdat->objectclass_maps[i].remote_name);
}
}
@@ -1071,7 +1073,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
continue;
}
- ldb_msg_add(module->ldb, mp, elm, 0);
+ ldb_msg_add(mp, elm, 0);
mapped++;
}
@@ -1083,7 +1085,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
elm->values = talloc_reference(elm, msg->elements[i].values);
elm->name = talloc_strdup(elm, msg->elements[i].name);
- ldb_msg_add(module->ldb, fb, elm, 0);
+ ldb_msg_add(fb, elm, 0);
}
}
@@ -1095,7 +1097,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_map_add: Added mapped record");
- ldb_msg_add_string(module->ldb, fb, "isMapped", "TRUE");
+ ldb_msg_add_string(fb, "isMapped", "TRUE");
ret = ldb_next_add_record(module, fb);
if (ret == -1) {
ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Adding fallback record failed: %s", ldb_errstring(module->ldb));
@@ -1159,7 +1161,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->values[j] = msg->elements[i].values[j];
}
- ldb_msg_add(module->ldb, mp, elm, msg->elements[i].flags);
+ ldb_msg_add(mp, elm, msg->elements[i].flags);
mapped++;
continue;
@@ -1176,7 +1178,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->values[j] = attr->u.convert.convert_local(module, mp, &msg->elements[i].values[j]);
}
- ldb_msg_add(module->ldb, mp, elm, msg->elements[i].flags);
+ ldb_msg_add(mp, elm, msg->elements[i].flags);
mapped++;
continue;
@@ -1191,7 +1193,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->name = talloc_strdup(elm, msg->elements[i].name);
- ldb_msg_add(module->ldb, mp, elm, msg->elements[i].flags);
+ ldb_msg_add(mp, elm, msg->elements[i].flags);
mapped++;
continue;
@@ -1209,8 +1211,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->values = talloc_reference(elm, msg->elements[i].values);
elm->name = talloc_strdup(elm, msg->elements[i].name);
- ldb_msg_add(module->ldb, fb, elm, msg->elements[i].flags);
-
+ ldb_msg_add(fb, elm, msg->elements[i].flags);
}
}
@@ -1218,7 +1219,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "Modifying fallback record with %d elements", fb->num_elements);
fb_ret = ldb_next_modify_record(module, fb);
if (fb_ret == -1) {
- ldb_msg_add_string(module->ldb, fb, "isMapped", "TRUE");
+ ldb_msg_add_string(fb, "isMapped", "TRUE");
fb_ret = ldb_next_add_record(module, fb);
}
} else fb_ret = 0;
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
new file mode 100644
index 0000000000..911bc087ca
--- /dev/null
+++ b/source4/lib/ldb/modules/operational.c
@@ -0,0 +1,217 @@
+/*
+ ldb database library
+
+ Copyright (C) Andrew Tridgell 2005
+
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/*
+ handle operational attributes
+ */
+
+/*
+ createTimestamp: HIDDEN, searchable, ldaptime, alias for whenCreated
+ modifyTimestamp: HIDDEN, searchable, ldaptime, alias for whenChanged
+
+ for the above two, we do the search as normal, and if
+ createTimestamp or modifyTimestamp is asked for, then do
+ additional searches for whenCreated and whenChanged and fill in
+ the resulting values
+
+ we also need to replace these with the whenCreated/whenChanged
+ equivalent in the search expression trees
+
+ whenCreated: not-HIDDEN, CONSTRUCTED, SEARCHABLE
+ whenChanged: not-HIDDEN, CONSTRUCTED, SEARCHABLE
+
+ on init we need to setup attribute handlers for these so
+ comparisons are done correctly. The resolution is 1 second.
+
+ on add we need to add both the above, for current time
+
+ on modify we need to change whenChanged
+
+
+ subschemaSubentry: HIDDEN, not-searchable,
+ points at DN CN=Aggregate,CN=Schema,CN=Configuration,$BASEDN
+
+ for this one we do the search as normal, then add the static
+ value if requested. How do we work out the $BASEDN from inside a
+ module?
+
+
+ structuralObjectClass: HIDDEN, CONSTRUCTED, not-searchable. always same as objectclass?
+
+ for this one we do the search as normal, then if requested ask
+ for objectclass, change the attribute name, and add it
+
+ attributeTypes: in schema only
+ objectClasses: in schema only
+ matchingRules: in schema only
+ matchingRuleUse: in schema only
+ creatorsName: not supported by w2k3?
+ modifiersName: not supported by w2k3?
+*/
+
+
+#include "includes.h"
+#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_private.h"
+#include <time.h>
+
+/*
+ a list of attribute names that should be substituted in the parse
+ tree before the search is done
+*/
+static const struct {
+ const char *attr;
+ const char *replace;
+} parse_tree_sub[] = {
+ { "createTimestamp", "whenCreated" },
+ { "modifyTimestamp", "whenChanged" }
+};
+
+/*
+ a list of attribute names that are hidden, but can be searched for
+ using another (non-hidden) name to produce the correct result
+*/
+static const struct {
+ const char *attr;
+ const char *replace;
+} search_sub[] = {
+ { "createTimestamp", "whenCreated" },
+ { "modifyTimestamp", "whenChanged" },
+ { "structuralObjectClass", "objectClass" }
+};
+
+/*
+ hook search operations
+*/
+static int operational_search_bytree(struct ldb_module *module,
+ const struct ldb_dn *base,
+ enum ldb_scope scope, struct ldb_parse_tree *tree,
+ const char * const *attrs,
+ struct ldb_message ***res)
+{
+ int i, r, a;
+ int ret;
+ const char **search_attrs = NULL;
+
+ /* replace any attributes in the parse tree that are
+ searchable, but are stored using a different name in the
+ backend */
+ for (i=0;i<ARRAY_SIZE(parse_tree_sub);i++) {
+ ldb_parse_tree_attr_replace(tree,
+ parse_tree_sub[i].attr,
+ parse_tree_sub[i].replace);
+ }
+
+ /* in the list of attributes we are looking for, rename any
+ attributes to the alias for any hidden attributes that can
+ be fetched directly using non-hidden names */
+ for (i=0;i<ARRAY_SIZE(search_sub);i++) {
+ for (a=0;attrs[a];a++) {
+ if (ldb_attr_cmp(attrs[a], search_sub[i].attr) == 0) {
+ if (!search_attrs) {
+ search_attrs = ldb_attr_list_copy(module, attrs);
+ if (search_attrs == NULL) {
+ goto oom;
+ }
+ }
+ search_attrs[a] = search_sub[i].replace;
+ }
+ }
+ }
+
+
+ /* perform the search */
+ ret = ldb_next_search_bytree(module, base, scope, tree,
+ search_attrs?search_attrs:attrs, res);
+ if (ret <= 0) {
+ return ret;
+ }
+
+ /* for each record returned see if we have added any
+ attributes to the search, and if we have then either copy
+ them (if the aliased name was also asked for) or rename
+ them (if the aliased entry was not asked for) */
+ for (r=0;r<ret;r++) {
+ for (i=0;i<ARRAY_SIZE(search_sub);i++) {
+ for (a=0;attrs[a];a++) {
+ if (ldb_attr_cmp(attrs[a], search_sub[i].attr) != 0) {
+ continue;
+ }
+ if (ldb_attr_in_list(attrs, search_sub[i].replace) ||
+ ldb_attr_in_list(attrs, "*")) {
+ if (ldb_msg_copy_attr((*res)[r],
+ search_sub[i].replace,
+ search_sub[i].attr) != 0) {
+ goto oom;
+ }
+ } else {
+ ldb_msg_rename_attr((*res)[r],
+ search_sub[i].replace,
+ search_sub[i].attr);
+ }
+ }
+ }
+ }
+
+ /* all done */
+ talloc_free(search_attrs);
+ return ret;
+
+oom:
+ talloc_free(search_attrs);
+ ldb_oom(module->ldb);
+ return -1;
+}
+
+
+static const struct ldb_module_ops operational_ops = {
+ .name = "operational",
+ .search_bytree = operational_search_bytree,
+#if 0
+ .add_record = operational_add_record,
+ .modify_record = operational_modify_record,
+ .rename_record = operational_rename_record
+#endif
+};
+
+
+/* the init function */
+#ifdef HAVE_DLOPEN_DISABLED
+ struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
+#else
+struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[])
+#endif
+{
+ struct ldb_module *ctx;
+
+ ctx = talloc(ldb, struct ldb_module);
+ if (!ctx)
+ return NULL;
+
+ ctx->private_data = NULL;
+ ctx->ldb = ldb;
+ ctx->prev = ctx->next = NULL;
+ ctx->ops = &operational_ops;
+
+ return ctx;
+}
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 40ff75744e..c8f2ebaabd 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -97,7 +97,7 @@ static int rdn_name_add_record(struct ldb_module *module, const struct ldb_messa
return -1;
}
- if (ldb_msg_add_value(module->ldb, msg2, "name", &rdn->value) != 0) {
+ if (ldb_msg_add_value(msg2, "name", &rdn->value) != 0) {
talloc_free(msg2);
return -1;
}
@@ -105,7 +105,7 @@ static int rdn_name_add_record(struct ldb_module *module, const struct ldb_messa
attribute = rdn_name_find_attribute(msg2, rdn->name);
if (!attribute) {
- if (ldb_msg_add_value(module->ldb, msg2, rdn->name, &rdn->value) != 0) {
+ if (ldb_msg_add_value(msg2, rdn->name, &rdn->value) != 0) {
talloc_free(msg2);
return -1;
}
@@ -175,7 +175,7 @@ static int rdn_name_modify_record(struct ldb_module *module, const struct ldb_me
return -1;
}
- if (ldb_msg_add_value(module->ldb, msg2, "name", &rdn->value) != 0) {
+ if (ldb_msg_add_value(msg2, "name", &rdn->value) != 0) {
talloc_free(msg2);
return -1;
}
diff --git a/source4/lib/ldb/modules/schema.c b/source4/lib/ldb/modules/schema.c
index 0cae110487..27177116c2 100644
--- a/source4/lib/ldb/modules/schema.c
+++ b/source4/lib/ldb/modules/schema.c
@@ -106,7 +106,7 @@ static int get_msg_attributes(struct schema_structures *ss, const struct ldb_mes
}
for (j = 0, cnum = ss->objectclasses.num; j < msg->elements[i].num_values; j++) {
- ss->objectclasses.attr[cnum+j].name = msg->elements[i].values[j].data;
+ ss->objectclasses.attr[cnum+j].name = (char *)msg->elements[i].values[j].data;
ss->objectclasses.attr[cnum+j].flags = msg->elements[i].flags & flag_mask;
}
ss->objectclasses.num += msg->elements[i].num_values;
@@ -164,14 +164,15 @@ static int add_attribute_uniq(void *mem_ctx, struct schema_attribute_list *list,
for (c = 0; c < list->num; c++) {
len = strlen(list->attr[c].name);
if (len == el->values[i].length) {
- if (ldb_attr_cmp(list->attr[c].name, el->values[i].data) == 0) {
+ if (ldb_attr_cmp(list->attr[c].name,
+ (char *)el->values[i].data) == 0) {
found = 1;
break;
}
}
}
if (!found) {
- list->attr[j + list->num].name = el->values[i].data;
+ list->attr[j + list->num].name = (char *)el->values[i].data;
list->attr[j + list->num].flags = flags;
j++;
}
@@ -187,7 +188,6 @@ static int add_attribute_uniq(void *mem_ctx, struct schema_attribute_list *list,
static int get_attr_list_recursive(struct ldb_module *module, struct schema_structures *schema_struct)
{
struct ldb_message **srch;
- char *error_string;
int i, j;
int ret;
@@ -209,21 +209,18 @@ static int get_attr_list_recursive(struct ldb_module *module, struct schema_stru
talloc_steal(schema_struct, srch);
if (ret <= 0) {
- /* Schema DB Error: Error occurred retrieving Object Class Description */
- error_string = talloc_asprintf(module, "Error retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ /* Schema DB Error: Error occurred retrieving
+ Object Class Description */
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "Error retrieving Objectclass %s.\n",
+ schema_struct->objectclasses.attr[i].name);
return -1;
}
if (ret > 1) {
/* Schema DB Error: Too Many Records */
- error_string = talloc_asprintf(module, "Too many records found retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "Too many records found retrieving Objectclass %s.\n",
+ schema_struct->objectclasses.attr[i].name);
return -1;
}
@@ -294,7 +291,6 @@ static int schema_search_bytree(struct ldb_module *module, const struct ldb_dn *
static int schema_add_record(struct ldb_module *module, const struct ldb_message *msg)
{
struct schema_structures *entry_structs;
- char *error_string;
unsigned int i;
int ret;
@@ -338,13 +334,9 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
entry_structs->required_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The required_attrs attribute %s is missing.\n",
- entry_structs->required_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The required_attrs attribute %s is missing.\n",
+ entry_structs->required_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -363,13 +355,9 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
entry_structs->entry_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The attribute %s is not referenced by any objectclass.\n",
- entry_structs->entry_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The attribute %s is not referenced by any objectclass.\n",
+ entry_structs->entry_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -385,7 +373,6 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
static int schema_modify_record(struct ldb_module *module, const struct ldb_message *msg)
{
struct schema_structures *entry_structs;
- char *error_string;
unsigned int i;
int ret;
@@ -437,13 +424,9 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
entry_structs->required_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The required_attrs attribute %s is missing.\n",
- entry_structs->required_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The required_attrs attribute %s is missing.\n",
+ entry_structs->required_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -451,14 +434,9 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
/* check we are not trying to delete a required attribute */
/* TODO: consider multivalued attrs */
if ((attr->flags & SCHEMA_FLAG_MOD_DELETE) != 0) {
- error_string = talloc_asprintf(module,
- "Trying to delete the required attribute %s.\n",
- attr->name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
-
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "Trying to delete the required attribute %s.\n",
+ attr->name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -477,14 +455,9 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
entry_structs->entry_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The attribute %s is not referenced by any objectclass.\n",
- entry_structs->entry_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
-
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The attribute %s is not referenced by any objectclass.\n",
+ entry_structs->entry_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
diff --git a/source4/lib/ldb/modules/timestamps.c b/source4/lib/ldb/modules/timestamps.c
index 13e9c2ccc4..8451da2445 100644
--- a/source4/lib/ldb/modules/timestamps.c
+++ b/source4/lib/ldb/modules/timestamps.c
@@ -58,7 +58,7 @@ static int add_time_element(struct ldb_module *module, struct ldb_message *msg,
}
}
- if (ldb_msg_add_string(module->ldb, msg, attr_name, time_string) != 0) {
+ if (ldb_msg_add_string(msg, attr_name, time_string) != 0) {
return -1;
}