summaryrefslogtreecommitdiff
path: root/source3/rpcclient/rpcclient.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-01-15 23:35:59 +0000
committerTim Potter <tpot@samba.org>2001-01-15 23:35:59 +0000
commit19a8acda6400e17707b32e3cba721d83e5cbf987 (patch)
tree28287dcb49199d988cadbb82a236e49b516ffc22 /source3/rpcclient/rpcclient.c
parent5a0e2f19575f98a6d5530e66a9e3758e9a1c0a1a (diff)
downloadsamba-19a8acda6400e17707b32e3cba721d83e5cbf987.tar.gz
samba-19a8acda6400e17707b32e3cba721d83e5cbf987.tar.bz2
samba-19a8acda6400e17707b32e3cba721d83e5cbf987.zip
rpcclient functions for remaining samr and lsa functions. All functions
now pass through insure except for some of the dodgy spoolss prs weirdness. (This used to be commit 76f08426a08881793b0ef32ccc4e13c54f26417f)
Diffstat (limited to 'source3/rpcclient/rpcclient.c')
-rw-r--r--source3/rpcclient/rpcclient.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 91cf722120..7f2779fc6a 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -24,6 +24,8 @@
extern int DEBUGLEVEL;
+/* Connect info */
+
pstring password;
pstring username;
pstring workgroup;
@@ -35,6 +37,58 @@ extern struct cmd_set lsarpc_commands[];
extern struct cmd_set samr_commands[];
extern struct cmd_set spoolss_commands[];
+DOM_SID domain_sid;
+
+/* Fetch the SID for this domain */
+
+void fetch_domain_sid(void)
+{
+ struct cli_state cli;
+ POLICY_HND pol;
+ uint32 result = 0, info_class = 5;
+ struct ntuser_creds creds;
+ fstring domain_name;
+ static BOOL got_domain_sid;
+
+ if (got_domain_sid) return;
+
+ ZERO_STRUCT(cli);
+ init_rpcclient_creds(&creds);
+
+ if (cli_lsa_initialise(&cli, server, &creds) == NULL) {
+ fprintf(stderr, "could not initialise lsa pipe\n");
+ goto error;
+ }
+
+ if ((result = cli_lsa_open_policy(&cli, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &pol) != NT_STATUS_NOPROBLEMO)) {
+ goto error;
+ }
+
+ if ((result = cli_lsa_query_info_policy(&cli, &pol, info_class,
+ domain_name, &domain_sid))
+ != NT_STATUS_NOPROBLEMO) {
+ goto error;
+ }
+
+ got_domain_sid = True;
+
+ cli_lsa_close(&cli, &pol);
+ cli_lsa_shutdown(&cli);
+
+ return;
+
+ error:
+ fprintf(stderr, "could not obtain sid for domain %s\n", workgroup);
+
+ if (result != NT_STATUS_NOPROBLEMO) {
+ fprintf(stderr, "error: %s\n", get_nt_error_msg(result));
+ }
+
+ exit(1);
+}
+
/* Initialise client credentials for authenticated pipe access */
void init_rpcclient_creds(struct ntuser_creds *creds)
@@ -91,11 +145,17 @@ static uint32 cmd_debuglevel(int argc, char **argv)
return NT_STATUS_NOPROBLEMO;
}
+static uint32 cmd_quit(int argc, char **argv)
+{
+ exit(0);
+}
+
/* Build in rpcclient commands */
static struct cmd_set rpcclient_commands[] = {
{ "help", cmd_help, "Print list of commands" },
{ "debuglevel", cmd_debuglevel, "Set debug level" },
+ { "quit", cmd_quit, "Exit program" },
{ "?", cmd_help, "Print list of commands" },
{ NULL, NULL, NULL }
@@ -235,6 +295,7 @@ static void usage(char *pname)
extern char *optarg;
extern int optind;
struct in_addr dest_ip;
+ extern pstring global_myname;
BOOL got_pass = False;
BOOL have_ip = False;
int opt;
@@ -265,6 +326,9 @@ static void usage(char *pname)
TimeInit();
+ get_myname((*global_myname)?NULL:global_myname);
+ strupper(global_myname);
+
/* Parse options */
if (argc < 2) {