repl: Set GET_ALL_GROUP_MEMBERSHIP flag in the drepl server
[nivanova/samba-autobuild/.git] / source4 / dsdb / kcc / kcc_periodic.c
index ef114fd13cbdda54a149eff5f40983bc579c5a72..fa19ba7efc5699e396c27cceff815a9ba2e33dfd 100644 (file)
@@ -178,7 +178,6 @@ uint32_t kccsrv_replica_flags(struct kccsrv_service *s)
                        DRSUAPI_DRS_PER_SYNC |
                        DRSUAPI_DRS_ADD_REF |
                        DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING |
-                       DRSUAPI_DRS_GET_ALL_GROUP_MEMBERSHIP |
                        DRSUAPI_DRS_NONGC_RO_REP;
        }
        return DRSUAPI_DRS_INIT_SYNC |
@@ -601,10 +600,47 @@ WERROR kccsrv_periodic_schedule(struct kccsrv_service *service, uint32_t next_in
  */
 static NTSTATUS kccsrv_check_deleted(struct kccsrv_service *s, TALLOC_CTX *mem_ctx)
 {
-       time_t current = time(NULL);
-       return dsdb_garbage_collect_tombstones(mem_ctx, s->task->lp_ctx, s->samdb,
-                                              s->partitions, current, &s->last_deleted_check,
-                                              &s->last_full_scan_deleted_check);
+       time_t current_time = time(NULL);
+       time_t interval = lpcfg_parm_int(s->task->lp_ctx, NULL, "kccsrv",
+                                        "check_deleted_interval", 86400);
+       uint32_t tombstoneLifetime;
+       int ret;
+       unsigned int num_objects_removed = 0;
+       unsigned int num_links_removed = 0;
+       NTSTATUS status;
+       char *error_string = NULL;
+
+       if (current_time - s->last_deleted_check < interval) {
+               return NT_STATUS_OK;
+       }
+
+       ret = dsdb_tombstone_lifetime(s->samdb, &tombstoneLifetime);
+       if (ret != LDB_SUCCESS) {
+               DEBUG(1,(__location__ ": Failed to get tombstone lifetime\n"));
+               return NT_STATUS_INTERNAL_DB_CORRUPTION;
+       }
+
+       s->last_deleted_check = current_time;
+
+       status = dsdb_garbage_collect_tombstones(mem_ctx, s->samdb,
+                                                s->partitions,
+                                                current_time, tombstoneLifetime,
+                                                &num_objects_removed,
+                                                &num_links_removed,
+                                                &error_string);
+
+       if (NT_STATUS_IS_OK(status)) {
+               DEBUG(5, ("garbage_collect_tombstones: Removed %u tombstone objects "
+                         "and %u tombstone links successfully\n",
+                         num_objects_removed, num_links_removed));
+       } else {
+               DEBUG(2, ("garbage_collect_tombstones: Failure removing tombstone "
+                         "objects and links after removing %u tombstone objects "
+                         "and %u tombstone links successfully: %s\n",
+                         num_objects_removed, num_links_removed,
+                         error_string ? error_string : nt_errstr(status)));
+       }
+       return status;
 }
 
 static void kccsrv_periodic_run(struct kccsrv_service *service)