From 25402e06bcdf98e346fdbbfa7e8740504329b42f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 26 Mar 2013 11:51:38 +1100 Subject: 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 --- source4/dsdb/repl/replicated_objects.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'source4') 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); -- cgit