Author: brad
Date: 2005-08-07 15:25:25 +0000 (Sun, 07 Aug 2005)
New Revision: 9180

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9180

Log:
 [EMAIL PROTECTED]:  j0j0 | 2005-08-07 09:30:12 -0600
 Reworked libnet_join to use two join levels, AUTOMATIC and SPECIFIED.

Modified:
   branches/SOC/SAMBA_4_0/
   branches/SOC/SAMBA_4_0/source/libnet/libnet_join.c
   branches/SOC/SAMBA_4_0/source/libnet/libnet_join.h


Changeset:

Property changes on: branches/SOC/SAMBA_4_0
___________________________________________________________________
Name: svk:merge
   - 0c0555d6-39d7-0310-84fc-f1cc0bd64818:/branches/SAMBA_4_0:9111
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/SAMBA_4_0:5312
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/samba-SAMBA_4_0:5311
   + 0c0555d6-39d7-0310-84fc-f1cc0bd64818:/branches/SAMBA_4_0:9111
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/SAMBA_4_0:5314
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/samba-SAMBA_4_0:5311

Modified: branches/SOC/SAMBA_4_0/source/libnet/libnet_join.c
===================================================================
--- branches/SOC/SAMBA_4_0/source/libnet/libnet_join.c  2005-08-07 15:20:25 UTC 
(rev 9179)
+++ branches/SOC/SAMBA_4_0/source/libnet/libnet_join.c  2005-08-07 15:25:25 UTC 
(rev 9180)
@@ -145,7 +145,8 @@
        attr.sec_qos = &qos;
 
        lsa_open_policy.in.attr = &attr;
-       lsa_open_policy.in.system_name = talloc_asprintf(tmp_ctx, "\\%s", 
lp_netbios_name());
+       
+       lsa_open_policy.in.system_name = talloc_asprintf(tmp_ctx, "\\%s", 
r->in.netbios_name);
        lsa_open_policy.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        lsa_open_policy.out.handle = &lsa_p_handle;
 
@@ -600,11 +601,12 @@
 
        {
                char *service_principal_name[2];
-               char *dns_host_name = strlower_talloc(mem_ctx, 
-                                                     talloc_asprintf(mem_ctx, 
-                                                                     "%s.%s", 
lp_netbios_name(), realm));
+               char *dns_host_name = strlower_talloc(mem_ctx, 
talloc_asprintf(mem_ctx, 
+                                                               "%s.%s", 
+                                                               
r->in.netbios_name, 
+                                                               realm));
                service_principal_name[0] = talloc_asprintf(tmp_ctx, "host/%s", 
dns_host_name);
-               service_principal_name[1] = talloc_asprintf(tmp_ctx, "host/%s", 
strlower_talloc(mem_ctx, lp_netbios_name()));
+               service_principal_name[1] = talloc_asprintf(tmp_ctx, "host/%s", 
strlower_talloc(mem_ctx, r->in.netbios_name));
 
                samdb_msg_add_string(remote_ldb, tmp_ctx, msg, "dNSHostName", 
dns_host_name);
                samdb_msg_add_string(remote_ldb, tmp_ctx, msg, 
"servicePrincipalName", service_principal_name[0]);
@@ -626,15 +628,13 @@
        return NT_STATUS_OK;
 }
 
-static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx, 
-                                          TALLOC_CTX *mem_ctx, 
-                                          struct libnet_Join *r)
+static NTSTATUS libnet_Join_primary_domain_common(struct libnet_context *ctx,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct libnet_Join *r, struct 
libnet_JoinDomain r2)
 {
        NTSTATUS status;
        int ret;
-
        struct ldb_context *ldb;
-       struct libnet_JoinDomain r2;
        const char *base_dn = "cn=Primary Domains";
        const struct ldb_val *prior_secret;
        const struct ldb_val *prior_modified_time;
@@ -643,20 +643,11 @@
        const char *attrs[] = {
                "whenChanged",
                "secret",
-               "priorSecret"
+               "priorSecret",
                "priorChanged",
                NULL
        };
-
-       if (r->in.secure_channel_type == SEC_CHAN_BDC) {
-               r2.in.acct_type = ACB_SVRTRUST;
-       } else if (r->in.secure_channel_type == SEC_CHAN_WKSTA) {
-               r2.in.acct_type = ACB_WSTRUST;
-       }
-       r2.in.domain_name  = r->in.domain_name;
-
-       r2.in.account_name = talloc_asprintf(mem_ctx, "%s$", lp_netbios_name());
-
+       
        /* Local secrets are stored in secrets.ldb */
        ldb = secrets_db_connect(mem_ctx);
        if (!ldb) {
@@ -745,12 +736,69 @@
        return NT_STATUS_OK;
 }
 
+static NTSTATUS libnet_Join_primary_domain_specified(struct libnet_context 
*ctx,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct libnet_Join *r)
+{
+       NTSTATUS status;
+       struct libnet_JoinDomain r2;
+
+       if (r->in.secure_channel_type == SEC_CHAN_BDC) {
+               r2.in.acct_type = ACB_SVRTRUST;
+       } else if (r->in.secure_channel_type == SEC_CHAN_WKSTA) {
+               r2.in.acct_type = ACB_WSTRUST;
+       }
+       r2.in.domain_name  = r->in.domain_name;
+       r2.in.netbios_name = r->in.netbios_name;
+       r2.in.account_name = talloc_asprintf(mem_ctx, "%s$", 
r->in.netbios_name); 
+
+       status = libnet_Join_primary_domain_common(ctx, mem_ctx, r, r2);
+       return status;
+}
+
+static NTSTATUS libnet_Join_primary_domain_automatic(struct libnet_context 
*ctx,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct libnet_Join *r)
+{
+       NTSTATUS status;
+       struct libnet_JoinDomain r2;
+
+       if (r->in.secure_channel_type == SEC_CHAN_BDC) {
+               r2.in.acct_type = ACB_SVRTRUST;
+       } else if (r->in.secure_channel_type == SEC_CHAN_WKSTA) {
+               r2.in.acct_type = ACB_WSTRUST;
+       }
+       r2.in.domain_name  = r->in.domain_name;
+       r2.in.netbios_name = talloc_asprintf(mem_ctx, "%s", lp_netbios_name());
+       r2.in.account_name = talloc_asprintf(mem_ctx, "%s$", 
r2.in.netbios_name);
+
+       status = libnet_Join_primary_domain_common(ctx, mem_ctx, r, r2);
+       return status;
+}
+
+static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx, 
+                                          TALLOC_CTX *mem_ctx, 
+                                          struct libnet_Join *r)
+{
+       switch (r->in.level) {
+       case LIBNET_JOIN_AUTOMATIC:
+               return libnet_Join_primary_domain_automatic(ctx, mem_ctx, r);
+       case LIBNET_JOIN_SPECIFIED:
+               return libnet_Join_primary_domain_specified(ctx, mem_ctx, r);
+       }
+       return NT_STATUS_INVALID_LEVEL;
+}
+
 NTSTATUS libnet_Join(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct 
libnet_Join *r)
 {
+
        NTSTATUS nt_status;
        struct libnet_Join r2;
+       
+       r2.in.level = r->in.level;
        r2.in.secure_channel_type = r->in.secure_channel_type;
        r2.in.domain_name = r->in.domain_name;
+       r2.in.netbios_name = r->in.netbios_name;
        
        if ((r->in.secure_channel_type == SEC_CHAN_WKSTA)
            || (r->in.secure_channel_type == SEC_CHAN_BDC)) {

Modified: branches/SOC/SAMBA_4_0/source/libnet/libnet_join.h
===================================================================
--- branches/SOC/SAMBA_4_0/source/libnet/libnet_join.h  2005-08-07 15:20:25 UTC 
(rev 9179)
+++ branches/SOC/SAMBA_4_0/source/libnet/libnet_join.h  2005-08-07 15:25:25 UTC 
(rev 9180)
@@ -21,10 +21,16 @@
 
 #include "librpc/gen_ndr/ndr_netlogon.h"
 
+enum libnet_Join_level {
+       LIBNET_JOIN_AUTOMATIC,
+       LIBNET_JOIN_SPECIFIED,
+};
+
 struct libnet_JoinDomain {
        struct {
                const char *domain_name;
                const char *account_name;
+               const char *netbios_name;
                uint32_t  acct_type;
        } in;
 
@@ -41,7 +47,9 @@
 struct libnet_Join {
        struct {
                const char *domain_name;
+               const char *netbios_name;
                enum netr_SchannelType secure_channel_type;
+               enum libnet_Join_level level;
        } in;
        
        struct {

Reply via email to