s4-secrets: fetch secure channel type with domain SID
authorAndrew Tridgell <tridge@samba.org>
Mon, 13 Sep 2010 02:15:52 +0000 (12:15 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 15 Sep 2010 05:39:34 +0000 (15:39 +1000)
The secure channel type is needed to work out what DC to connect to

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/param/secrets.c
source4/param/secrets.h
source4/winbind/wb_server.c
source4/winbind/wb_server.h

index befe7f36588b67701b0e1bd43cc33dd83f58515f..8fc595fbb055b9929434f2fcc2f1f0418c949862 100644 (file)
@@ -101,15 +101,17 @@ struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev_ctx,
                                       struct loadparm_context *lp_ctx,
                                       const char *domain,
+                                      enum netr_SchannelType *sec_channel_type,
                                       char **errstring)
 {
        struct ldb_context *ldb;
        struct ldb_message *msg;
        int ldb_ret;
-       const char *attrs[] = { "objectSid", NULL };
+       const char *attrs[] = { "objectSid", "secureChannelType", NULL };
        struct dom_sid *result = NULL;
        const struct ldb_val *v;
        enum ndr_err_code ndr_err;
+
        *errstring = NULL;
 
        ldb = secrets_db_connect(mem_ctx, ev_ctx, lp_ctx);
@@ -135,6 +137,18 @@ struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
                                             domain, (char *) ldb_get_opaque(ldb, "ldb_url"));
                return NULL;
        }
+
+       if (sec_channel_type) {
+               int v;
+               v = ldb_msg_find_attr_as_int(msg, "secureChannelType", -1);
+               if (v == -1) {
+                       *errstring = talloc_asprintf(mem_ctx, "Failed to find secureChannelType for %s in %s",
+                                                    domain, (char *) ldb_get_opaque(ldb, "ldb_url"));
+                       return NULL;
+               }
+               *sec_channel_type = v;
+       }
+
        result = talloc(mem_ctx, struct dom_sid);
        if (result == NULL) {
                talloc_free(ldb);
index c3227dfbcbc9e91ac98a09b75d140d46c58c0d5d..018bd36337e2fd62960d05dd853b3222f315d9c8 100644 (file)
  */
 struct loadparm_context;
 struct tevent_context;
+enum netr_SchannelType;
 struct tdb_wrap *secrets_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
 struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, struct loadparm_context *lp_ctx);
 struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev_ctx,
                                       struct loadparm_context *lp_ctx,
                                       const char *domain,
+                                      enum netr_SchannelType *sec_channel_type,
                                       char **errstring);
 
 
index ee44f0a2402623ed5ae708ee22806a3bb91cc7c2..96dab0acd525438c5d0d2c5057a56ce242147571 100644 (file)
@@ -239,7 +239,9 @@ static void winbind_task_init(struct task_server *task)
                primary_sid = secrets_get_domain_sid(service,
                                                     service->task->event_ctx,
                                                     service->task->lp_ctx,
-                                                    lpcfg_netbios_name(service->task->lp_ctx), &errstring);
+                                                    lpcfg_netbios_name(service->task->lp_ctx),
+                                                    &service->sec_channel_type,
+                                                    &errstring);
                if (!primary_sid) {
                        char *message = talloc_asprintf(task, 
                                                        "Cannot start Winbind (standalone configuration): %s: "
@@ -253,7 +255,9 @@ static void winbind_task_init(struct task_server *task)
                primary_sid = secrets_get_domain_sid(service,
                                                     service->task->event_ctx,
                                                     service->task->lp_ctx,
-                                                    lpcfg_workgroup(service->task->lp_ctx), &errstring);
+                                                    lpcfg_workgroup(service->task->lp_ctx),
+                                                    &service->sec_channel_type,
+                                                    &errstring);
                if (!primary_sid) {
                        char *message = talloc_asprintf(task, "Cannot start Winbind (domain member): %s: "
                                                        "Have you joined the %s domain?", 
@@ -266,7 +270,9 @@ static void winbind_task_init(struct task_server *task)
                primary_sid = secrets_get_domain_sid(service,
                                                     service->task->event_ctx,
                                                     service->task->lp_ctx,
-                                                    lpcfg_workgroup(service->task->lp_ctx), &errstring);
+                                                    lpcfg_workgroup(service->task->lp_ctx),
+                                                    &service->sec_channel_type,
+                                                    &errstring);
                if (!primary_sid) {
                        char *message = talloc_asprintf(task, "Cannot start Winbind (domain controller): %s: "
                                                        "Have you provisioned the %s domain?", 
index 1ffb62e4859d6bd5cc4b4dd4d1cadd2902a6b747..7fc778a97bf398b28490ada6aa829d6b88fe6ecf 100644 (file)
@@ -29,6 +29,7 @@ struct wbsrv_service {
        struct task_server *task;
 
        const struct dom_sid *primary_sid;
+       enum netr_SchannelType sec_channel_type;
        struct wbsrv_domain *domains;
        struct idmap_context *idmap_ctx;
        const char *priv_pipe_dir;