summaryrefslogtreecommitdiff
path: root/source4/dsdb/repl/drepl_service.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-04-23 00:43:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:30 -0500
commit023e2451873a89a433fadbe913b94507af856cf3 (patch)
tree069c97024aaf77573e588ace6cf641500d3f7f2b /source4/dsdb/repl/drepl_service.c
parent9ec83ae25df8e8e55ab1e25de4972ec4d082783b (diff)
downloadsamba-023e2451873a89a433fadbe913b94507af856cf3.tar.gz
samba-023e2451873a89a433fadbe913b94507af856cf3.tar.bz2
samba-023e2451873a89a433fadbe913b94507af856cf3.zip
r22472: Commit the start of the DRSUAPI pull replication service.
It doesn't work completely yet because we aren't able to resolve DNS SRV records. And also we also need a kdc locator plugin... But with some hacks the pull replication works fine metze (This used to be commit 0dc78f7439c9c786fd8c592960f9669dea40b811)
Diffstat (limited to 'source4/dsdb/repl/drepl_service.c')
-rw-r--r--source4/dsdb/repl/drepl_service.c114
1 files changed, 60 insertions, 54 deletions
diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c
index 9a3cac4247..17690d135d 100644
--- a/source4/dsdb/repl/drepl_service.c
+++ b/source4/dsdb/repl/drepl_service.c
@@ -47,70 +47,68 @@ static WERROR dreplsrv_init_creds(struct dreplsrv_service *service)
static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service)
{
+ const struct GUID *ntds_guid;
+ struct drsuapi_DsBindInfo28 *bind_info28;
+
service->samdb = samdb_connect(service, service->system_session_info);
if (!service->samdb) {
return WERR_DS_SERVICE_UNAVAILABLE;
}
- return WERR_OK;
-}
-
-static void dreplsrv_periodic_handler_te(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *ptr)
-{
- struct dreplsrv_service *service = talloc_get_type(ptr, struct dreplsrv_service);
- WERROR status;
-
- service->periodic.te = NULL;
-
- status = dreplsrv_periodic_schedule(service, service->periodic.interval);
- if (!W_ERROR_IS_OK(status)) {
- task_server_terminate(service->task, win_errstr(status));
- return;
+ ntds_guid = samdb_ntds_objectGUID(service->samdb);
+ if (!ntds_guid) {
+ return WERR_DS_SERVICE_UNAVAILABLE;
}
-}
-WERROR dreplsrv_periodic_schedule(struct dreplsrv_service *service, uint32_t next_interval)
-{
- TALLOC_CTX *tmp_mem;
- struct timed_event *new_te;
- struct timeval next_time;
-
- /* prevent looping */
- if (next_interval == 0) next_interval = 1;
-
- next_time = timeval_current_ofs(next_interval, 5000);
-
- if (service->periodic.te) {
- /*
- * if the timestamp of the new event is higher,
- * as current next we don't need to reschedule
- */
- if (timeval_compare(&next_time, &service->periodic.next_event) > 0) {
- return WERR_OK;
- }
+ service->ntds_guid = *ntds_guid;
+
+ bind_info28 = &service->bind_info28;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
+#if 0
+ if (s->domain_behavior_version == 2) {
+ /* TODO: find out how this is really triggered! */
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
}
-
- /* reset the next scheduled timestamp */
- service->periodic.next_event = next_time;
-
- new_te = event_add_timed(service->task->event_ctx, service,
- service->periodic.next_event,
- dreplsrv_periodic_handler_te, service);
- W_ERROR_HAVE_NO_MEMORY(new_te);
-
- tmp_mem = talloc_new(service);
- DEBUG(6,("dreplsrv_periodic_schedule(%u) %sscheduled for: %s\n",
- next_interval,
- (service->periodic.te?"re":""),
- nt_time_string(tmp_mem, timeval_to_nttime(&next_time))));
- talloc_free(tmp_mem);
-
- talloc_free(service->periodic.te);
- service->periodic.te = new_te;
+#endif
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_00100000;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
+#if 0 /* we don't support XPRESS compression yet */
+ bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
+#endif
+ /* TODO: fill in site_guid */
+ bind_info28->site_guid = GUID_zero();
+ /* TODO: find out how this is really triggered! */
+ bind_info28->u1 = 0;
+ bind_info28->repl_epoch = 0;
return WERR_OK;
}
+
/*
startup the dsdb replicator service task
*/
@@ -158,7 +156,15 @@ static void dreplsrv_task_init(struct task_server *task)
return;
}
- service->periodic.interval = 300; /* in seconds */
+ status = dreplsrv_load_partitions(service);
+ if (!W_ERROR_IS_OK(status)) {
+ task_server_terminate(task, talloc_asprintf(task,
+ "dreplsrv: Failed to load partitions: %s\n",
+ win_errstr(status)));
+ return;
+ }
+
+ service->periodic.interval = lp_parm_int(-1, "dreplsrv", "periodic_interval", 300); /* in seconds */
status = dreplsrv_periodic_schedule(service, service->periodic.interval);
if (!W_ERROR_IS_OK(status)) {