1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

s4:dsdb - introduce a only constant-time "get_last_structural_class()" call

With the redesign of the previous patches this has become possible.
This commit is contained in:
Matthias Dieter Wallnöfer 2012-04-04 18:55:40 +02:00 committed by Andrew Bartlett
parent ba96b2491e
commit 3fa5f84d2f
3 changed files with 18 additions and 37 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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;