summaryrefslogtreecommitdiff
path: root/source3/utils/net_rpc.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-04-14 09:44:16 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-04-14 09:44:16 +0000
commit07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed (patch)
tree0623e2c8e4b760f294c31de6f01aec1ec1a71902 /source3/utils/net_rpc.c
parent06f15779303dc540ee7801fe843023970454166b (diff)
downloadsamba-07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed.tar.gz
samba-07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed.tar.bz2
samba-07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed.zip
Partly based on the work by mimir (Rafal Szczesniak
<mimir@diament.ists.pwr.wroc.pl>) this patch allows samba to correctly enumerate its trusted domains - by exaimining the keys in the secrets.tdb file. This patch has been tested with both NT4 and rpcclient/wbinfo, and adds some extra functionality to talloc and rpc_parse to allow it to deal with already unicode strings. Finally, this cleans up some const warnings that were in net_rpc.c by pushing another dash of const into the rpc client code. Andrew Bartlett (This used to be commit 0bdd94cb992b40942aaf2e5e0efd2868b4686296)
Diffstat (limited to 'source3/utils/net_rpc.c')
-rw-r--r--source3/utils/net_rpc.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 2aca3f0485..315c2de030 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -451,7 +451,7 @@ static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid,
uint32 flags = 0x000003e8; /* Unknown */
result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- flags, 1, (char **) &argv[0],
+ flags, 1, &argv[0],
&num_rids, &user_rids,
&name_types);
@@ -548,7 +548,7 @@ rpc_user_info_internals(const DOM_SID *domain_sid, struct cli_state *cli,
/* Get handle on user */
result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- flags, 1, (char **) &argv[0],
+ flags, 1, &argv[0],
&num_rids, &rids, &name_types);
if (!NT_STATUS_IS_OK(result)) goto done;
@@ -874,7 +874,7 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, struct cli
if (argc != 1) {
d_printf("Usage: net rpc trustdom add <domain_name>\n");
- return NT_STATUS_OK;
+ return NT_STATUS_INVALID_PARAMETER;
}
/*
@@ -985,6 +985,12 @@ static int rpc_trustdom_establish(int argc, const char **argv) {
* Connect to \\server\ipc$ as 'our domain' account with password
*/
+ if (argc != 1) {
+ d_printf("Usage: net rpc trustdom add <domain_name>\n");
+ return -1;
+ }
+
+
domain_name = smb_xstrdup(argv[0]);
strupper(domain_name);
@@ -1061,10 +1067,8 @@ static int rpc_trustdom_establish(int argc, const char **argv) {
return -1;
}
- if (cli->nt_pipe_fnum) {
+ if (cli->nt_pipe_fnum)
cli_nt_session_close(cli);
- talloc_destroy(mem_ctx);
- }
/*
@@ -1104,6 +1108,17 @@ static int rpc_trustdom_establish(int argc, const char **argv) {
but I still don't know if it's _really_ necessary */
/*
+ * Store the password in secrets db
+ */
+
+ if (!secrets_store_trusted_domain_password(domain_name, wks_info.uni_lan_grp.buffer,
+ wks_info.uni_lan_grp.uni_str_len, opt_password,
+ domain_sid)) {
+ DEBUG(0, ("Storing password for trusted domain failed.\n"));
+ return -1;
+ }
+
+ /*
* Close the pipes and clean up
*/
@@ -1116,20 +1131,9 @@ static int rpc_trustdom_establish(int argc, const char **argv) {
if (cli->nt_pipe_fnum)
cli_nt_session_close(cli);
-
- talloc_destroy(mem_ctx);
+ talloc_destroy(mem_ctx);
- /*
- * Store the password in secrets db
- */
-
- if (!secrets_store_trusted_domain_password(domain_name, opt_password,
- domain_sid)) {
- DEBUG(0, ("Storing password for trusted domain failed.\n"));
- return -1;
- }
-
DEBUG(0, ("Success!\n"));
return 0;
}