r25398: Parse loadparm context to all lp_*() functions.
[kai/samba.git] / source4 / libnet / libnet_join.c
index a40c8607bf037e8529e2053ecb6113ea2c7f68e7..553bde615be3e07df2978b6998a865e8ed164e0f 100644 (file)
@@ -7,7 +7,7 @@
  
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -32,6 +31,7 @@
 #include "auth/credentials/credentials.h"
 #include "auth/credentials/credentials_krb5.h"
 #include "librpc/gen_ndr/ndr_samr_c.h"
+#include "param/param.h"
 
 /*
  * complete a domain join, when joining to a AD domain:
@@ -111,7 +111,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        status = dcerpc_pipe_connect_b(tmp_ctx, 
                                       &drsuapi_pipe,
                                       drsuapi_binding,
-                                      &dcerpc_table_drsuapi,
+                                      &ndr_table_drsuapi,
                                       ctx->cred, 
                                       ctx->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
@@ -480,7 +480,7 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
        /* This level makes a connection to the LSA pipe on the way,
         * to get some useful bits of information about the domain */
        connect_with_info->level              = LIBNET_RPC_CONNECT_DC_INFO;
-       connect_with_info->in.dcerpc_iface    = &dcerpc_table_samr;
+       connect_with_info->in.dcerpc_iface    = &ndr_table_samr;
 
        /*
          establish the SAMR connection
@@ -504,7 +504,7 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
 
        status = dcerpc_pipe_auth(tmp_ctx, &samr_pipe,
                                  connect_with_info->out.dcerpc_pipe->binding, 
-                                 &dcerpc_table_samr, ctx->cred);
+                                 &ndr_table_samr, ctx->cred);
        if (!NT_STATUS_IS_OK(status)) {
                r->out.error_string = talloc_asprintf(mem_ctx,
                                                "SAMR bind failed: %s",
@@ -535,8 +535,8 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
                        connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, r->in.domain_name);
                } else {
                        /* Bugger, we just lost our way to automaticly find the domain name */
-                       connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, lp_workgroup());
-                       connect_with_info->out.realm = talloc_strdup(tmp_ctx, lp_realm());
+                       connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, lp_workgroup(global_loadparm));
+                       connect_with_info->out.realm = talloc_strdup(tmp_ctx, lp_realm(global_loadparm));
                }
        }
 
@@ -860,7 +860,6 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
        uint32_t acct_type = 0;
        const char *account_name;
        const char *netbios_name;
-       char *filter;
        
        r->out.error_string = NULL;
 
@@ -889,7 +888,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
        if (r->in.netbios_name != NULL) {
                netbios_name = r->in.netbios_name;
        } else {
-               netbios_name = talloc_reference(tmp_mem, lp_netbios_name());
+               netbios_name = talloc_reference(tmp_mem, lp_netbios_name(global_loadparm));
                if (!netbios_name) {
                        r->out.error_string = NULL;
                        talloc_free(tmp_mem);
@@ -1143,33 +1142,6 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
-       if (r2->out.realm) {
-               struct cli_credentials *creds;
-               /* Make a credentials structure from it */
-               creds = cli_credentials_init(mem_ctx);
-               if (!creds) {
-                       r->out.error_string = NULL;
-                       talloc_free(tmp_mem);
-                       return NT_STATUS_NO_MEMORY;
-               }
-               cli_credentials_set_conf(creds);
-               filter = talloc_asprintf(mem_ctx, "dn=%s", ldb_dn_get_linearized(msg->dn));
-               status = cli_credentials_set_secrets(creds, NULL, filter);
-               if (!NT_STATUS_IS_OK(status)) {
-                       r->out.error_string = talloc_asprintf(mem_ctx, "Failed to read secrets for keytab update for %s", 
-                                                             filter);
-                       talloc_free(tmp_mem);
-                       return status;
-               } 
-               ret = cli_credentials_update_keytab(creds);
-               if (ret != 0) {
-                       r->out.error_string = talloc_asprintf(mem_ctx, "Failed to update keytab for %s", 
-                                                             filter);
-                       talloc_free(tmp_mem);
-                       return NT_STATUS_UNSUCCESSFUL;
-               }
-       }
-
        /* move all out parameter to the callers TALLOC_CTX */
        r->out.error_string     = NULL;
        r->out.join_password    = r2->out.join_password;