summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2012-04-04 18:55:40 +0200
committerAndrew Bartlett <abartlet@samba.org>2012-04-11 12:50:16 +1000
commit3fa5f84d2f7bdd3747ea14453fc49eb6931eeedf (patch)
tree3876653102c8225d5f0820b211d76fff0d088f49 /source4/dsdb
parentba96b2491e106dd9035d3b3b1f95cb81412e0847 (diff)
downloadsamba-3fa5f84d2f7bdd3747ea14453fc49eb6931eeedf.tar.gz
samba-3fa5f84d2f7bdd3747ea14453fc49eb6931eeedf.tar.bz2
samba-3fa5f84d2f7bdd3747ea14453fc49eb6931eeedf.zip
s4:dsdb - introduce a only constant-time "get_last_structural_class()" call
With the redesign of the previous patches this has become possible.
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/descriptor.c6
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass.c9
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema.c40
3 files changed, 18 insertions, 37 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/descriptor.c b/source4/dsdb/samdb/ldb_modules/descriptor.c
index f2afe742af..0a4b1da39f 100644
--- a/source4/dsdb/samdb/ldb_modules/descriptor.c
+++ b/source4/dsdb/samdb/ldb_modules/descriptor.c
@@ -542,8 +542,7 @@ static int descriptor_add(struct ldb_module *module, struct ldb_request *req)
return ldb_operr(ldb);
}
- objectclass = get_last_structural_class(schema, objectclass_element,
- true);
+ objectclass = get_last_structural_class(schema, objectclass_element);
if (objectclass == NULL) {
return ldb_operr(ldb);
}
@@ -661,8 +660,7 @@ static int descriptor_modify(struct ldb_module *module, struct ldb_request *req)
return ldb_operr(ldb);
}
- objectclass = get_last_structural_class(schema, objectclass_element,
- true);
+ objectclass = get_last_structural_class(schema, objectclass_element);
if (objectclass == NULL) {
return ldb_operr(ldb);
}
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c
index b8422ee86e..033330c86c 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass.c
@@ -470,8 +470,7 @@ static int objectclass_do_add(struct oc_context *ac)
* unrelated structural classes
*/
objectclass = get_last_structural_class(ac->schema,
- objectclass_element,
- true);
+ objectclass_element);
if (objectclass == NULL) {
ldb_asprintf_errstring(ldb,
"Failed to find a structural class for %s",
@@ -955,8 +954,7 @@ static int objectclass_do_mod(struct oc_context *ac)
* Get the new top-most structural object class and check for
* unrelated structural classes
*/
- objectclass = get_last_structural_class(ac->schema, oc_el_entry,
- true);
+ objectclass = get_last_structural_class(ac->schema, oc_el_entry);
if (objectclass == NULL) {
ldb_set_errstring(ldb,
"objectclass: cannot delete all structural objectclasses!");
@@ -1132,8 +1130,7 @@ static int objectclass_do_rename2(struct oc_context *ac)
/* existing entry without a valid object class? */
return ldb_operr(ldb);
}
- objectclass = get_last_structural_class(ac->schema, oc_el_entry,
- false);
+ objectclass = get_last_structural_class(ac->schema, oc_el_entry);
if (objectclass == NULL) {
/* existing entry without a valid object class? */
return ldb_operr(ldb);
diff --git a/source4/dsdb/samdb/ldb_modules/schema.c b/source4/dsdb/samdb/ldb_modules/schema.c
index d24d388d25..333fb1b0a6 100644
--- a/source4/dsdb/samdb/ldb_modules/schema.c
+++ b/source4/dsdb/samdb/ldb_modules/schema.c
@@ -31,43 +31,29 @@
/*
* This function determines the (last) structural or 88 object class of a passed
- * "objectClass" attribute.
- * Without schema this does not work and hence NULL is returned. If the
- * "objectClass" attribute has already been sorted then only a check on the
- * last value is necessary (MS-ADTS 3.1.1.1.4)
+ * "objectClass" attribute - per MS-ADTS 3.1.1.1.4 this is the last value.
+ * Without schema this does not work and hence NULL is returned.
*/
const struct dsdb_class *get_last_structural_class(const struct dsdb_schema *schema,
- const struct ldb_message_element *element,
- bool sorted)
+ const struct ldb_message_element *element)
{
- const struct dsdb_class *last_class = NULL;
- unsigned int i = 0;
+ const struct dsdb_class *last_class;
if (schema == NULL) {
return NULL;
}
- if (sorted && (element->num_values > 1)) {
- i = element->num_values - 1;
+ if (element->num_values == 0) {
+ return NULL;
}
- for (; i < element->num_values; i++){
- const struct dsdb_class *tmp_class = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &element->values[i]);
-
- if(tmp_class == NULL) {
- continue;
- }
-
- if(tmp_class->objectClassCategory > 1) {
- continue;
- }
-
- if (!last_class) {
- last_class = tmp_class;
- } else {
- if (tmp_class->subClass_order > last_class->subClass_order)
- last_class = tmp_class;
- }
+ last_class = dsdb_class_by_lDAPDisplayName_ldb_val(schema,
+ &element->values[element->num_values-1]);
+ if (last_class == NULL) {
+ return NULL;
+ }
+ if (last_class->objectClassCategory > 1) {
+ return NULL;
}
return last_class;