libnet: Rename a variable so it does not shadow a global.
[ira/wip.git] / source / libnet / libnet_join.c
index 215217bfef425bf9c5c0ee5717933262b2e30ff5..22134518d695a15b6c4625e2de7eea6fe58c8fb6 100644 (file)
@@ -114,7 +114,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                                       drsuapi_binding,
                                       &ndr_table_drsuapi,
                                       ctx->cred, 
-                                      ctx->event_ctx);
+                                      ctx->event_ctx,
+                                      ctx->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                r->out.error_string = talloc_asprintf(r,
                                        "Connection to DRSUAPI pipe of PDC of domain '%s' failed: %s",
@@ -229,7 +230,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                return NT_STATUS_NO_MEMORY;
        }
 
-       remote_ldb = ldb_wrap_connect(tmp_ctx, global_loadparm
+       remote_ldb = ldb_wrap_connect(tmp_ctx, ctx->lp_ctx
                                      remote_ldb_url, 
                                      NULL, ctx->cred, 0, NULL);
        if (!remote_ldb) {
@@ -389,7 +390,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        r->out.account_guid = samdb_result_guid(res->msgs[0], "objectGUID");
 
        if (r->in.acct_type == ACB_SVRTRUST) {
-               status = libnet_JoinSite(remote_ldb, r);
+               status = libnet_JoinSite(ctx, remote_ldb, r);
        }
        talloc_free(tmp_ctx);
 
@@ -506,7 +507,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, 
-                                 &ndr_table_samr, ctx->cred);
+                                 &ndr_table_samr, ctx->cred, ctx->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                r->out.error_string = talloc_asprintf(mem_ctx,
                                                "SAMR bind failed: %s",
@@ -537,8 +538,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(global_loadparm));
-                       connect_with_info->out.realm = talloc_strdup(tmp_ctx, lp_realm(global_loadparm));
+                       connect_with_info->out.domain_name = talloc_strdup(tmp_ctx, lp_workgroup(ctx->lp_ctx));
+                       connect_with_info->out.realm = talloc_strdup(tmp_ctx, lp_realm(ctx->lp_ctx));
                }
        }
 
@@ -890,7 +891,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(global_loadparm));
+               netbios_name = talloc_reference(tmp_mem, lp_netbios_name(ctx->lp_ctx));
                if (!netbios_name) {
                        r->out.error_string = NULL;
                        talloc_free(tmp_mem);
@@ -909,7 +910,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
         * Local secrets are stored in secrets.ldb 
         * open it to make sure we can write the info into it after the join
         */
-       ldb = secrets_db_connect(tmp_mem);
+       ldb = secrets_db_connect(tmp_mem, ctx->lp_ctx);
        if (!ldb) {
                r->out.error_string
                        = talloc_asprintf(mem_ctx, 
@@ -1063,7 +1064,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        } else {
                const struct ldb_val *private_keytab;
-               const struct ldb_val *krb5_keytab;
+               const struct ldb_val *krb5_main_keytab;
                const struct ldb_val *prior_secret;
                const struct ldb_val *prior_modified_time;
                int i;
@@ -1124,9 +1125,10 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
                                return NT_STATUS_NO_MEMORY;
                        }
                }
-               krb5_keytab = ldb_msg_find_ldb_val(msgs[0], "krb5Keytab");
-               if (krb5_keytab) {
-                       rtn = samdb_msg_set_value(ldb, tmp_mem, msg, "krb5Keytab", krb5_keytab);
+               krb5_main_keytab = ldb_msg_find_ldb_val(msgs[0], "krb5Keytab");
+               if (krb5_main_keytab) {
+                       rtn = samdb_msg_set_value(ldb, tmp_mem, msg,
+                                       "krb5Keytab", krb5_main_keytab);
                        if (rtn == -1) {
                                r->out.error_string = NULL;
                                talloc_free(tmp_mem);
@@ -1136,7 +1138,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
        }
 
        /* create the secret */
-       ret = samdb_add(ldb, tmp_mem, msg);
+       ret = ldb_add(ldb, msg);
        if (ret != 0) {
                r->out.error_string = talloc_asprintf(mem_ctx, "Failed to create secret record %s", 
                                                      ldb_dn_get_linearized(msg->dn));