s4:dsdb/samdb/ldb_modules/schema.c - inline "get_oc_guid_from_message()" to its only...
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 4 Apr 2012 19:58:04 +0000 (21:58 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 11 Apr 2012 02:50:16 +0000 (12:50 +1000)
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
source4/dsdb/samdb/ldb_modules/schema.c

index 6971fbf4ee027a0fbf6b11c88d49470a93d260f8..bce878501a03c07b5c135d9dafca1e7b0973a9e5 100644 (file)
@@ -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");
index 333fb1b0a68bbe2731a07d8f2ba398599ae3fe09..233816f99a2f116186432e27120265a7a44764bc 100644 (file)
@@ -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);
-}
-