From 17f1efcff60aa1ee9dac0ecab99f3b3e4246ecbc Mon Sep 17 00:00:00 2001 From: Brendan Powers Date: Mon, 14 Dec 2009 20:36:44 -0500 Subject: [PATCH] s4-dsdb: Move get_last_structural class from descriptor.c to util.c so it can be used by objectclass.c s4-dsdb: get_last_structural_class now ignores AUX classes, because they are not structural --- source4/dsdb/samdb/ldb_modules/descriptor.c | 17 +---------------- source4/dsdb/samdb/ldb_modules/util.c | 27 +++++++++++++++++++++++++++ source4/dsdb/samdb/ldb_modules/util.h | 1 + 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/descriptor.c b/source4/dsdb/samdb/ldb_modules/descriptor.c index 03cb1ff..8df93dd 100644 --- a/source4/dsdb/samdb/ldb_modules/descriptor.c +++ b/source4/dsdb/samdb/ldb_modules/descriptor.c @@ -41,6 +41,7 @@ #include "libcli/security/security.h" #include "auth/auth.h" #include "param/param.h" +#include "util.h" struct descriptor_data { int _dummy; @@ -56,22 +57,6 @@ struct descriptor_context { int (*step_fn)(struct descriptor_context *); }; -static const struct dsdb_class * get_last_structural_class(const struct dsdb_schema *schema, struct ldb_message_element *element) -{ - const struct dsdb_class *last_class = NULL; - int i; - for (i = 0; i < element->num_values; i++){ - if (!last_class) { - last_class = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &element->values[i]); - } else { - const struct dsdb_class *tmp_class = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &element->values[i]); - if (tmp_class->subClass_order > last_class->subClass_order) - last_class = tmp_class; - } - } - return last_class; -} - struct dom_sid *get_default_ag(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct security_token *token, diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c index fe6ddfa..ed65ca4 100644 --- a/source4/dsdb/samdb/ldb_modules/util.c +++ b/source4/dsdb/samdb/ldb_modules/util.c @@ -24,6 +24,7 @@ #include "ldb_module.h" #include "dsdb/samdb/ldb_modules/util.h" #include "dsdb/samdb/samdb.h" +#include "util.h" int dsdb_module_search_handle_flags(struct ldb_module *module, struct ldb_request *req, int dsdb_flags) { @@ -205,3 +206,29 @@ int dsdb_module_search(struct ldb_module *module, return ret; } +const struct dsdb_class * get_last_structural_class(const struct dsdb_schema *schema,const struct ldb_message_element *element) +{ + const struct dsdb_class *last_class = NULL; + int i; + + for (i = 0; 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 == 3) { + continue; + } + + if (!last_class) { + last_class = tmp_class; + } else { + if (tmp_class->subClass_order > last_class->subClass_order) + last_class = tmp_class; + } + } + + return last_class; +} diff --git a/source4/dsdb/samdb/ldb_modules/util.h b/source4/dsdb/samdb/ldb_modules/util.h index 56db27d..41ec873 100644 --- a/source4/dsdb/samdb/ldb_modules/util.h +++ b/source4/dsdb/samdb/ldb_modules/util.h @@ -19,6 +19,7 @@ along with this program. If not, see . */ +struct dsdb_schema; /* predeclare schema struct */ #include "dsdb/samdb/ldb_modules/util_proto.h" #define DSDB_SEARCH_SEARCH_ALL_PARTITIONS 0x0001 -- 1.5.4.3