summaryrefslogtreecommitdiff
path: root/source3/utils/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils/net.c')
-rw-r--r--source3/utils/net.c76
1 files changed, 74 insertions, 2 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index fc7094bcf7..800aeded0a 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -329,6 +329,74 @@ static int net_file(int argc, const char **argv)
return net_rap_file(argc, argv);
}
+/*
+ Retrieve our local SID or the SID for the specified name
+ */
+static int net_getlocalsid(int argc, const char **argv)
+{
+ DOM_SID sid;
+ const char *name;
+ fstring sid_str;
+
+ if (argc >= 1) {
+ name = argv[0];
+ }
+ else {
+ name = global_myname;
+ }
+
+ if (!secrets_fetch_domain_sid(name, &sid)) {
+ DEBUG(0, ("Can't fetch domain SID for name: %s\n", name));
+ return 1;
+ }
+ sid_to_string(sid_str, &sid);
+ d_printf("SID for domain %s is: %s\n", name, sid_str);
+ return 0;
+}
+
+static int net_setlocalsid(int argc, const char **argv)
+{
+ DOM_SID sid;
+
+ if ( (argc != 1)
+ || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
+ || (!string_to_sid(&sid, argv[0]))
+ || (sid.num_auths != 4)) {
+ d_printf("usage: net setlocalsid S-1-5-21-x-y-z\n");
+ return 1;
+ }
+
+ if (!secrets_store_domain_sid(global_myname, &sid)) {
+ DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
+ return 1;
+ }
+
+ return 0;
+}
+
+static int net_getdomainsid(int argc, const char **argv)
+{
+ DOM_SID domain_sid;
+ fstring sid_str;
+
+ if (!secrets_fetch_domain_sid(global_myname, &domain_sid)) {
+ d_printf("Could not fetch local SID\n");
+ return 1;
+ }
+ sid_to_string(sid_str, &domain_sid);
+ d_printf("SID for domain %s is: %s\n", global_myname, sid_str);
+
+ if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) {
+ d_printf("Could not fetch domain SID\n");
+ return 1;
+ }
+
+ sid_to_string(sid_str, &domain_sid);
+ d_printf("SID for domain %s is: %s\n", lp_workgroup(), sid_str);
+
+ return 0;
+}
+
/* main function table */
static struct functable net_func[] = {
{"RPC", net_rpc},
@@ -352,6 +420,10 @@ static struct functable net_func[] = {
{"TIME", net_time},
{"LOOKUP", net_lookup},
{"JOIN", net_join},
+ {"CACHE", net_cache},
+ {"GETLOCALSID", net_getlocalsid},
+ {"SETLOCALSID", net_setlocalsid},
+ {"GETDOMAINSID", net_getdomainsid},
{"HELP", net_help},
{NULL, NULL}
@@ -391,7 +463,7 @@ static struct functable net_func[] = {
{"force", 'f', POPT_ARG_NONE, &opt_force},
{"timeout", 't', POPT_ARG_INT, &opt_timeout},
{"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass},
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
+ {"debuglevel", 'D', POPT_ARG_STRING, &debuglevel},
{ 0, 0, 0, 0}
};
@@ -469,7 +541,7 @@ static struct functable net_func[] = {
if (!*global_myname) {
char *p2;
- fstrcpy(global_myname, myhostname());
+ pstrcpy(global_myname, myhostname());
p2 = strchr_m(global_myname, '.');
if (p2)
*p2 = 0;