From 83062125e60dd097a1a151fb35467fe55a356780 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Matthias=20Dieter=20Walln=C3=B6fer?= Date: Wed, 4 Apr 2012 21:58:04 +0200 Subject: [PATCH] s4:dsdb/samdb/ldb_modules/schema.c - inline "get_oc_guid_from_message()" to its only user Reduce the number of not to be shared functions in "schema.c". Change it to make use of "get_last_structural_class()". --- source4/dsdb/samdb/ldb_modules/acl.c | 26 ++++++++++++++++++++++--- source4/dsdb/samdb/ldb_modules/schema.c | 15 -------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/acl.c b/source4/dsdb/samdb/ldb_modules/acl.c index 6971fbf4ee0..bce878501a0 100644 --- a/source4/dsdb/samdb/ldb_modules/acl.c +++ b/source4/dsdb/samdb/ldb_modules/acl.c @@ -908,6 +908,26 @@ static int acl_check_password_rights(TALLOC_CTX *mem_ctx, return ret; } +static const struct GUID *get_oc_guid_from_message(const struct dsdb_schema *schema, + struct ldb_message *msg) +{ + struct ldb_message_element *oc_el; + const struct dsdb_class *object_class; + + oc_el = ldb_msg_find_element(msg, "objectClass"); + if (!oc_el) { + return NULL; + } + + object_class = get_last_structural_class(schema, oc_el); + if (object_class == NULL) { + return NULL; + } + + return &object_class->schemaIDGUID; +} + + static int acl_modify(struct ldb_module *module, struct ldb_request *req) { int ret; @@ -973,7 +993,7 @@ static int acl_modify(struct ldb_module *module, struct ldb_request *req) goto success; } - guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]); + guid = get_oc_guid_from_message(schema, acl_res->msgs[0]); if (!guid) { talloc_free(tmp_ctx); return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR, @@ -1247,7 +1267,7 @@ static int acl_rename(struct ldb_module *module, struct ldb_request *req) return ldb_operr(ldb); } - guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]); + guid = get_oc_guid_from_message(schema, acl_res->msgs[0]); if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP, &root, &new_node)) { talloc_free(tmp_ctx); @@ -1315,7 +1335,7 @@ static int acl_rename(struct ldb_module *module, struct ldb_request *req) /* new parent should have create child */ root = NULL; new_node = NULL; - guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]); + guid = get_oc_guid_from_message(schema, acl_res->msgs[0]); if (!guid) { ldb_asprintf_errstring(ldb_module_get_ctx(module), "acl:renamed object has no object class\n"); diff --git a/source4/dsdb/samdb/ldb_modules/schema.c b/source4/dsdb/samdb/ldb_modules/schema.c index 333fb1b0a68..233816f99a2 100644 --- a/source4/dsdb/samdb/ldb_modules/schema.c +++ b/source4/dsdb/samdb/ldb_modules/schema.c @@ -59,19 +59,4 @@ const struct dsdb_class *get_last_structural_class(const struct dsdb_schema *sch return last_class; } -const struct GUID *get_oc_guid_from_message(struct ldb_module *module, - const struct dsdb_schema *schema, - struct ldb_message *msg) -{ - struct ldb_message_element *oc_el; - - oc_el = ldb_msg_find_element(msg, "objectClass"); - if (!oc_el) { - return NULL; - } - - return class_schemaid_guid_by_lDAPDisplayName(schema, - (char *)oc_el->values[oc_el->num_values-1].data); -} - -- 2.34.1