s4-schema: keep track of the timestamp of the most recently changed/created object
authorMatthieu Patou <mat@matws.net>
Tue, 22 May 2012 23:25:50 +0000 (16:25 -0700)
committerMatthieu Patou <mat@matws.net>
Sat, 23 Jun 2012 06:22:03 +0000 (23:22 -0700)
source4/dsdb/schema/schema.h
source4/dsdb/schema/schema_init.c
source4/dsdb/schema/schema_set.c

index d3dd035e0132b41e7656275d8c8c07172e8362ac..b2f7bac1d1869f4cf5ea1c6b50dedfbbcb3b429d 100644 (file)
@@ -245,6 +245,7 @@ struct dsdb_schema {
        struct ldb_module *loaded_from_module;
        struct dsdb_schema *(*refresh_fn)(struct ldb_module *module, struct dsdb_schema *schema, bool is_global_schema);
        bool refresh_in_progress;
+       time_t ts_last_change;
        time_t last_refresh;
        /* an 'opaque' sequence number that the reload function may also wish to use */
        uint64_t reload_seq_number;
index 2db708d2df5e74011bc4dece315943fab55c24f4..c0318cf9c43fc2b1f19bb7e9d9cc61731151c648 100644 (file)
@@ -807,6 +807,7 @@ int dsdb_load_ldb_results_into_schema(TALLOC_CTX *mem_ctx, struct ldb_context *l
 {
        unsigned int i;
 
+       schema->ts_last_change = 0;
        for (i=0; i < attrs_class_res->count; i++) {
                WERROR status = dsdb_schema_set_el_from_ldb_msg(ldb, schema, attrs_class_res->msgs[i]);
                if (!W_ERROR_IS_OK(status)) {
index 8a4361058b1838a93917985a14083f9afb00a22e..286a8a3f23f5f4c8b966dfdb551b3f8832c4d3b7 100644 (file)
@@ -665,6 +665,8 @@ int dsdb_schema_fill_extended_dn(struct ldb_context *ldb, struct dsdb_schema *sc
 WERROR dsdb_schema_set_el_from_ldb_msg(struct ldb_context *ldb, struct dsdb_schema *schema,
                                       struct ldb_message *msg)
 {
+       const char* tstring;
+       time_t ts;
        if (samdb_find_attribute(ldb, msg,
                                 "objectclass", "attributeSchema") != NULL) {
                return dsdb_set_attribute_from_ldb(ldb, schema, msg);
@@ -672,7 +674,14 @@ WERROR dsdb_schema_set_el_from_ldb_msg(struct ldb_context *ldb, struct dsdb_sche
                                 "objectclass", "classSchema") != NULL) {
                return dsdb_set_class_from_ldb(schema, msg);
        }
-
+       tstring = ldb_msg_find_attr_as_string(msg, "whenChanged", NULL);
+       /* keep a trace of the ts of the most recently changed object */
+       if (tstring) {
+               ts = ldb_string_to_time(tstring);
+               if (ts > schema->ts_last_change) {
+                       schema->ts_last_change = ts;
+               }
+       }
        /* Don't fail on things not classes or attributes */
        return WERR_OK;
 }
@@ -753,6 +762,7 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb,
                goto failed;
        }
 
+       schema->ts_last_change = 0;
        /* load the attribute and class definitions out of df */
        while ((ldif = ldb_ldif_read_string(ldb, &df))) {
                talloc_steal(mem_ctx, ldif);