summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2013-03-26 11:51:38 +1100
committerStefan Metzmacher <metze@samba.org>2013-05-16 19:02:03 +0200
commit25402e06bcdf98e346fdbbfa7e8740504329b42f (patch)
treeee3580a8d98e91abc1d65f034cce7cf0ed59e315
parent34820602715cc8936179091e188993f7a42808ac (diff)
downloadsamba-25402e06bcdf98e346fdbbfa7e8740504329b42f.tar.gz
samba-25402e06bcdf98e346fdbbfa7e8740504329b42f.tar.bz2
samba-25402e06bcdf98e346fdbbfa7e8740504329b42f.zip
dsdb-repl: Allow the name attribute (and name-based schema lookups) to be skipped in dsdb_repl_make_working_schema()
This allows us to use a schema that may only be valid for attributeID based lookups, during the schema load. Andrew Bartlett Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source4/dsdb/repl/replicated_objects.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c
index 44c5de89ae..29b494b816 100644
--- a/source4/dsdb/repl/replicated_objects.c
+++ b/source4/dsdb/repl/replicated_objects.c
@@ -209,10 +209,6 @@ WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
NTTIME whenChanged = 0;
time_t whenChanged_t;
const char *whenChanged_s;
- const char *rdn_name = NULL;
- const struct ldb_val *rdn_value = NULL;
- const struct dsdb_attribute *rdn_attr = NULL;
- uint32_t rdn_attid;
struct drsuapi_DsReplicaAttribute *name_a = NULL;
struct drsuapi_DsReplicaMetaData *name_d = NULL;
struct replPropertyMetaData1 *rdn_m = NULL;
@@ -248,14 +244,6 @@ WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
msg->dn = ldb_dn_new(msg, ldb, in->object.identifier->dn);
W_ERROR_HAVE_NO_MEMORY(msg->dn);
- rdn_name = ldb_dn_get_rdn_name(msg->dn);
- rdn_attr = dsdb_attribute_by_lDAPDisplayName(schema, rdn_name);
- if (!rdn_attr) {
- return WERR_FOOBAR;
- }
- rdn_attid = rdn_attr->attributeID_id;
- rdn_value = ldb_dn_get_rdn_val(msg->dn);
-
msg->num_elements = in->object.attribute_ctr.num_attributes;
msg->elements = talloc_array(msg, struct ldb_message_element,
msg->num_elements + 1); /* +1 because of the RDN attribute */
@@ -331,6 +319,25 @@ WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
if (rdn_m) {
struct ldb_message_element *el;
+ const char *rdn_name = NULL;
+ const struct ldb_val *rdn_value = NULL;
+ const struct dsdb_attribute *rdn_attr = NULL;
+ uint32_t rdn_attid;
+
+ /*
+ * We only need the schema calls for the RDN in this
+ * codepath, and by doing this we avoid needing to
+ * have the dsdb_attribute_by_lDAPDisplayName accessor
+ * working during the schema load.
+ */
+ rdn_name = ldb_dn_get_rdn_name(msg->dn);
+ rdn_attr = dsdb_attribute_by_lDAPDisplayName(schema, rdn_name);
+ if (!rdn_attr) {
+ return WERR_FOOBAR;
+ }
+ rdn_attid = rdn_attr->attributeID_id;
+ rdn_value = ldb_dn_get_rdn_val(msg->dn);
+
el = ldb_msg_find_element(msg, rdn_attr->lDAPDisplayName);
if (!el) {
ret = ldb_msg_add_value(msg, rdn_attr->lDAPDisplayName, rdn_value, NULL);