summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_ds.c84
-rw-r--r--source3/rpcclient/cmd_dssetup.c69
-rw-r--r--source3/rpcclient/cmd_lsarpc.c538
-rw-r--r--source3/rpcclient/cmd_netlogon.c871
-rw-r--r--source3/rpcclient/cmd_ntsvcs.c189
-rw-r--r--source3/rpcclient/cmd_samr.c1900
-rw-r--r--source3/rpcclient/cmd_spoolss.c12
-rw-r--r--source3/rpcclient/rpcclient.c16
8 files changed, 2449 insertions, 1230 deletions
diff --git a/source3/rpcclient/cmd_ds.c b/source3/rpcclient/cmd_ds.c
deleted file mode 100644
index 1f36dc3b45..0000000000
--- a/source3/rpcclient/cmd_ds.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- RPC pipe client
-
- Copyright (C) Gerald Carter 2002
-
- 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 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "rpcclient.h"
-
-/* Look up domain related information on a remote host */
-
-static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
-{
- NTSTATUS result;
- DS_DOMINFO_CTR ctr;
-
- result = rpccli_ds_getprimarydominfo( cli, mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr );
- if ( NT_STATUS_IS_OK(result) )
- {
- printf ("Machine Role = [%d]\n", ctr.basic->machine_role);
-
- if ( ctr.basic->flags & DSROLE_PRIMARY_DS_RUNNING ) {
- printf( "Directory Service is running.\n");
- printf( "Domain is in %s mode.\n", (ctr.basic->flags & DSROLE_PRIMARY_DS_MIXED_MODE) ? "mixed" : "native" );
- }
- else
- printf( "Directory Service not running on server\n");
- }
-
- return result;
-}
-
-static NTSTATUS cmd_ds_enum_domain_trusts(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
-{
- NTSTATUS result;
- uint32 flags = DS_DOMAIN_IN_FOREST;
- struct ds_domain_trust *trusts = NULL;
- unsigned int num_domains = 0;
- int i;
-
- if (argc > 1) {
- flags = atoi(argv[1]);
- }
-
- result = rpccli_ds_enum_domain_trusts( cli, mem_ctx, cli->cli->desthost, flags,
- &trusts, &num_domains );
-
- printf( "%d domains returned\n", num_domains );
-
- for (i=0; i<num_domains; i++ )
- printf("%s (%s)\n", trusts[i].dns_domain, trusts[i].netbios_domain);
-
- return result;
-}
-
-/* List of commands exported by this module */
-
-struct cmd_set ds_commands[] = {
-
- { "LSARPC-DS" },
-
- { "dsroledominfo", RPC_RTYPE_NTSTATUS, cmd_ds_dsrole_getprimarydominfo, NULL, PI_LSARPC_DS, NULL, "Get Primary Domain Information", "" },
- { "dsenumdomtrusts", RPC_RTYPE_NTSTATUS, cmd_ds_enum_domain_trusts, NULL, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" },
-
-{ NULL }
-};
diff --git a/source3/rpcclient/cmd_dssetup.c b/source3/rpcclient/cmd_dssetup.c
new file mode 100644
index 0000000000..6ec58e9388
--- /dev/null
+++ b/source3/rpcclient/cmd_dssetup.c
@@ -0,0 +1,69 @@
+/*
+ Unix SMB/CIFS implementation.
+ RPC pipe client
+
+ Copyright (C) Gerald Carter 2002
+ Copyright (C) Guenther Deschner 2008
+
+ 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 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "rpcclient.h"
+
+/* Look up domain related information on a remote host */
+
+static WERROR cmd_ds_dsrole_getprimarydominfo(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ WERROR werr;
+ union dssetup_DsRoleInfo info;
+
+ status = rpccli_dssetup_DsRoleGetPrimaryDomainInformation(cli, mem_ctx,
+ DS_ROLE_BASIC_INFORMATION,
+ &info,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
+ }
+
+ printf ("Machine Role = [%d]\n", info.basic.role);
+
+ if (info.basic.flags & DS_ROLE_PRIMARY_DS_RUNNING) {
+ printf("Directory Service is running.\n");
+ printf("Domain is in %s mode.\n",
+ (info.basic.flags & DS_ROLE_PRIMARY_DS_MIXED_MODE) ? "mixed" : "native" );
+ } else {
+ printf("Directory Service not running on server\n");
+ }
+
+ return werr;
+}
+
+/* List of commands exported by this module */
+
+struct cmd_set ds_commands[] = {
+
+ { "LSARPC-DS" },
+
+ { "dsroledominfo", RPC_RTYPE_WERROR, NULL, cmd_ds_dsrole_getprimarydominfo, PI_DSSETUP, NULL, "Get Primary Domain Information", "" },
+
+{ NULL }
+};
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 05269d7711..90f8646810 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -4,6 +4,7 @@
Copyright (C) Tim Potter 2000
Copyright (C) Rafal Szczesniak 2002
+ Copyright (C) Guenther Deschner 2008
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
@@ -22,7 +23,6 @@
#include "includes.h"
#include "rpcclient.h"
-
/* useful function to allow entering a name instead of a SID and
* looking it up automatically */
static NTSTATUS name_to_sid(struct rpc_pipe_client *cli,
@@ -58,107 +58,91 @@ done:
return result;
}
-static void display_query_info_1(DOM_QUERY_1 d)
+static void display_query_info_1(struct lsa_AuditLogInfo *r)
{
- d_printf("percent_full:\t%d\n", d.percent_full);
- d_printf("log_size:\t%d\n", d.log_size);
- d_printf("retention_time:\t%lld\n", (long long)d.retention_time);
- d_printf("shutdown_in_progress:\t%d\n", d.shutdown_in_progress);
- d_printf("time_to_shutdown:\t%lld\n", (long long)d.time_to_shutdown);
- d_printf("next_audit_record:\t%d\n", d.next_audit_record);
- d_printf("unknown:\t%d\n", d.unknown);
+ d_printf("percent_full:\t%d\n", r->percent_full);
+ d_printf("log_size:\t%d\n", r->log_size);
+ d_printf("retention_time:\t%lld\n", (long long)r->retention_time);
+ d_printf("shutdown_in_progress:\t%d\n", r->shutdown_in_progress);
+ d_printf("time_to_shutdown:\t%lld\n", (long long)r->time_to_shutdown);
+ d_printf("next_audit_record:\t%d\n", r->next_audit_record);
+ d_printf("unknown:\t%d\n", r->unknown);
}
-static void display_query_info_2(DOM_QUERY_2 d, TALLOC_CTX *mem_ctx)
+static void display_query_info_2(struct lsa_AuditEventsInfo *r)
{
int i;
- d_printf("Auditing enabled:\t%d\n", d.auditing_enabled);
- d_printf("Auditing categories:\t%d\n", d.count1);
+ d_printf("Auditing enabled:\t%d\n", r->auditing_mode);
+ d_printf("Auditing categories:\t%d\n", r->count);
d_printf("Auditsettings:\n");
- for (i=0; i<d.count1; i++) {
- const char *val = audit_policy_str(mem_ctx, d.auditsettings[i]);
+ for (i=0; i<r->count; i++) {
+ const char *val = audit_policy_str(talloc_tos(), r->settings[i]);
const char *policy = audit_description_str(i);
d_printf("%s:\t%s\n", policy, val);
}
}
-static void display_query_info_3(DOM_QUERY_3 d)
+static void display_query_info_3(struct lsa_DomainInfo *r)
{
- fstring name;
-
- unistr2_to_ascii(name, &d.uni_domain_name, sizeof(name));
-
- d_printf("Domain Name: %s\n", name);
- d_printf("Domain Sid: %s\n", sid_string_tos(&d.dom_sid.sid));
+ d_printf("Domain Name: %s\n", r->name.string);
+ d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
}
-static void display_query_info_5(DOM_QUERY_5 d)
+static void display_query_info_5(struct lsa_DomainInfo *r)
{
- fstring name;
-
- unistr2_to_ascii(name, &d.uni_domain_name, sizeof(name));
-
- d_printf("Domain Name: %s\n", name);
- d_printf("Domain Sid: %s\n", sid_string_tos(&d.dom_sid.sid));
+ d_printf("Domain Name: %s\n", r->name.string);
+ d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
}
-static void display_query_info_10(DOM_QUERY_10 d)
+static void display_query_info_10(struct lsa_AuditFullSetInfo *r)
{
- d_printf("Shutdown on full: %d\n", d.shutdown_on_full);
+ d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
}
-static void display_query_info_11(DOM_QUERY_11 d)
+static void display_query_info_11(struct lsa_AuditFullQueryInfo *r)
{
- d_printf("Shutdown on full: %d\n", d.shutdown_on_full);
- d_printf("Log is full: %d\n", d.log_is_full);
- d_printf("Unknown: %d\n", d.unknown);
+ d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
+ d_printf("Log is full: %d\n", r->log_is_full);
+ d_printf("Unknown: %d\n", r->unknown);
}
-static void display_query_info_12(DOM_QUERY_12 d)
+static void display_query_info_12(struct lsa_DnsDomainInfo *r)
{
- fstring dom_name, dns_dom_name, forest_name;
-
- unistr2_to_ascii(dom_name, &d.uni_nb_dom_name, sizeof(dom_name));
- unistr2_to_ascii(dns_dom_name, &d.uni_dns_dom_name, sizeof(dns_dom_name));
- unistr2_to_ascii(forest_name, &d.uni_forest_name, sizeof(forest_name));
-
- d_printf("Domain NetBios Name: %s\n", dom_name);
- d_printf("Domain DNS Name: %s\n", dns_dom_name);
- d_printf("Domain Forest Name: %s\n", forest_name);
- d_printf("Domain Sid: %s\n", sid_string_tos(&d.dom_sid.sid));
+ d_printf("Domain NetBios Name: %s\n", r->name.string);
+ d_printf("Domain DNS Name: %s\n", r->dns_domain.string);
+ d_printf("Domain Forest Name: %s\n", r->dns_forest.string);
+ d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
d_printf("Domain GUID: %s\n", smb_uuid_string(talloc_tos(),
- d.dom_guid));
-
+ r->domain_guid));
}
-
-
-static void display_lsa_query_info(LSA_INFO_CTR *dom, TALLOC_CTX *mem_ctx)
+static void display_lsa_query_info(union lsa_PolicyInformation *info,
+ enum lsa_PolicyInfo level)
{
- switch (dom->info_class) {
+ switch (level) {
case 1:
- display_query_info_1(dom->info.id1);
+ display_query_info_1(&info->audit_log);
break;
case 2:
- display_query_info_2(dom->info.id2, mem_ctx);
+ display_query_info_2(&info->audit_events);
break;
case 3:
- display_query_info_3(dom->info.id3);
+ display_query_info_3(&info->domain);
break;
case 5:
- display_query_info_5(dom->info.id5);
+ display_query_info_5(&info->account_domain);
break;
case 10:
- display_query_info_10(dom->info.id10);
+ display_query_info_10(&info->auditfullset);
break;
case 11:
- display_query_info_11(dom->info.id11);
+ display_query_info_11(&info->auditfullquery);
break;
case 12:
- display_query_info_12(dom->info.id12);
+ display_query_info_12(&info->dns);
break;
default:
- printf("can't display info level: %d\n", dom->info_class);
+ printf("can't display info level: %d\n", level);
break;
}
}
@@ -169,7 +153,7 @@ static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- LSA_INFO_CTR dom;
+ union lsa_PolicyInformation *info = NULL;
uint32 info_class = 3;
@@ -190,8 +174,10 @@ static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_info_policy2_new(cli, mem_ctx, &pol,
- info_class, &dom);
+ result = rpccli_lsa_QueryInfoPolicy2(cli, mem_ctx,
+ &pol,
+ info_class,
+ &info);
break;
default:
result = rpccli_lsa_open_policy(cli, mem_ctx, True,
@@ -201,12 +187,15 @@ static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_info_policy_new(cli, mem_ctx, &pol,
- info_class, &dom);
+ result = rpccli_lsa_QueryInfoPolicy(cli, mem_ctx,
+ &pol,
+ info_class,
+ &info);
}
-
- display_lsa_query_info(&dom, mem_ctx);
+ if (NT_STATUS_IS_OK(result)) {
+ display_lsa_query_info(info, info_class);
+ }
rpccli_lsa_Close(cli, mem_ctx, &pol);
@@ -389,13 +378,12 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- DOM_SID *domain_sids;
- char **domain_names;
+ struct lsa_DomainList domain_list;
/* defaults, but may be changed using params */
uint32 enum_ctx = 0;
- uint32 num_domains = 0;
int i;
+ uint32_t max_size = (uint32_t)-1;
if (argc > 2) {
printf("Usage: %s [enum context (0)]\n", argv[0]);
@@ -407,7 +395,7 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
}
result = rpccli_lsa_open_policy(cli, mem_ctx, True,
- POLICY_VIEW_LOCAL_INFORMATION,
+ LSA_POLICY_VIEW_LOCAL_INFORMATION,
&pol);
if (!NT_STATUS_IS_OK(result))
@@ -419,9 +407,11 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
/* Lookup list of trusted domains */
- result = rpccli_lsa_enum_trust_dom(cli, mem_ctx, &pol, &enum_ctx,
- &num_domains,
- &domain_names, &domain_sids);
+ result = rpccli_lsa_EnumTrustDom(cli, mem_ctx,
+ &pol,
+ &enum_ctx,
+ &domain_list,
+ max_size);
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
!NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
@@ -429,12 +419,14 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
/* Print results: list of names and sids returned in this
* response. */
- for (i = 0; i < num_domains; i++) {
+ for (i = 0; i < domain_list.count; i++) {
fstring sid_str;
- sid_to_fstring(sid_str, &domain_sids[i]);
- printf("%s %s\n", domain_names[i] ? domain_names[i] :
- "*unknown*", sid_str);
+ sid_to_fstring(sid_str, domain_list.domains[i].sid);
+ printf("%s %s\n",
+ domain_list.domains[i].name.string ?
+ domain_list.domains[i].name.string : "*unknown*",
+ sid_str);
}
}
@@ -451,13 +443,10 @@ static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ struct lsa_PrivArray priv_array;
uint32 enum_context=0;
uint32 pref_max_length=0x1000;
- uint32 count=0;
- char **privs_name;
- uint32 *privs_high;
- uint32 *privs_low;
int i;
if (argc > 3) {
@@ -478,18 +467,24 @@ static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_enum_privilege(cli, mem_ctx, &pol, &enum_context, pref_max_length,
- &count, &privs_name, &privs_high, &privs_low);
-
+ result = rpccli_lsa_EnumPrivs(cli, mem_ctx,
+ &pol,
+ &enum_context,
+ &priv_array,
+ pref_max_length);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Print results */
- printf("found %d privileges\n\n", count);
-
- for (i = 0; i < count; i++) {
- printf("%s \t\t%d:%d (0x%x:0x%x)\n", privs_name[i] ? privs_name[i] : "*unknown*",
- privs_high[i], privs_low[i], privs_high[i], privs_low[i]);
+ printf("found %d privileges\n\n", priv_array.count);
+
+ for (i = 0; i < priv_array.count; i++) {
+ printf("%s \t\t%d:%d (0x%x:0x%x)\n",
+ priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*",
+ priv_array.privs[i].luid.high,
+ priv_array.privs[i].luid.low,
+ priv_array.privs[i].luid.high,
+ priv_array.privs[i].luid.low);
}
rpccli_lsa_Close(cli, mem_ctx, &pol);
@@ -509,7 +504,8 @@ static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
uint16 lang_id=0;
uint16 lang_id_sys=0;
uint16 lang_id_desc;
- fstring description;
+ struct lsa_String lsa_name;
+ struct lsa_StringLarge *description = NULL;
if (argc != 2) {
printf("Usage: %s privilege name\n", argv[0]);
@@ -523,13 +519,21 @@ static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_get_dispname(cli, mem_ctx, &pol, argv[1], lang_id, lang_id_sys, description, &lang_id_desc);
+ init_lsa_String(&lsa_name, argv[1]);
+
+ result = rpccli_lsa_LookupPrivDisplayName(cli, mem_ctx,
+ &pol,
+ &lsa_name,
+ lang_id,
+ lang_id_sys,
+ &description,
+ &lang_id_desc);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Print results */
- printf("%s -> %s (language: 0x%x)\n", argv[1], description, lang_id_desc);
+ printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
rpccli_lsa_Close(cli, mem_ctx, &pol);
done:
@@ -547,8 +551,7 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
uint32 enum_context=0;
uint32 pref_max_length=0x1000;
- DOM_SID *sids;
- uint32 count=0;
+ struct lsa_SidArray sid_array;
int i;
if (argc > 3) {
@@ -569,19 +572,22 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length,
- &count, &sids);
+ result = rpccli_lsa_EnumAccounts(cli, mem_ctx,
+ &pol,
+ &enum_context,
+ &sid_array,
+ pref_max_length);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Print results */
- printf("found %d SIDs\n\n", count);
+ printf("found %d SIDs\n\n", sid_array.num_sids);
- for (i = 0; i < count; i++) {
+ for (i = 0; i < sid_array.num_sids; i++) {
fstring sid_str;
- sid_to_fstring(sid_str, &sids[i]);
+ sid_to_fstring(sid_str, sid_array.sids[i].sid);
printf("%s\n", sid_str);
}
@@ -619,7 +625,11 @@ static NTSTATUS cmd_lsa_create_account(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_create_account(cli, mem_ctx, &dom_pol, &sid, des_access, &user_pol);
+ result = rpccli_lsa_CreateAccount(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ des_access,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -643,10 +653,8 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli,
POLICY_HND user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 access_desired = 0x000f000f;
-
DOM_SID sid;
- uint32 count=0;
- LUID_ATTR *set;
+ struct lsa_PrivilegeSet *privs = NULL;
int i;
if (argc != 2 ) {
@@ -665,22 +673,31 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_open_account(cli, mem_ctx, &dom_pol, &sid, access_desired, &user_pol);
+ result = rpccli_lsa_OpenAccount(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ access_desired,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set);
+ result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx,
+ &user_pol,
+ &privs);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Print results */
- printf("found %d privileges for SID %s\n\n", count, argv[1]);
+ printf("found %d privileges for SID %s\n\n", privs->count, argv[1]);
printf("high\tlow\tattribute\n");
- for (i = 0; i < count; i++) {
- printf("%u\t%u\t%u\n", set[i].luid.high, set[i].luid.low, set[i].attr);
+ for (i = 0; i < privs->count; i++) {
+ printf("%u\t%u\t%u\n",
+ privs->set[i].luid.high,
+ privs->set[i].luid.low,
+ privs->set[i].attribute);
}
rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
@@ -697,10 +714,8 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli,
{
POLICY_HND dom_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
DOM_SID sid;
- uint32 count;
- char **rights;
+ struct lsa_RightSet rights;
int i;
@@ -720,16 +735,19 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights);
+ result = rpccli_lsa_EnumAccountRights(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ &rights);
if (!NT_STATUS_IS_OK(result))
goto done;
- printf("found %d privileges for SID %s\n", count,
+ printf("found %d privileges for SID %s\n", rights.count,
sid_string_tos(&sid));
- for (i = 0; i < count; i++) {
- printf("\t%s\n", rights[i]);
+ for (i = 0; i < rights.count; i++) {
+ printf("\t%s\n", rights.names[i].string);
}
rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
@@ -746,8 +764,9 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli,
{
POLICY_HND dom_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
+ struct lsa_RightSet rights;
DOM_SID sid;
+ int i;
if (argc < 3 ) {
printf("Usage: %s SID [rights...]\n", argv[0]);
@@ -765,8 +784,21 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid,
- argc-2, argv+2);
+ rights.count = argc-2;
+ rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.count);
+ if (!rights.names) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; i<argc-1; i++) {
+ init_lsa_StringLarge(&rights.names[i], argv[i+2]);
+ }
+
+ result = rpccli_lsa_AddAccountRights(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ &rights);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -785,8 +817,9 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli,
{
POLICY_HND dom_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
+ struct lsa_RightSet rights;
DOM_SID sid;
+ int i;
if (argc < 3 ) {
printf("Usage: %s SID [rights...]\n", argv[0]);
@@ -804,8 +837,22 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid,
- False, argc-2, argv+2);
+ rights.count = argc-2;
+ rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.count);
+ if (!rights.names) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; i<argc-2; i++) {
+ init_lsa_StringLarge(&rights.names[i], argv[i+2]);
+ }
+
+ result = rpccli_lsa_RemoveAccountRights(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ false,
+ &rights);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -825,7 +872,8 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- LUID luid;
+ struct lsa_LUID luid;
+ struct lsa_String name;
if (argc != 2 ) {
printf("Usage: %s name\n", argv[0]);
@@ -839,7 +887,12 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_lookup_priv_value(cli, mem_ctx, &pol, argv[1], &luid);
+ init_lsa_String(&name, argv[1]);
+
+ result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
+ &pol,
+ &name,
+ &luid);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -879,8 +932,10 @@ static NTSTATUS cmd_lsa_query_secobj(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_lsa_query_secobj(cli, mem_ctx, &pol, sec_info, &sdb);
-
+ result = rpccli_lsa_QuerySecurity(cli, mem_ctx,
+ &pol,
+ sec_info,
+ &sdb);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -976,17 +1031,11 @@ static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
done:
- if (&pol)
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
-static void init_lsa_String(struct lsa_String *name, const char *s)
-{
- name->string = s;
-}
-
static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
@@ -1015,7 +1064,7 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx,
&pol,
- trusted_domain,
+ &trusted_domain,
info_class,
&info);
if (!NT_STATUS_IS_OK(result))
@@ -1024,8 +1073,7 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
done:
- if (&pol)
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
@@ -1078,12 +1126,221 @@ static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli,
display_trust_dom_info(mem_ctx, &info, info_class, cli->pwd.password);
done:
- if (&pol)
- rpccli_lsa_Close(cli, mem_ctx, &pol);
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
return result;
}
+static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ POLICY_HND pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ const char *servername = cli->cli->desthost;
+ struct lsa_String *account_name = NULL;
+ struct lsa_String *authority_name = NULL;
+
+ if (argc > 2) {
+ printf("Usage: %s servername\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ result = rpccli_lsa_open_policy(cli, mem_ctx, true,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_lsa_GetUserName(cli, mem_ctx,
+ servername,
+ &account_name,
+ &authority_name);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Print results */
+
+ printf("Account Name: %s, Authority Name: %s\n",
+ account_name->string, authority_name->string);
+
+ rpccli_lsa_Close(cli, mem_ctx, &pol);
+ done:
+ return result;
+}
+
+static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ POLICY_HND dom_pol, user_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ struct lsa_PrivilegeSet privs;
+ struct lsa_LUIDAttribute *set = NULL;
+ DOM_SID sid;
+ int i;
+
+ ZERO_STRUCT(privs);
+
+ if (argc < 3 ) {
+ printf("Usage: %s SID [rights...]\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &dom_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_lsa_OpenAccount(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ for (i=2; i<argc; i++) {
+
+ struct lsa_String priv_name;
+ struct lsa_LUID luid;
+
+ init_lsa_String(&priv_name, argv[i]);
+
+ result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
+ &dom_pol,
+ &priv_name,
+ &luid);
+ if (!NT_STATUS_IS_OK(result)) {
+ continue;
+ }
+
+ privs.count++;
+ set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
+ struct lsa_LUIDAttribute,
+ privs.count);
+ if (!set) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ set[privs.count-1].luid = luid;
+ set[privs.count-1].attribute = 0;
+ }
+
+ privs.set = set;
+
+ result = rpccli_lsa_AddPrivilegesToAccount(cli, mem_ctx,
+ &user_pol,
+ &privs);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ rpccli_lsa_Close(cli, mem_ctx, &user_pol);
+ rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
+ done:
+ return result;
+}
+
+static NTSTATUS cmd_lsa_del_priv(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ POLICY_HND dom_pol, user_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ struct lsa_PrivilegeSet privs;
+ struct lsa_LUIDAttribute *set = NULL;
+ DOM_SID sid;
+ int i;
+
+ ZERO_STRUCT(privs);
+
+ if (argc < 3 ) {
+ printf("Usage: %s SID [rights...]\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &dom_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_lsa_OpenAccount(cli, mem_ctx,
+ &dom_pol,
+ &sid,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ for (i=2; i<argc; i++) {
+
+ struct lsa_String priv_name;
+ struct lsa_LUID luid;
+
+ init_lsa_String(&priv_name, argv[i]);
+
+ result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
+ &dom_pol,
+ &priv_name,
+ &luid);
+ if (!NT_STATUS_IS_OK(result)) {
+ continue;
+ }
+
+ privs.count++;
+ set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
+ struct lsa_LUIDAttribute,
+ privs.count);
+ if (!set) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ set[privs.count-1].luid = luid;
+ set[privs.count-1].attribute = 0;
+ }
+
+ privs.set = set;
+
+
+ result = rpccli_lsa_RemovePrivilegesFromAccount(cli, mem_ctx,
+ &user_pol,
+ false,
+ &privs);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ rpccli_lsa_Close(cli, mem_ctx, &user_pol);
+ rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
+ done:
+ return result;
+}
/* List of commands exported by this module */
@@ -1103,10 +1360,8 @@ struct cmd_set lsarpc_commands[] = {
{ "lsacreateaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_create_account, NULL, PI_LSARPC, NULL, "Create a new lsa account", "" },
{ "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, PI_LSARPC, NULL, "Enumerate the privileges of an SID", "" },
{ "lsaenumacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights, NULL, PI_LSARPC, NULL, "Enumerate the rights of an SID", "" },
-#if 0
- { "lsaaddpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv, NULL, PI_LSARPC, "Assign a privilege to a SID", "" },
- { "lsadelpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv, NULL, PI_LSARPC, "Revoke a privilege from a SID", "" },
-#endif
+ { "lsaaddpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv, NULL, PI_LSARPC, NULL, "Assign a privilege to a SID", "" },
+ { "lsadelpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv, NULL, PI_LSARPC, NULL, "Revoke a privilege from a SID", "" },
{ "lsaaddacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights, NULL, PI_LSARPC, NULL, "Add rights to an account", "" },
{ "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, PI_LSARPC, NULL, "Remove rights from an account", "" },
{ "lsalookupprivvalue", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_priv_value, NULL, PI_LSARPC, NULL, "Get a privilege value given its name", "" },
@@ -1114,6 +1369,7 @@ struct cmd_set lsarpc_commands[] = {
{ "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" },
{ "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" },
{ "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" },
+ { "getusername", RPC_RTYPE_NTSTATUS, cmd_lsa_get_username, NULL, PI_LSARPC, NULL, "Get username", "" },
{ NULL }
};
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 2c1f7e0f11..95d79b5825 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -3,6 +3,7 @@
RPC pipe client
Copyright (C) Tim Potter 2000
+ Copyright (C) Guenther Deschner 2008
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
@@ -21,35 +22,77 @@
#include "includes.h"
#include "rpcclient.h"
-static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
+static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
{
- uint32 query_level = 1;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr;
+ const char *logon_server = cli->cli->desthost;
+ enum netr_LogonControlCode function_code = NETLOGON_CONTROL_REDISCOVER;
+ uint32_t level = 1;
+ union netr_CONTROL_DATA_INFORMATION data;
+ union netr_CONTROL_QUERY_INFORMATION query;
+ const char *domain = lp_workgroup();
+
+ if (argc > 5) {
+ fprintf(stderr, "Usage: %s <logon_server> <function_code> "
+ "<level> <domain>\n", argv[0]);
+ return WERR_OK;
+ }
- if (argc > 1) {
- fprintf(stderr, "Usage: %s\n", argv[0]);
- return NT_STATUS_OK;
+ if (argc >= 2) {
+ logon_server = argv[1];
}
- result = rpccli_netlogon_logon_ctrl2(cli, mem_ctx, query_level);
+ if (argc >= 3) {
+ function_code = atoi(argv[2]);
+ }
- if (!NT_STATUS_IS_OK(result))
- goto done;
+ if (argc >= 4) {
+ level = atoi(argv[3]);
+ }
+
+ if (argc >= 5) {
+ domain = argv[4];
+ }
+
+ switch (function_code) {
+ case NETLOGON_CONTROL_REDISCOVER:
+ case NETLOGON_CONTROL_TC_QUERY:
+ data.domain = domain;
+ break;
+ default:
+ break;
+ }
+
+ status = rpccli_netr_LogonControl2(cli, mem_ctx,
+ logon_server,
+ function_code,
+ level,
+ &data,
+ &query,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
+ }
/* Display results */
- done:
- return result;
+ return werr;
}
static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
- char *dcname = NULL;
- WERROR result = WERR_GENERAL_FAILURE;
+ const char *dcname = NULL;
+ WERROR werr;
+ NTSTATUS status;
int old_timeout;
if (argc != 2) {
@@ -60,27 +103,35 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
/* Make sure to wait for our DC's reply */
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
- result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname);
-
+ status = rpccli_netr_GetAnyDCName(cli, mem_ctx,
+ cli->cli->desthost,
+ argv[1],
+ &dcname,
+ &werr);
cli_set_timeout(cli->cli, old_timeout);
- if (!W_ERROR_IS_OK(result))
- goto done;
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
+ }
/* Display results */
printf("%s\n", dcname);
- done:
- return result;
+ return werr;
}
-static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
+static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
- char *dcname = NULL;
- WERROR result = WERR_GENERAL_FAILURE;
+ const char *dcname = NULL;
+ NTSTATUS status;
+ WERROR werr;
int old_timeout;
if (argc != 2) {
@@ -91,32 +142,40 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
/* Make sure to wait for our DC's reply */
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
- result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname);
-
+ status = rpccli_netr_GetDcName(cli, mem_ctx,
+ cli->cli->desthost,
+ argv[1],
+ &dcname,
+ &werr);
cli_set_timeout(cli->cli, old_timeout);
- if (!W_ERROR_IS_OK(result))
- goto done;
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
+ }
/* Display results */
printf("%s\n", dcname);
- done:
- return result;
+ return werr;
}
static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
- WERROR result;
+ NTSTATUS result;
+ WERROR werr = WERR_OK;
uint32 flags = DS_RETURN_DNS_NAME;
const char *server_name = cli->cli->desthost;
const char *domain_name;
struct GUID domain_guid = GUID_zero();
struct GUID site_guid = GUID_zero();
- struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
+ struct netr_DsRGetDCNameInfo *info = NULL;
if (argc < 2) {
fprintf(stderr, "Usage: %s [domain_name] [domain_guid] "
@@ -144,20 +203,25 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
debug_dsdcinfo_flags(1,flags);
- result = rpccli_netlogon_dsr_getdcname(cli, mem_ctx, server_name, domain_name,
- &domain_guid, &site_guid, flags,
- &info);
-
- if (W_ERROR_IS_OK(result)) {
- d_printf("DsGetDcName gave\n");
- display_ds_domain_controller_info(mem_ctx, info);
+ result = rpccli_netr_DsRGetDCName(cli, mem_ctx,
+ server_name,
+ domain_name,
+ &domain_guid,
+ &site_guid,
+ flags,
+ &info,
+ &werr);
+
+ if (W_ERROR_IS_OK(werr)) {
+ d_printf("DsGetDcName gave: %s\n",
+ NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info));
return WERR_OK;
}
printf("rpccli_netlogon_dsr_getdcname returned %s\n",
- dos_errstr(result));
+ dos_errstr(werr));
- return result;
+ return werr;
}
static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
@@ -165,12 +229,13 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
const char **argv)
{
WERROR result;
- uint32 flags = DS_RETURN_DNS_NAME;
+ NTSTATUS status;
+ uint32_t flags = DS_RETURN_DNS_NAME;
const char *server_name = cli->cli->desthost;
const char *domain_name;
const char *site_name = NULL;
struct GUID domain_guid = GUID_zero();
- struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
+ struct netr_DsRGetDCNameInfo *info = NULL;
if (argc < 2) {
fprintf(stderr, "Usage: %s [domain_name] [domain_guid] "
@@ -178,8 +243,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
return WERR_OK;
}
- if (argc >= 2)
- domain_name = argv[1];
+ domain_name = argv[1];
if (argc >= 3) {
if (!NT_STATUS_IS_OK(GUID_from_string(argv[2], &domain_guid))) {
@@ -187,26 +251,34 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
}
}
- if (argc >= 4)
+ if (argc >= 4) {
site_name = argv[3];
+ }
- if (argc >= 5)
+ if (argc >= 5) {
sscanf(argv[4], "%x", &flags);
+ }
debug_dsdcinfo_flags(1,flags);
- result = rpccli_netlogon_dsr_getdcnameex(cli, mem_ctx, server_name, domain_name,
- &domain_guid, site_name, flags,
- &info);
+ status = rpccli_netr_DsRGetDCNameEx(cli, mem_ctx,
+ server_name,
+ domain_name,
+ &domain_guid,
+ site_name,
+ flags,
+ &info,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
- if (W_ERROR_IS_OK(result)) {
- d_printf("DsGetDcNameEx gave\n");
- display_ds_domain_controller_info(mem_ctx, info);
- return WERR_OK;
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
}
- printf("rpccli_netlogon_dsr_getdcnameex returned %s\n",
- dos_errstr(result));
+ d_printf("DsRGetDCNameEx gave %s\n",
+ NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info));
return result;
}
@@ -216,14 +288,15 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli,
const char **argv)
{
WERROR result;
- uint32 flags = DS_RETURN_DNS_NAME;
+ NTSTATUS status;
+ uint32_t flags = DS_RETURN_DNS_NAME;
const char *server_name = cli->cli->desthost;
const char *domain_name = NULL;
const char *client_account = NULL;
- uint32 mask = 0;
+ uint32_t mask = 0;
const char *site_name = NULL;
struct GUID domain_guid = GUID_zero();
- struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
+ struct netr_DsRGetDCNameInfo *info = NULL;
if (argc < 2) {
fprintf(stderr, "Usage: %s [client_account] [acb_mask] "
@@ -232,14 +305,17 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli,
return WERR_OK;
}
- if (argc >= 2)
+ if (argc >= 2) {
client_account = argv[1];
+ }
- if (argc >= 3)
+ if (argc >= 3) {
mask = atoi(argv[2]);
+ }
- if (argc >= 4)
+ if (argc >= 4) {
domain_name = argv[3];
+ }
if (argc >= 5) {
if (!NT_STATUS_IS_OK(GUID_from_string(argv[4], &domain_guid))) {
@@ -247,28 +323,36 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli,
}
}
- if (argc >= 6)
+ if (argc >= 6) {
site_name = argv[5];
+ }
- if (argc >= 7)
+ if (argc >= 7) {
sscanf(argv[6], "%x", &flags);
+ }
debug_dsdcinfo_flags(1,flags);
- result = rpccli_netlogon_dsr_getdcnameex2(cli, mem_ctx, server_name,
- client_account, mask,
- domain_name, &domain_guid,
- site_name, flags,
- &info);
+ status = rpccli_netr_DsRGetDCNameEx2(cli, mem_ctx,
+ server_name,
+ client_account,
+ mask,
+ domain_name,
+ &domain_guid,
+ site_name,
+ flags,
+ &info,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
- if (W_ERROR_IS_OK(result)) {
- d_printf("DsGetDcNameEx2 gave\n");
- display_ds_domain_controller_info(mem_ctx, info);
- return WERR_OK;
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
}
- printf("rpccli_netlogon_dsr_getdcnameex2 returned %s\n",
- dos_errstr(result));
+ d_printf("DsRGetDCNameEx2 gave %s\n",
+ NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info));
return result;
}
@@ -278,20 +362,27 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
- WERROR result;
- char *sitename;
+ WERROR werr;
+ NTSTATUS status;
+ const char *sitename = NULL;
if (argc != 2) {
fprintf(stderr, "Usage: %s computername\n", argv[0]);
return WERR_OK;
}
- result = rpccli_netlogon_dsr_getsitename(cli, mem_ctx, argv[1], &sitename);
+ status = rpccli_netr_DsRGetSiteName(cli, mem_ctx,
+ argv[1],
+ &sitename,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
- if (!W_ERROR_IS_OK(result)) {
+ if (!W_ERROR_IS_OK(werr)) {
printf("rpccli_netlogon_dsr_gesitename returned %s\n",
- nt_errstr(werror_to_ntstatus(result)));
- return result;
+ nt_errstr(werror_to_ntstatus(werr)));
+ return werr;
}
printf("Computer %s is on Site: %s\n", argv[1], sitename);
@@ -299,169 +390,292 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli,
return WERR_OK;
}
-static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
+static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
{
-#if 0
- uint32 query_level = 1;
-#endif
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr;
+ const char *logon_server = cli->cli->desthost;
+ enum netr_LogonControlCode function_code = 1;
+ uint32_t level = 1;
+ union netr_CONTROL_QUERY_INFORMATION info;
+
+ if (argc > 4) {
+ fprintf(stderr, "Usage: %s <logon_server> <function_code> "
+ "<level>\n", argv[0]);
+ return WERR_OK;
+ }
- if (argc > 1) {
- fprintf(stderr, "Usage: %s\n", argv[0]);
- return NT_STATUS_OK;
+ if (argc >= 2) {
+ logon_server = argv[1];
}
-#if 0
- result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level);
- if (!NT_STATUS_IS_OK(result)) {
- goto done;
+ if (argc >= 3) {
+ function_code = atoi(argv[2]);
+ }
+
+ if (argc >= 4) {
+ level = atoi(argv[3]);
+ }
+
+ status = rpccli_netr_LogonControl(cli, mem_ctx,
+ logon_server,
+ function_code,
+ level,
+ &info,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
}
-#endif
/* Display results */
- return result;
+ return werr;
}
/* Display sam synchronisation information */
-static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas,
- SAM_DELTA_CTR *deltas)
+static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r)
{
- fstring name;
- uint32 i, j;
-
- for (i = 0; i < num_deltas; i++) {
- switch (hdr_deltas[i].type) {
- case SAM_DELTA_DOMAIN_INFO:
- unistr2_to_ascii(name,
- &deltas[i].domain_info.uni_dom_name,
- sizeof(name));
- printf("Domain: %s\n", name);
- break;
- case SAM_DELTA_GROUP_INFO:
- unistr2_to_ascii(name,
- &deltas[i].group_info.uni_grp_name,
- sizeof(name));
- printf("Group: %s\n", name);
- break;
- case SAM_DELTA_ACCOUNT_INFO:
- unistr2_to_ascii(name,
- &deltas[i].account_info.uni_acct_name,
- sizeof(name));
- printf("Account: %s\n", name);
- break;
- case SAM_DELTA_ALIAS_INFO:
- unistr2_to_ascii(name,
- &deltas[i].alias_info.uni_als_name,
- sizeof(name));
- printf("Alias: %s\n", name);
- break;
- case SAM_DELTA_ALIAS_MEM: {
- SAM_ALIAS_MEM_INFO *alias = &deltas[i].als_mem_info;
-
- for (j = 0; j < alias->num_members; j++) {
- fstring sid_str;
-
- sid_to_fstring(sid_str, &alias->sids[j].sid);
-
- printf("%s\n", sid_str);
- }
- break;
- }
- case SAM_DELTA_GROUP_MEM: {
- SAM_GROUP_MEM_INFO *group = &deltas[i].grp_mem_info;
-
- for (j = 0; j < group->num_members; j++)
- printf("rid 0x%x, attrib 0x%08x\n",
- group->rids[j], group->attribs[j]);
- break;
- }
- case SAM_DELTA_MODIFIED_COUNT: {
- SAM_DELTA_MOD_COUNT *mc = &deltas[i].mod_count;
-
- printf("sam sequence update: 0x%04x\n", mc->seqnum);
- break;
- }
- default:
- printf("unknown delta type 0x%02x\n",
- hdr_deltas[i].type);
- break;
- }
- }
+ uint32_t i, j;
+
+ for (i=0; i < r->num_deltas; i++) {
+
+ union netr_DELTA_UNION u = r->delta_enum[i].delta_union;
+ union netr_DELTA_ID_UNION id = r->delta_enum[i].delta_id_union;
+
+ switch (r->delta_enum[i].delta_type) {
+ case NETR_DELTA_DOMAIN:
+ printf("Domain: %s\n",
+ u.domain->domain_name.string);
+ break;
+ case NETR_DELTA_GROUP:
+ printf("Group: %s\n",
+ u.group->group_name.string);
+ break;
+ case NETR_DELTA_DELETE_GROUP:
+ printf("Delete Group: %d\n",
+ u.delete_account.unknown);
+ break;
+ case NETR_DELTA_RENAME_GROUP:
+ printf("Rename Group: %s -> %s\n",
+ u.rename_group->OldName.string,
+ u.rename_group->NewName.string);
+ break;
+ case NETR_DELTA_USER:
+ printf("Account: %s\n",
+ u.user->account_name.string);
+ break;
+ case NETR_DELTA_DELETE_USER:
+ printf("Delete User: %d\n",
+ id.rid);
+ break;
+ case NETR_DELTA_RENAME_USER:
+ printf("Rename user: %s -> %s\n",
+ u.rename_user->OldName.string,
+ u.rename_user->NewName.string);
+ break;
+ case NETR_DELTA_GROUP_MEMBER:
+ for (j=0; j < u.group_member->num_rids; j++) {
+ printf("rid 0x%x, attrib 0x%08x\n",
+ u.group_member->rids[j],
+ u.group_member->attribs[j]);
+ }
+ break;
+ case NETR_DELTA_ALIAS:
+ printf("Alias: %s\n",
+ u.alias->alias_name.string);
+ break;
+ case NETR_DELTA_DELETE_ALIAS:
+ printf("Delete Alias: %d\n",
+ r->delta_enum[i].delta_id_union.rid);
+ break;
+ case NETR_DELTA_RENAME_ALIAS:
+ printf("Rename alias: %s -> %s\n",
+ u.rename_alias->OldName.string,
+ u.rename_alias->NewName.string);
+ break;
+ case NETR_DELTA_ALIAS_MEMBER:
+ for (j=0; j < u.alias_member->sids.num_sids; j++) {
+ fstring sid_str;
+ sid_to_fstring(sid_str,
+ u.alias_member->sids.sids[j].sid);
+ printf("%s\n", sid_str);
+ }
+ break;
+ case NETR_DELTA_POLICY:
+ printf("Policy\n");
+ break;
+ case NETR_DELTA_TRUSTED_DOMAIN:
+ printf("Trusted Domain: %s\n",
+ u.trusted_domain->domain_name.string);
+ break;
+ case NETR_DELTA_DELETE_TRUST:
+ printf("Delete Trust: %d\n",
+ u.delete_trust.unknown);
+ break;
+ case NETR_DELTA_ACCOUNT:
+ printf("Account\n");
+ break;
+ case NETR_DELTA_DELETE_ACCOUNT:
+ printf("Delete Account: %d\n",
+ u.delete_account.unknown);
+ break;
+ case NETR_DELTA_SECRET:
+ printf("Secret\n");
+ break;
+ case NETR_DELTA_DELETE_SECRET:
+ printf("Delete Secret: %d\n",
+ u.delete_secret.unknown);
+ break;
+ case NETR_DELTA_DELETE_GROUP2:
+ printf("Delete Group2: %s\n",
+ u.delete_group->account_name);
+ break;
+ case NETR_DELTA_DELETE_USER2:
+ printf("Delete User2: %s\n",
+ u.delete_user->account_name);
+ break;
+ case NETR_DELTA_MODIFY_COUNT:
+ printf("sam sequence update: 0x%016llx\n",
+ (unsigned long long) *u.modified_count);
+ break;
+ default:
+ printf("unknown delta type 0x%02x\n",
+ r->delta_enum[i].delta_type);
+ break;
+ }
+ }
}
/* Perform sam synchronisation */
-static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 database_id = 0, num_deltas;
- SAM_DELTA_HDR *hdr_deltas;
- SAM_DELTA_CTR *deltas;
+ const char *logon_server = cli->cli->desthost;
+ const char *computername = global_myname();
+ struct netr_Authenticator credential;
+ struct netr_Authenticator return_authenticator;
+ enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
+ uint16_t restart_state = 0;
+ uint32_t sync_context = 0;
if (argc > 2) {
fprintf(stderr, "Usage: %s [database_id]\n", argv[0]);
return NT_STATUS_OK;
}
- if (argc == 2)
- database_id = atoi(argv[1]);
+ if (argc == 2) {
+ database_id = atoi(argv[1]);
+ }
- /* Synchronise sam database */
+ /* Synchronise sam database */
+
+ do {
+ struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL;
+
+ netlogon_creds_client_step(cli->dc, &credential);
+
+ result = rpccli_netr_DatabaseSync2(cli, mem_ctx,
+ logon_server,
+ computername,
+ &credential,
+ &return_authenticator,
+ database_id,
+ restart_state,
+ &sync_context,
+ &delta_enum_array,
+ 0xffff);
+
+ /* Check returned credentials. */
+ if (!netlogon_creds_client_check(cli->dc,
+ &return_authenticator.cred)) {
+ DEBUG(0,("credentials chain check failed\n"));
+ return NT_STATUS_ACCESS_DENIED;
+ }
- result = rpccli_netlogon_sam_sync(cli, mem_ctx, database_id,
- 0, &num_deltas, &hdr_deltas, &deltas);
+ if (NT_STATUS_IS_ERR(result)) {
+ break;
+ }
- if (!NT_STATUS_IS_OK(result))
- goto done;
+ /* Display results */
- /* Display results */
+ display_sam_sync(delta_enum_array);
- display_sam_sync(num_deltas, hdr_deltas, deltas);
+ TALLOC_FREE(delta_enum_array);
- done:
- return result;
+ } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
+
+ return result;
}
/* Perform sam delta synchronisation */
-static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
+static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 database_id, num_deltas, tmp;
- SAM_DELTA_HDR *hdr_deltas;
- SAM_DELTA_CTR *deltas;
- uint64 seqnum;
+ uint32_t tmp;
+ const char *logon_server = cli->cli->desthost;
+ const char *computername = global_myname();
+ struct netr_Authenticator credential;
+ struct netr_Authenticator return_authenticator;
+ enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
+ uint64_t sequence_num;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]);
+ return NT_STATUS_OK;
+ }
- if (argc != 3) {
- fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]);
- return NT_STATUS_OK;
- }
+ database_id = atoi(argv[1]);
+ tmp = atoi(argv[2]);
- database_id = atoi(argv[1]);
- tmp = atoi(argv[2]);
+ sequence_num = tmp & 0xffff;
- seqnum = tmp & 0xffff;
+ do {
+ struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL;
- result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id,
- seqnum, &num_deltas,
- &hdr_deltas, &deltas);
+ netlogon_creds_client_step(cli->dc, &credential);
- if (!NT_STATUS_IS_OK(result))
- goto done;
+ result = rpccli_netr_DatabaseDeltas(cli, mem_ctx,
+ logon_server,
+ computername,
+ &credential,
+ &return_authenticator,
+ database_id,
+ &sequence_num,
+ &delta_enum_array,
+ 0xffff);
- /* Display results */
+ /* Check returned credentials. */
+ if (!netlogon_creds_client_check(cli->dc,
+ &return_authenticator.cred)) {
+ DEBUG(0,("credentials chain check failed\n"));
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ if (NT_STATUS_IS_ERR(result)) {
+ break;
+ }
+
+ /* Display results */
+
+ display_sam_sync(delta_enum_array);
+
+ TALLOC_FREE(delta_enum_array);
+
+ } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
- display_sam_sync(num_deltas, hdr_deltas, deltas);
-
- done:
return result;
}
@@ -539,6 +753,254 @@ static NTSTATUS cmd_netlogon_change_trust_pw(struct rpc_pipe_client *cli,
return result;
}
+static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr = WERR_GENERAL_FAILURE;
+ const char *server_name = cli->cli->desthost;
+ const char *domain_name = lp_workgroup();
+ uint32_t rid = 0;
+
+ if (argc < 1 || argc > 3) {
+ fprintf(stderr, "Usage: %s <server_name> <domain_name>\n",
+ argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 2) {
+ server_name = argv[1];
+ }
+
+ if (argc >= 3) {
+ domain_name = argv[2];
+ }
+
+ status = rpccli_netr_LogonGetTrustRid(cli, mem_ctx,
+ server_name,
+ domain_name,
+ &rid,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("Rid: %d\n", rid);
+ }
+ done:
+ return werr;
+}
+
+static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr = WERR_GENERAL_FAILURE;
+ const char *server_name = cli->cli->desthost;
+ uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST;
+ struct netr_DomainTrustList trusts;
+
+ if (argc < 1 || argc > 3) {
+ fprintf(stderr, "Usage: %s <server_name> <trust_flags>\n",
+ argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 2) {
+ server_name = argv[1];
+ }
+
+ if (argc >= 3) {
+ sscanf(argv[2], "%x", &trust_flags);
+ }
+
+ status = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,
+ server_name,
+ trust_flags,
+ &trusts,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ int i;
+
+ printf("%d domains returned\n", trusts.count);
+
+ for (i=0; i<trusts.count; i++ ) {
+ printf("%s (%s)\n",
+ trusts.array[i].dns_name,
+ trusts.array[i].netbios_name);
+ }
+ }
+ done:
+ return werr;
+}
+
+static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr = WERR_GENERAL_FAILURE;
+ const char *server_name = cli->cli->desthost;
+ const char *domain = lp_workgroup();
+ const char *dns_host = NULL;
+
+ if (argc < 1 || argc > 4) {
+ fprintf(stderr, "Usage: %s <server_name> <domain_name> "
+ "<dns_host>\n", argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 2) {
+ server_name = argv[1];
+ }
+
+ if (argc >= 3) {
+ domain = argv[2];
+ }
+
+ if (argc >= 4) {
+ dns_host = argv[3];
+ }
+
+ status = rpccli_netr_DsrDeregisterDNSHostRecords(cli, mem_ctx,
+ server_name,
+ domain,
+ NULL,
+ NULL,
+ dns_host,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("success\n");
+ }
+ done:
+ return werr;
+}
+
+static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr = WERR_GENERAL_FAILURE;
+ const char *server_name = cli->cli->desthost;
+ const char *trusted_domain_name = NULL;
+ struct lsa_ForestTrustInformation *info = NULL;
+ uint32_t flags = 0;
+
+ if (argc < 1 || argc > 4) {
+ fprintf(stderr, "Usage: %s <server_name> <trusted_domain_name> "
+ "<flags>\n", argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 2) {
+ server_name = argv[1];
+ }
+
+ if (argc >= 3) {
+ trusted_domain_name = argv[2];
+ }
+
+ if (argc >= 4) {
+ sscanf(argv[3], "%x", &flags);
+ }
+
+ status = rpccli_netr_DsRGetForestTrustInformation(cli, mem_ctx,
+ server_name,
+ trusted_domain_name,
+ flags,
+ &info,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("success\n");
+ }
+ done:
+ return werr;
+}
+
+static WERROR cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr = WERR_GENERAL_FAILURE;
+ const char *server_name = cli->cli->desthost;
+ struct netr_Blob blob;
+
+
+ if (argc < 1 || argc > 3) {
+ fprintf(stderr, "Usage: %s <server_name>\n", argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 2) {
+ server_name = argv[1];
+ }
+
+ status = rpccli_netr_NetrEnumerateTrustedDomains(cli, mem_ctx,
+ server_name,
+ &blob,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("success\n");
+ dump_data(1, blob.data, blob.length);
+ }
+ done:
+ return werr;
+}
+
+static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ WERROR werr = WERR_GENERAL_FAILURE;
+ const char *server_name = cli->cli->desthost;
+ struct netr_DomainTrustList list;
+
+ if (argc < 1 || argc > 3) {
+ fprintf(stderr, "Usage: %s <server_name>\n", argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 2) {
+ server_name = argv[1];
+ }
+
+ status = rpccli_netr_NetrEnumerateTrustedDomainsEx(cli, mem_ctx,
+ server_name,
+ &list,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("success\n");
+ }
+ done:
+ return werr;
+}
+
/* List of commands exported by this module */
@@ -546,18 +1008,25 @@ struct cmd_set netlogon_commands[] = {
{ "NETLOGON" },
- { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" },
+ { "logonctrl2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl2, PI_NETLOGON, NULL, "Logon Control 2", "" },
{ "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" },
{ "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" },
{ "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" },
{ "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name", "" },
{ "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" },
{ "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" },
- { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" },
+ { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, PI_NETLOGON, NULL, "Get Forest Trust Info", "" },
+ { "logonctrl", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl, PI_NETLOGON, NULL, "Logon Control", "" },
{ "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" },
{ "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" },
{ "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" },
{ "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" },
+ { "gettrustrid", RPC_RTYPE_WERROR, NULL, cmd_netlogon_gettrustrid, PI_NETLOGON, NULL, "Get trust rid", "" },
+ { "dsr_enumtrustdom", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate trusted domains", "" },
+ { "dsenumdomtrusts", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" },
+ { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, PI_NETLOGON, NULL, "Deregister DNS records", "" },
+ { "netrenumtrusteddomains", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomains, PI_NETLOGON, NULL, "Enumerate trusted domains", "" },
+ { "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, PI_NETLOGON, NULL, "Enumerate trusted domains", "" },
{ NULL }
};
diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c
new file mode 100644
index 0000000000..b7b37e2fa6
--- /dev/null
+++ b/source3/rpcclient/cmd_ntsvcs.c
@@ -0,0 +1,189 @@
+/*
+ Unix SMB/CIFS implementation.
+ RPC pipe client
+
+ Copyright (C) Günther Deschner 2008
+
+ 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 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "rpcclient.h"
+
+static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ WERROR werr;
+ uint16_t version;
+
+ status = rpccli_PNP_GetVersion(cli, mem_ctx,
+ &version, &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("version: %d\n", version);
+ }
+
+ return werr;
+}
+
+static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ WERROR werr;
+ const char *devicepath = NULL;
+ uint32_t flags = 0;
+
+ if (argc < 2 || argc > 3) {
+ printf("usage: %s [devicepath] <flags>\n", argv[0]);
+ return WERR_OK;
+ }
+
+ devicepath = argv[1];
+
+ if (argc >= 3) {
+ flags = atoi(argv[2]);
+ }
+
+ status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx,
+ devicepath,
+ flags,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ return werr;
+}
+
+static WERROR cmd_ntsvcs_get_device_list_size(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ WERROR werr;
+ const char *devicename = NULL;
+ uint32_t flags = 0;
+ uint32_t size = 0;
+
+ if (argc < 2 || argc > 4) {
+ printf("usage: %s [devicename] <flags>\n", argv[0]);
+ return WERR_OK;
+ }
+
+ devicename = argv[1];
+
+ if (argc >= 3) {
+ flags = atoi(argv[2]);
+ }
+
+ status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx,
+ devicename,
+ &size,
+ flags,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ if (W_ERROR_IS_OK(werr)) {
+ printf("size: %d\n", size);
+ }
+
+ return werr;
+}
+
+static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ WERROR werr;
+ const char *devicepath = NULL;
+ uint32_t unk3 = 0;
+ uint16_t unk4 = 0;
+ const char *unk5 = NULL;
+ const char *unk5a = NULL;
+
+ if (argc < 2) {
+ printf("usage: %s [devicepath]\n", argv[0]);
+ return WERR_OK;
+ }
+
+ devicepath = argv[1];
+
+ status = rpccli_PNP_HwProfFlags(cli, mem_ctx,
+ 0,
+ devicepath,
+ 0,
+ &unk3,
+ &unk4,
+ unk5,
+ &unk5a,
+ 0,
+ 0,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ return werr;
+}
+
+static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ WERROR werr;
+ uint32_t idx = 0;
+ struct PNP_HwProfInfo info;
+ uint32_t unknown1 = 0, unknown2 = 0;
+
+ ZERO_STRUCT(info);
+
+ status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx,
+ idx,
+ &info,
+ unknown1,
+ unknown2,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+
+ return werr;
+}
+
+struct cmd_set ntsvcs_commands[] = {
+
+ { "NTSVCS" },
+ { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" },
+ { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" },
+ { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" },
+ { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, PI_NTSVCS, NULL, "Query NTSVCS HW prof flags", "" },
+ { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_hw_prof_info, PI_NTSVCS, NULL, "Query NTSVCS HW prof info", "" },
+ { NULL }
+};
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 15e180df01..2d20afeb13 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
RPC pipe client
@@ -6,17 +6,18 @@
Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
Copyright (C) Elrond 2000,
Copyright (C) Tim Potter 2000
+ Copyright (C) Guenther Deschner 2008
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 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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, see <http://www.gnu.org/licenses/>.
*/
@@ -27,381 +28,327 @@
extern DOM_SID domain_sid;
/****************************************************************************
- display sam_user_info_7 structure
+ display samr_user_info_7 structure
****************************************************************************/
-static void display_sam_user_info_7(SAM_USER_INFO_7 *usr)
+static void display_samr_user_info_7(struct samr_UserInfo7 *r)
{
- fstring temp;
-
- unistr2_to_ascii(temp, &usr->uni_name, sizeof(temp));
- printf("\tUser Name :\t%s\n", temp);
+ printf("\tUser Name :\t%s\n", r->account_name.string);
}
/****************************************************************************
- display sam_user_info_9 structure
+ display samr_user_info_9 structure
****************************************************************************/
-static void display_sam_user_info_9(SAM_USER_INFO_9 *usr)
+static void display_samr_user_info_9(struct samr_UserInfo9 *r)
{
- printf("\tPrimary group RID :\tox%x\n", usr->rid_group);
+ printf("\tPrimary group RID :\tox%x\n", r->primary_gid);
}
/****************************************************************************
- display sam_user_info_16 structure
+ display samr_user_info_16 structure
****************************************************************************/
-static void display_sam_user_info_16(SAM_USER_INFO_16 *usr)
+static void display_samr_user_info_16(struct samr_UserInfo16 *r)
{
- printf("\tAcct Flags :\tox%x\n", usr->acb_info);
+ printf("\tAcct Flags :\tox%x\n", r->acct_flags);
}
/****************************************************************************
- display sam_user_info_21 structure
+ display samr_user_info_21 structure
****************************************************************************/
-static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
+static void display_samr_user_info_21(struct samr_UserInfo21 *r)
{
- fstring temp;
-
- unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp));
- printf("\tUser Name :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp));
- printf("\tFull Name :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp));
- printf("\tHome Drive :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp));
- printf("\tDir Drive :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp));
- printf("\tProfile Path:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp));
- printf("\tLogon Script:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp));
- printf("\tDescription :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp));
- printf("\tWorkstations:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_comment, sizeof(temp));
- printf("\tUnknown Str :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp));
- printf("\tRemote Dial :\t%s\n", temp);
-
- printf("\tLogon Time :\t%s\n",
- http_timestring(nt_time_to_unix(usr->logon_time)));
- printf("\tLogoff Time :\t%s\n",
- http_timestring(nt_time_to_unix(usr->logoff_time)));
- printf("\tKickoff Time :\t%s\n",
- http_timestring(nt_time_to_unix(usr->kickoff_time)));
- printf("\tPassword last set Time :\t%s\n",
- http_timestring(nt_time_to_unix(usr->pass_last_set_time)));
- printf("\tPassword can change Time :\t%s\n",
- http_timestring(nt_time_to_unix(usr->pass_can_change_time)));
- printf("\tPassword must change Time:\t%s\n",
- http_timestring(nt_time_to_unix(usr->pass_must_change_time)));
-
+ printf("\tUser Name :\t%s\n", r->account_name.string);
+ printf("\tFull Name :\t%s\n", r->full_name.string);
+ printf("\tHome Drive :\t%s\n", r->home_directory.string);
+ printf("\tDir Drive :\t%s\n", r->home_drive.string);
+ printf("\tProfile Path:\t%s\n", r->profile_path.string);
+ printf("\tLogon Script:\t%s\n", r->logon_script.string);
+ printf("\tDescription :\t%s\n", r->description.string);
+ printf("\tWorkstations:\t%s\n", r->workstations.string);
+ printf("\tComment :\t%s\n", r->comment.string);
+ printf("\tRemote Dial :\t%s\n", r->parameters.string);
+
+ printf("\tLogon Time :\t%s\n",
+ http_timestring(nt_time_to_unix(r->last_logon)));
+ printf("\tLogoff Time :\t%s\n",
+ http_timestring(nt_time_to_unix(r->last_logoff)));
+ printf("\tKickoff Time :\t%s\n",
+ http_timestring(nt_time_to_unix(r->acct_expiry)));
+ printf("\tPassword last set Time :\t%s\n",
+ http_timestring(nt_time_to_unix(r->last_password_change)));
+ printf("\tPassword can change Time :\t%s\n",
+ http_timestring(nt_time_to_unix(r->allow_password_change)));
+ printf("\tPassword must change Time:\t%s\n",
+ http_timestring(nt_time_to_unix(r->force_password_change)));
+
printf("\tunknown_2[0..31]...\n"); /* user passwords? */
-
- printf("\tuser_rid :\t0x%x\n" , usr->user_rid ); /* User ID */
- printf("\tgroup_rid:\t0x%x\n" , usr->group_rid); /* Group ID */
- printf("\tacb_info :\t0x%08x\n", usr->acb_info ); /* Account Control Info */
-
- printf("\tfields_present:\t0x%08x\n", usr->fields_present); /* 0x00ff ffff */
- printf("\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
- printf("\tbad_password_count:\t0x%08x\n", usr->bad_password_count);
- printf("\tlogon_count:\t0x%08x\n", usr->logon_count);
-
+
+ printf("\tuser_rid :\t0x%x\n" , r->rid); /* User ID */
+ printf("\tgroup_rid:\t0x%x\n" , r->primary_gid); /* Group ID */
+ printf("\tacb_info :\t0x%08x\n", r->acct_flags); /* Account Control Info */
+
+ printf("\tfields_present:\t0x%08x\n", r->fields_present); /* 0x00ff ffff */
+ printf("\tlogon_divs:\t%d\n", r->logon_hours.units_per_week); /* 0x0000 00a8 which is 168 which is num hrs in a week */
+ printf("\tbad_password_count:\t0x%08x\n", r->bad_password_count);
+ printf("\tlogon_count:\t0x%08x\n", r->logon_count);
+
printf("\tpadding1[0..7]...\n");
-
- if (usr->ptr_logon_hrs) {
- printf("\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
+
+ if (r->logon_hours.bits) {
+ printf("\tlogon_hrs[0..%d]...\n", r->logon_hours.units_per_week/8);
}
}
-static void display_password_properties(uint32 password_properties)
+static void display_password_properties(uint32_t password_properties)
{
printf("password_properties: 0x%08x\n", password_properties);
-
+
if (password_properties & DOMAIN_PASSWORD_COMPLEX)
printf("\tDOMAIN_PASSWORD_COMPLEX\n");
-
+
if (password_properties & DOMAIN_PASSWORD_NO_ANON_CHANGE)
printf("\tDOMAIN_PASSWORD_NO_ANON_CHANGE\n");
-
+
if (password_properties & DOMAIN_PASSWORD_NO_CLEAR_CHANGE)
printf("\tDOMAIN_PASSWORD_NO_CLEAR_CHANGE\n");
-
- if (password_properties & DOMAIN_LOCKOUT_ADMINS)
- printf("\tDOMAIN_LOCKOUT_ADMINS\n");
-
+
+ if (password_properties & DOMAIN_PASSWORD_LOCKOUT_ADMINS)
+ printf("\tDOMAIN_PASSWORD_LOCKOUT_ADMINS\n");
+
if (password_properties & DOMAIN_PASSWORD_STORE_CLEARTEXT)
printf("\tDOMAIN_PASSWORD_STORE_CLEARTEXT\n");
-
+
if (password_properties & DOMAIN_REFUSE_PASSWORD_CHANGE)
printf("\tDOMAIN_REFUSE_PASSWORD_CHANGE\n");
}
-static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1)
+static void display_sam_dom_info_1(struct samr_DomInfo1 *info1)
{
-
- printf("Minimum password length:\t\t\t%d\n", info1->min_length_password);
- printf("Password uniqueness (remember x passwords):\t%d\n", info1->password_history);
+ printf("Minimum password length:\t\t\t%d\n",
+ info1->min_password_length);
+ printf("Password uniqueness (remember x passwords):\t%d\n",
+ info1->password_history_length);
display_password_properties(info1->password_properties);
- printf("password expire in:\t\t\t\t%s\n", display_time(info1->expire));
- printf("Min password age (allow changing in x days):\t%s\n", display_time(info1->min_passwordage));
+ printf("password expire in:\t\t\t\t%s\n",
+ display_time(info1->max_password_age));
+ printf("Min password age (allow changing in x days):\t%s\n",
+ display_time(info1->min_password_age));
}
-static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2)
+static void display_sam_dom_info_2(struct samr_DomInfo2 *info2)
{
- fstring name;
-
- unistr2_to_ascii(name, &info2->uni_domain, sizeof(name));
- printf("Domain:\t\t%s\n", name);
-
- unistr2_to_ascii(name, &info2->uni_server, sizeof(name));
- printf("Server:\t\t%s\n", name);
+ printf("Domain:\t\t%s\n", info2->domain_name.string);
+ printf("Server:\t\t%s\n", info2->primary.string);
+ printf("Comment:\t%s\n", info2->comment.string);
- unistr2_to_ascii(name, &info2->uni_comment, sizeof(name));
- printf("Comment:\t%s\n", name);
+ printf("Total Users:\t%d\n", info2->num_users);
+ printf("Total Groups:\t%d\n", info2->num_groups);
+ printf("Total Aliases:\t%d\n", info2->num_aliases);
- printf("Total Users:\t%d\n", info2->num_domain_usrs);
- printf("Total Groups:\t%d\n", info2->num_domain_grps);
- printf("Total Aliases:\t%d\n", info2->num_local_grps);
-
- printf("Sequence No:\t%llu\n", (unsigned long long)info2->seq_num);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info2->sequence_num);
- printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info2->logout));
+ printf("Force Logoff:\t%d\n",
+ (int)nt_time_to_unix_abs(&info2->force_logoff_time));
- printf("Unknown 4:\t0x%x\n", info2->unknown_4);
- printf("Server Role:\t%s\n", server_role_str(info2->server_role));
- printf("Unknown 6:\t0x%x\n", info2->unknown_6);
+ printf("Unknown 2:\t0x%x\n", info2->unknown2);
+ printf("Server Role:\t%s\n", server_role_str(info2->role));
+ printf("Unknown 3:\t0x%x\n", info2->unknown3);
}
-static void display_sam_unk_info_3(SAM_UNK_INFO_3 *info3)
+static void display_sam_dom_info_3(struct samr_DomInfo3 *info3)
{
- printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info3->logout));
+ printf("Force Logoff:\t%d\n",
+ (int)nt_time_to_unix_abs(&info3->force_logoff_time));
}
-static void display_sam_unk_info_4(SAM_UNK_INFO_4 *info4)
+static void display_sam_dom_info_4(struct samr_DomInfo4 *info4)
{
- fstring name;
-
- unistr2_to_ascii(name, &info4->uni_comment, sizeof(name));
- printf("Comment:\t%s\n", name);
+ printf("Comment:\t%s\n", info4->comment.string);
}
-static void display_sam_unk_info_5(SAM_UNK_INFO_5 *info5)
+static void display_sam_dom_info_5(struct samr_DomInfo5 *info5)
{
- fstring name;
-
- unistr2_to_ascii(name, &info5->uni_domain, sizeof(name));
- printf("Domain:\t\t%s\n", name);
+ printf("Domain:\t\t%s\n", info5->domain_name.string);
}
-static void display_sam_unk_info_6(SAM_UNK_INFO_6 *info6)
+static void display_sam_dom_info_6(struct samr_DomInfo6 *info6)
{
- fstring name;
-
- unistr2_to_ascii(name, &info6->uni_server, sizeof(name));
- printf("Server:\t\t%s\n", name);
+ printf("Server:\t\t%s\n", info6->primary.string);
}
-static void display_sam_unk_info_7(SAM_UNK_INFO_7 *info7)
+static void display_sam_dom_info_7(struct samr_DomInfo7 *info7)
{
- printf("Server Role:\t%s\n", server_role_str(info7->server_role));
+ printf("Server Role:\t%s\n", server_role_str(info7->role));
}
-static void display_sam_unk_info_8(SAM_UNK_INFO_8 *info8)
+static void display_sam_dom_info_8(struct samr_DomInfo8 *info8)
{
- printf("Sequence No:\t%llu\n", (unsigned long long)info8->seq_num);
- printf("Domain Create Time:\t%s\n",
+ printf("Sequence No:\t%llu\n", (unsigned long long)info8->sequence_num);
+ printf("Domain Create Time:\t%s\n",
http_timestring(nt_time_to_unix(info8->domain_create_time)));
}
-static void display_sam_unk_info_9(SAM_UNK_INFO_9 *info9)
+static void display_sam_dom_info_9(struct samr_DomInfo9 *info9)
{
printf("unknown:\t%d (0x%08x)\n", info9->unknown, info9->unknown);
}
-static void display_sam_unk_info_12(SAM_UNK_INFO_12 *info12)
+static void display_sam_dom_info_12(struct samr_DomInfo12 *info12)
{
- printf("Bad password lockout duration: %s\n", display_time(info12->duration));
- printf("Reset Lockout after: %s\n", display_time(info12->reset_count));
- printf("Lockout after bad attempts: %d\n", info12->bad_attempt_lockout);
+ printf("Bad password lockout duration: %s\n",
+ display_time(info12->lockout_duration));
+ printf("Reset Lockout after: %s\n",
+ display_time(info12->lockout_window));
+ printf("Lockout after bad attempts: %d\n",
+ info12->lockout_threshold);
}
-static void display_sam_unk_info_13(SAM_UNK_INFO_13 *info13)
+static void display_sam_dom_info_13(struct samr_DomInfo13 *info13)
{
- printf("Sequence No:\t%llu\n", (unsigned long long)info13->seq_num);
- printf("Domain Create Time:\t%s\n",
+ printf("Sequence No:\t%llu\n", (unsigned long long)info13->sequence_num);
+ printf("Domain Create Time:\t%s\n",
http_timestring(nt_time_to_unix(info13->domain_create_time)));
printf("Unknown1:\t%d\n", info13->unknown1);
printf("Unknown2:\t%d\n", info13->unknown2);
}
-static void display_sam_info_1(SAM_ENTRY1 *e1, SAM_STR1 *s1)
+static void display_sam_info_1(struct samr_DispEntryGeneral *r)
{
- fstring tmp;
-
- printf("index: 0x%x ", e1->user_idx);
- printf("RID: 0x%x ", e1->rid_user);
- printf("acb: 0x%x ", e1->acb_info);
-
- unistr2_to_ascii(tmp, &s1->uni_acct_name, sizeof(tmp));
- printf("Account: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s1->uni_full_name, sizeof(tmp));
- printf("Name: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s1->uni_acct_desc, sizeof(tmp));
- printf("Desc: %s\n", tmp);
+ printf("index: 0x%x ", r->idx);
+ printf("RID: 0x%x ", r->rid);
+ printf("acb: 0x%08x ", r->acct_flags);
+ printf("Account: %s\t", r->account_name.string);
+ printf("Name: %s\t", r->full_name.string);
+ printf("Desc: %s\n", r->description.string);
}
-static void display_sam_info_2(SAM_ENTRY2 *e2, SAM_STR2 *s2)
+static void display_sam_info_2(struct samr_DispEntryFull *r)
{
- fstring tmp;
-
- printf("index: 0x%x ", e2->user_idx);
- printf("RID: 0x%x ", e2->rid_user);
- printf("acb: 0x%x ", e2->acb_info);
-
- unistr2_to_ascii(tmp, &s2->uni_srv_name, sizeof(tmp));
- printf("Account: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s2->uni_srv_desc, sizeof(tmp));
- printf("Name: %s\n", tmp);
-
+ printf("index: 0x%x ", r->idx);
+ printf("RID: 0x%x ", r->rid);
+ printf("acb: 0x%08x ", r->acct_flags);
+ printf("Account: %s\t", r->account_name.string);
+ printf("Desc: %s\n", r->description.string);
}
-static void display_sam_info_3(SAM_ENTRY3 *e3, SAM_STR3 *s3)
+static void display_sam_info_3(struct samr_DispEntryFullGroup *r)
{
- fstring tmp;
-
- printf("index: 0x%x ", e3->grp_idx);
- printf("RID: 0x%x ", e3->rid_grp);
- printf("attr: 0x%x ", e3->attr);
-
- unistr2_to_ascii(tmp, &s3->uni_grp_name, sizeof(tmp));
- printf("Account: %s\t", tmp);
-
- unistr2_to_ascii(tmp, &s3->uni_grp_desc, sizeof(tmp));
- printf("Name: %s\n", tmp);
-
+ printf("index: 0x%x ", r->idx);
+ printf("RID: 0x%x ", r->rid);
+ printf("acb: 0x%08x ", r->acct_flags);
+ printf("Account: %s\t", r->account_name.string);
+ printf("Desc: %s\n", r->description.string);
}
-static void display_sam_info_4(SAM_ENTRY4 *e4, SAM_STR4 *s4)
+static void display_sam_info_4(struct samr_DispEntryAscii *r)
{
- int i;
-
- printf("index: %d ", e4->user_idx);
-
- printf("Account: ");
- for (i=0; i<s4->acct_name.str_str_len; i++)
- printf("%c", s4->acct_name.buffer[i]);
- printf("\n");
-
+ printf("index: 0x%x ", r->idx);
+ printf("Account: %s\n", r->account_name.string);
}
-static void display_sam_info_5(SAM_ENTRY5 *e5, SAM_STR5 *s5)
+static void display_sam_info_5(struct samr_DispEntryAscii *r)
{
- int i;
-
- printf("index: 0x%x ", e5->grp_idx);
-
- printf("Account: ");
- for (i=0; i<s5->grp_name.str_str_len; i++)
- printf("%c", s5->grp_name.buffer[i]);
- printf("\n");
-
+ printf("index: 0x%x ", r->idx);
+ printf("Account: %s\n", r->account_name.string);
}
/****************************************************************************
- Try samr_connect4 first, then samr_conenct if it fails
+ Try samr_connect4 first, then samr_connect2 if it fails
****************************************************************************/
-static NTSTATUS try_samr_connects(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+static NTSTATUS try_samr_connects(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 access_mask, POLICY_HND *connect_pol)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- result = rpccli_samr_connect4(cli, mem_ctx, access_mask, connect_pol);
+
+ result = rpccli_samr_Connect4(cli, mem_ctx,
+ cli->cli->desthost,
+ SAMR_CONNECT_W2K,
+ access_mask,
+ connect_pol);
if (!NT_STATUS_IS_OK(result)) {
- result = rpccli_samr_connect(cli, mem_ctx, access_mask,
- connect_pol);
+ result = rpccli_samr_Connect2(cli, mem_ctx,
+ cli->cli->desthost,
+ access_mask,
+ connect_pol);
}
return result;
}
/**********************************************************************
- * Query user information
+ * Query user information
*/
-static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 info_level = 21;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- SAM_USERINFO_CTR *user_ctr;
+ union samr_UserInfo *info = NULL;
fstring server;
uint32 user_rid = 0;
-
+
if ((argc < 2) || (argc > 4)) {
printf("Usage: %s rid [info level] [access mask] \n", argv[0]);
return NT_STATUS_OK;
}
-
+
sscanf(argv[1], "%i", &user_rid);
-
+
if (argc > 2)
sscanf(argv[2], "%i", &info_level);
-
+
if (argc > 3)
sscanf(argv[3], "%x", &access_mask);
-
+
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
-
+
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
-
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- access_mask,
- user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ user_rid,
+ &user_pol);
if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER) &&
(user_rid == 0)) {
/* Probably this was a user name, try lookupnames */
- uint32 num_rids;
- uint32 *rids, *types;
-
- result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- 1000, 1, &argv[1],
- &num_rids, &rids,
- &types);
+ struct samr_Ids rids, types;
+ struct lsa_String lsa_acct_name;
+
+ init_lsa_String(&lsa_acct_name, argv[1]);
+
+ result = rpccli_samr_LookupNames(cli, mem_ctx,
+ &domain_pol,
+ 1,
+ &lsa_acct_name,
+ &rids,
+ &types);
if (NT_STATUS_IS_OK(result)) {
- result = rpccli_samr_open_user(cli, mem_ctx,
- &domain_pol,
- access_mask,
- rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ rids.ids[0],
+ &user_pol);
}
}
@@ -409,35 +356,35 @@ static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- ZERO_STRUCT(user_ctr);
-
- result = rpccli_samr_query_userinfo(cli, mem_ctx, &user_pol,
- info_level, &user_ctr);
+ result = rpccli_samr_QueryUserInfo(cli, mem_ctx,
+ &user_pol,
+ info_level,
+ &info);
if (!NT_STATUS_IS_OK(result))
goto done;
- switch (user_ctr->switch_value) {
+ switch (info_level) {
case 7:
- display_sam_user_info_7(user_ctr->info.id7);
+ display_samr_user_info_7(&info->info7);
break;
case 9:
- display_sam_user_info_9(user_ctr->info.id9);
+ display_samr_user_info_9(&info->info9);
break;
case 16:
- display_sam_user_info_16(user_ctr->info.id16);
+ display_samr_user_info_16(&info->info16);
break;
case 21:
- display_sam_user_info_21(user_ctr->info.id21);
+ display_samr_user_info_21(&info->info21);
break;
default:
printf("Unsupported infolevel: %d\n", info_level);
break;
}
- rpccli_samr_close(cli, mem_ctx, &user_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &user_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
@@ -446,115 +393,101 @@ done:
/****************************************************************************
display group info
****************************************************************************/
-static void display_group_info1(GROUP_INFO1 *info1)
+static void display_group_info1(struct samr_GroupInfoAll *info1)
{
- fstring temp;
-
- unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp));
- printf("\tGroup Name:\t%s\n", temp);
- unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp));
- printf("\tDescription:\t%s\n", temp);
- printf("\tGroup Attribute:%d\n", info1->group_attr);
+ printf("\tGroup Name:\t%s\n", info1->name.string);
+ printf("\tDescription:\t%s\n", info1->description.string);
+ printf("\tGroup Attribute:%d\n", info1->attributes);
printf("\tNum Members:%d\n", info1->num_members);
}
/****************************************************************************
display group info
****************************************************************************/
-static void display_group_info2(GROUP_INFO2 *info2)
+static void display_group_info2(struct lsa_String *info2)
{
- fstring name;
-
- unistr2_to_ascii(name, &info2->uni_acct_name, sizeof(name));
- printf("\tGroup Description:%s\n", name);
+ printf("\tGroup Description:%s\n", info2->string);
}
/****************************************************************************
display group info
****************************************************************************/
-static void display_group_info3(GROUP_INFO3 *info3)
+static void display_group_info3(struct samr_GroupInfoAttributes *info3)
{
- printf("\tGroup Attribute:%d\n", info3->group_attr);
+ printf("\tGroup Attribute:%d\n", info3->attributes);
}
/****************************************************************************
display group info
****************************************************************************/
-static void display_group_info4(GROUP_INFO4 *info4)
+static void display_group_info4(struct lsa_String *info4)
{
- fstring desc;
-
- unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc));
- printf("\tGroup Description:%s\n", desc);
+ printf("\tGroup Description:%s\n", info4->string);
}
/****************************************************************************
display group info
****************************************************************************/
-static void display_group_info5(GROUP_INFO5 *info5)
+static void display_group_info5(struct samr_GroupInfoAll *info5)
{
- fstring temp;
-
- unistr2_to_ascii(temp, &info5->uni_acct_name, sizeof(temp));
- printf("\tGroup Name:\t%s\n", temp);
- unistr2_to_ascii(temp, &info5->uni_acct_desc, sizeof(temp));
- printf("\tDescription:\t%s\n", temp);
- printf("\tGroup Attribute:%d\n", info5->group_attr);
+ printf("\tGroup Name:\t%s\n", info5->name.string);
+ printf("\tDescription:\t%s\n", info5->description.string);
+ printf("\tGroup Attribute:%d\n", info5->attributes);
printf("\tNum Members:%d\n", info5->num_members);
}
/****************************************************************************
display sam sync structure
****************************************************************************/
-static void display_group_info_ctr(GROUP_INFO_CTR *ctr)
+static void display_group_info(union samr_GroupInfo *info,
+ enum samr_GroupInfoEnum level)
{
- switch (ctr->switch_value1) {
+ switch (level) {
case 1:
- display_group_info1(&ctr->group.info1);
+ display_group_info1(&info->all);
break;
case 2:
- display_group_info2(&ctr->group.info2);
+ display_group_info2(&info->name);
break;
case 3:
- display_group_info3(&ctr->group.info3);
+ display_group_info3(&info->attributes);
break;
case 4:
- display_group_info4(&ctr->group.info4);
+ display_group_info4(&info->description);
break;
case 5:
- display_group_info5(&ctr->group.info5);
+ display_group_info5(&info->all2);
break;
-
}
}
/***********************************************************************
- * Query group information
+ * Query group information
*/
-static NTSTATUS cmd_samr_query_group(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_group(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, group_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 info_level = 1;
+ enum samr_GroupInfoEnum info_level = GROUPINFOALL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- GROUP_INFO_CTR *group_ctr;
- fstring server;
+ union samr_GroupInfo *group_info = NULL;
+ fstring server;
uint32 group_rid;
-
+
if ((argc < 2) || (argc > 4)) {
printf("Usage: %s rid [info level] [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
sscanf(argv[1], "%i", &group_rid);
-
+
if (argc > 2)
- sscanf(argv[2], "%i", &info_level);
-
+ info_level = atoi(argv[2]);
+
if (argc > 3)
sscanf(argv[3], "%x", &access_mask);
@@ -567,118 +500,128 @@ static NTSTATUS cmd_samr_query_group(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
- access_mask,
- group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_groupinfo(cli, mem_ctx, &group_pol,
- info_level, &group_ctr);
+ result = rpccli_samr_QueryGroupInfo(cli, mem_ctx,
+ &group_pol,
+ info_level,
+ &group_info);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- display_group_info_ctr(group_ctr);
+ display_group_info(group_info, info_level);
- rpccli_samr_close(cli, mem_ctx, &group_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &group_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Query groups a user is a member of */
-static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
- POLICY_HND connect_pol,
- domain_pol,
+ POLICY_HND connect_pol,
+ domain_pol,
user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 num_groups,
- user_rid;
+ uint32 user_rid;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- DOM_GID *user_gids;
int i;
fstring server;
-
+ struct samr_RidWithAttributeArray *rid_array = NULL;
+
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s rid [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
sscanf(argv[1], "%i", &user_rid);
-
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
-
+
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- access_mask,
- user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_usergroups(cli, mem_ctx, &user_pol,
- &num_groups, &user_gids);
+ result = rpccli_samr_GetGroupsForUser(cli, mem_ctx,
+ &user_pol,
+ &rid_array);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_groups; i++) {
- printf("\tgroup rid:[0x%x] attr:[0x%x]\n",
- user_gids[i].g_rid, user_gids[i].attr);
+ for (i = 0; i < rid_array->count; i++) {
+ printf("\tgroup rid:[0x%x] attr:[0x%x]\n",
+ rid_array->rids[i].rid,
+ rid_array->rids[i].attributes);
}
- rpccli_samr_close(cli, mem_ctx, &user_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &user_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Query aliases a user is a member of */
-static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_SID *sids;
size_t num_sids;
- uint32 num_aliases, *alias_rids;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
int i;
fstring server;
- DOM_SID2 *sid2;
+ struct lsa_SidArray sid_array;
+ struct samr_Ids alias_rids;
if (argc < 3) {
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
@@ -701,21 +644,25 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
}
if (num_sids) {
- sid2 = TALLOC_ARRAY(mem_ctx, DOM_SID2, num_sids);
- if (sid2 == NULL)
+ sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
+ if (sid_array.sids == NULL)
return NT_STATUS_NO_MEMORY;
} else {
- sid2 = NULL;
+ sid_array.sids = NULL;
}
for (i=0; i<num_sids; i++) {
- sid_copy(&sid2[i].sid, &sids[i]);
- sid2[i].num_auths = sid2[i].sid.num_auths;
+ sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);
+ if (!sid_array.sids[i].sid) {
+ return NT_STATUS_NO_MEMORY;
+ }
}
+ sid_array.num_sids = num_sids;
+
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
-
+
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
@@ -723,14 +670,16 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
goto done;
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid, &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &global_sid_Builtin,
- &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else {
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
return NT_STATUS_INVALID_PARAMETER;
@@ -739,44 +688,45 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_useraliases(cli, mem_ctx, &domain_pol,
- num_sids, sid2,
- &num_aliases, &alias_rids);
-
+ result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
+ &domain_pol,
+ &sid_array,
+ &alias_rids);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_aliases; i++) {
- printf("\tgroup rid:[0x%x]\n", alias_rids[i]);
+ for (i = 0; i < alias_rids.count; i++) {
+ printf("\tgroup rid:[0x%x]\n", alias_rids.ids[i]);
}
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Query members of a group */
-static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, group_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 num_members, *group_rids, *group_attrs, group_rid;
+ uint32 group_rid;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
int i;
fstring server;
unsigned int old_timeout;
-
+ struct samr_RidTypeArray *rids = NULL;
+
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s rid [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
sscanf(argv[1], "%i", &group_rid);
-
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
@@ -789,16 +739,20 @@ static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
- access_mask,
- group_rid, &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ group_rid,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -806,38 +760,37 @@ static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
/* Make sure to wait for our DC's reply */
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
- result = rpccli_samr_query_groupmem(cli, mem_ctx, &group_pol,
- &num_members, &group_rids,
- &group_attrs);
+ result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
+ &group_pol,
+ &rids);
cli_set_timeout(cli->cli, old_timeout);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_members; i++) {
- printf("\trid:[0x%x] attr:[0x%x]\n", group_rids[i],
- group_attrs[i]);
+ for (i = 0; i < rids->count; i++) {
+ printf("\trid:[0x%x] attr:[0x%x]\n", rids->rids[i],
+ rids->types[i]);
}
- rpccli_samr_close(cli, mem_ctx, &group_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &group_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Enumerate domain users */
-static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx, size, num_dom_users, i;
- char **dom_users;
- uint32 *dom_rids;
+ struct samr_SamArray *dom_users = NULL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 acb_mask = ACB_NORMAL;
bool got_connect_pol = False, got_domain_pol = False;
@@ -846,7 +799,7 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]);
return NT_STATUS_OK;
}
-
+
if (argc > 1)
sscanf(argv[1], "%x", &access_mask);
@@ -855,7 +808,7 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -865,9 +818,11 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -880,54 +835,59 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
size = 0xffff;
do {
- result = rpccli_samr_enum_dom_users(
- cli, mem_ctx, &domain_pol, &start_idx, acb_mask,
- size, &dom_users, &dom_rids, &num_dom_users);
+ result = rpccli_samr_EnumDomainUsers(cli, mem_ctx,
+ &domain_pol,
+ &start_idx,
+ acb_mask,
+ &dom_users,
+ size,
+ &num_dom_users);
if (NT_STATUS_IS_OK(result) ||
NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
for (i = 0; i < num_dom_users; i++)
- printf("user:[%s] rid:[0x%x]\n",
- dom_users[i], dom_rids[i]);
+ printf("user:[%s] rid:[0x%x]\n",
+ dom_users->entries[i].name.string,
+ dom_users->entries[i].idx);
}
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
if (got_domain_pol)
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (got_connect_pol)
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
}
/* Enumerate domain groups */
-static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx, size, num_dom_groups, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- struct acct_info *dom_groups;
+ struct samr_SamArray *dom_groups = NULL;
bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 1) || (argc > 2)) {
printf("Usage: %s [access_mask]\n", argv[0]);
return NT_STATUS_OK;
}
-
+
if (argc > 1)
sscanf(argv[1], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -937,9 +897,11 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -952,55 +914,57 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
size = 0xffff;
do {
- result = rpccli_samr_enum_dom_groups(
- cli, mem_ctx, &domain_pol, &start_idx, size,
- &dom_groups, &num_dom_groups);
-
+ result = rpccli_samr_EnumDomainGroups(cli, mem_ctx,
+ &domain_pol,
+ &start_idx,
+ &dom_groups,
+ size,
+ &num_dom_groups);
if (NT_STATUS_IS_OK(result) ||
NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
for (i = 0; i < num_dom_groups; i++)
- printf("group:[%s] rid:[0x%x]\n",
- dom_groups[i].acct_name,
- dom_groups[i].rid);
+ printf("group:[%s] rid:[0x%x]\n",
+ dom_groups->entries[i].name.string,
+ dom_groups->entries[i].idx);
}
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
if (got_domain_pol)
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (got_connect_pol)
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
}
/* Enumerate alias groups */
-static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx, size, num_als_groups, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- struct acct_info *als_groups;
+ struct samr_SamArray *als_groups = NULL;
bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s builtin|domain [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
-
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -1011,13 +975,17 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
/* Get domain policy handle */
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
@@ -1032,41 +1000,110 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
size = 0xffff; /* Number of groups to retrieve */
do {
- result = rpccli_samr_enum_als_groups(
- cli, mem_ctx, &domain_pol, &start_idx, size,
- &als_groups, &num_als_groups);
+ result = rpccli_samr_EnumDomainAliases(cli, mem_ctx,
+ &domain_pol,
+ &start_idx,
+ &als_groups,
+ size,
+ &num_als_groups);
if (NT_STATUS_IS_OK(result) ||
NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
for (i = 0; i < num_als_groups; i++)
- printf("group:[%s] rid:[0x%x]\n",
- als_groups[i].acct_name,
- als_groups[i].rid);
+ printf("group:[%s] rid:[0x%x]\n",
+ als_groups->entries[i].name.string,
+ als_groups->entries[i].idx);
}
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
if (got_domain_pol)
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
-
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+
if (got_connect_pol)
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
-
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
+
+ return result;
+}
+
+/* Enumerate domains */
+
+static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ POLICY_HND connect_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ uint32 start_idx, size, num_entries, i;
+ uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ bool got_connect_pol = false;
+ struct samr_SamArray *sam = NULL;
+
+ if ((argc < 1) || (argc > 2)) {
+ printf("Usage: %s [access mask]\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ if (argc > 1) {
+ sscanf(argv[1], "%x", &access_mask);
+ }
+
+ /* Get sam policy handle */
+
+ result = try_samr_connects(cli, mem_ctx,
+ access_mask,
+ &connect_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ got_connect_pol = true;
+
+ /* Enumerate alias groups */
+
+ start_idx = 0;
+ size = 0xffff;
+
+ do {
+ result = rpccli_samr_EnumDomains(cli, mem_ctx,
+ &connect_pol,
+ &start_idx,
+ &sam,
+ size,
+ &num_entries);
+
+ if (NT_STATUS_IS_OK(result) ||
+ NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
+
+ for (i = 0; i < num_entries; i++)
+ printf("name:[%s] idx:[0x%x]\n",
+ sam->entries[i].name.string,
+ sam->entries[i].idx);
+ }
+ } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
+
+ done:
+ if (got_connect_pol) {
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
+ }
+
return result;
}
+
/* Query alias membership */
-static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, alias_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 alias_rid, num_members, i;
+ uint32 alias_rid, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- DOM_SID *alias_sids;
+ struct lsa_SidArray sid_array;
if ((argc < 3) || (argc > 4)) {
printf("Usage: %s builtin|domain rid [access mask]\n", argv[0]);
@@ -1074,28 +1111,32 @@ static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
}
sscanf(argv[2], "%i", &alias_rid);
-
+
if (argc > 3)
sscanf(argv[3], "%x", &access_mask);
/* Open SAMR handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Open handle on domain */
-
+
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
@@ -1104,37 +1145,149 @@ static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
/* Open handle on alias */
- result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol,
- access_mask,
- alias_rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ alias_rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_query_aliasmem(cli, mem_ctx, &alias_pol,
- &num_members, &alias_sids);
+ result = rpccli_samr_GetMembersInAlias(cli, mem_ctx,
+ &alias_pol,
+ &sid_array);
if (!NT_STATUS_IS_OK(result))
goto done;
- for (i = 0; i < num_members; i++) {
+ for (i = 0; i < sid_array.num_sids; i++) {
fstring sid_str;
- sid_to_fstring(sid_str, &alias_sids[i]);
+ sid_to_fstring(sid_str, sid_array.sids[i].sid);
printf("\tsid:[%s]\n", sid_str);
}
- rpccli_samr_close(cli, mem_ctx, &alias_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &alias_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
+/* Query alias info */
+
+static NTSTATUS cmd_samr_query_aliasinfo(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ POLICY_HND connect_pol, domain_pol, alias_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ uint32_t alias_rid;
+ uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ union samr_AliasInfo *info = NULL;
+ enum samr_AliasInfoEnum level = ALIASINFOALL;
+
+ if ((argc < 3) || (argc > 4)) {
+ printf("Usage: %s builtin|domain rid [level] [access mask]\n",
+ argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ sscanf(argv[2], "%i", &alias_rid);
+
+ if (argc > 2) {
+ level = atoi(argv[3]);
+ }
+
+ if (argc > 3) {
+ sscanf(argv[4], "%x", &access_mask);
+ }
+
+ /* Open SAMR handle */
+
+ result = try_samr_connects(cli, mem_ctx,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &connect_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Open handle on domain */
+
+ if (strequal(argv[1], "domain")) {
+
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &domain_sid,
+ &domain_pol);
+
+ } else if (strequal(argv[1], "builtin")) {
+
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
+
+ } else {
+ return NT_STATUS_OK;
+ }
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Open handle on alias */
+
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ alias_rid,
+ &alias_pol);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ result = rpccli_samr_QueryAliasInfo(cli, mem_ctx,
+ &alias_pol,
+ level,
+ &info);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ switch (level) {
+ case ALIASINFOALL:
+ printf("Name: %s\n", info->all.name.string);
+ printf("Description: %s\n", info->all.description.string);
+ printf("Num Members: %d\n", info->all.num_members);
+ break;
+ case ALIASINFONAME:
+ printf("Name: %s\n", info->name.string);
+ break;
+ case ALIASINFODESCRIPTION:
+ printf("Description: %s\n", info->description.string);
+ break;
+ default:
+ break;
+ }
+
+ rpccli_samr_Close(cli, mem_ctx, &alias_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
+ done:
+ return result;
+}
+
+
/* Query delete an alias membership */
-static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, alias_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
@@ -1147,25 +1300,29 @@ static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
}
alias_rid = strtoul(argv[2], NULL, 10);
-
+
/* Open SAMR handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Open handle on domain */
-
+
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_INVALID_PARAMETER;
@@ -1174,57 +1331,62 @@ static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
/* Open handle on alias */
- result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol,
- access_mask,
- alias_rid, &alias_pol);
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ alias_rid,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result) && (alias_rid == 0)) {
/* Probably this was a user name, try lookupnames */
- uint32 num_rids;
- uint32 *rids, *types;
-
- result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- 1000, 1, &argv[2],
- &num_rids, &rids,
- &types);
+ struct samr_Ids rids, types;
+ struct lsa_String lsa_acct_name;
+
+ init_lsa_String(&lsa_acct_name, argv[2]);
+
+ result = rpccli_samr_LookupNames(cli, mem_ctx,
+ &domain_pol,
+ 1,
+ &lsa_acct_name,
+ &rids,
+ &types);
if (NT_STATUS_IS_OK(result)) {
- result = rpccli_samr_open_alias(cli, mem_ctx,
+ result = rpccli_samr_OpenAlias(cli, mem_ctx,
&domain_pol,
access_mask,
- rids[0], &alias_pol);
+ rids.ids[0],
+ &alias_pol);
}
}
- result = rpccli_samr_delete_dom_alias(cli, mem_ctx, &alias_pol);
+ result = rpccli_samr_DeleteDomAlias(cli, mem_ctx,
+ &alias_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Query display info */
-static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+static NTSTATUS cmd_samr_query_dispinfo_internal(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv,
+ uint32_t opcode)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries, i;
+ uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries = 0, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 info_level = 1;
- SAM_DISPINFO_CTR ctr;
- SAM_DISPINFO_1 info1;
- SAM_DISPINFO_2 info2;
- SAM_DISPINFO_3 info3;
- SAM_DISPINFO_4 info4;
- SAM_DISPINFO_5 info5;
+ union samr_DispInfo info;
int loop_count = 0;
bool got_params = False; /* Use get_query_dispinfo_params() or not? */
+ uint32_t total_size, returned_size;
if (argc > 6) {
printf("Usage: %s [info level] [start index] [max entries] [max size] [access mask]\n", argv[0]);
@@ -1233,26 +1395,26 @@ static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
if (argc >= 2)
sscanf(argv[1], "%i", &info_level);
-
+
if (argc >= 3)
sscanf(argv[2], "%i", &start_idx);
-
+
if (argc >= 4) {
sscanf(argv[3], "%i", &max_entries);
got_params = True;
}
-
+
if (argc >= 5) {
sscanf(argv[4], "%i", &max_size);
got_params = True;
}
-
+
if (argc >= 6)
sscanf(argv[5], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -1260,99 +1422,158 @@ static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Query display info */
- ZERO_STRUCT(ctr);
- ZERO_STRUCT(info1);
-
- switch (info_level) {
- case 1:
- ZERO_STRUCT(info1);
- ctr.sam.info1 = &info1;
- break;
- case 2:
- ZERO_STRUCT(info2);
- ctr.sam.info2 = &info2;
- break;
- case 3:
- ZERO_STRUCT(info3);
- ctr.sam.info3 = &info3;
- break;
- case 4:
- ZERO_STRUCT(info4);
- ctr.sam.info4 = &info4;
- break;
- case 5:
- ZERO_STRUCT(info5);
- ctr.sam.info5 = &info5;
- break;
- }
-
-
do {
if (!got_params)
get_query_dispinfo_params(
loop_count, &max_entries, &max_size);
-
- result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
- &start_idx, info_level,
- &num_entries, max_entries,
- max_size, &ctr);
- loop_count++;
+ switch (opcode) {
+ case NDR_SAMR_QUERYDISPLAYINFO:
+ result = rpccli_samr_QueryDisplayInfo(cli, mem_ctx,
+ &domain_pol,
+ info_level,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &info);
+ break;
+ case NDR_SAMR_QUERYDISPLAYINFO2:
+ result = rpccli_samr_QueryDisplayInfo2(cli, mem_ctx,
+ &domain_pol,
+ info_level,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &info);
+
+ break;
+ case NDR_SAMR_QUERYDISPLAYINFO3:
+ result = rpccli_samr_QueryDisplayInfo3(cli, mem_ctx,
+ &domain_pol,
+ info_level,
+ start_idx,
+ max_entries,
+ max_size,
+ &total_size,
+ &returned_size,
+ &info);
- if (NT_STATUS_IS_ERR(result))
break;
+ default:
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (!NT_STATUS_IS_OK(result) &&
+ !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
+ !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
+ break;
+ }
+
+ loop_count++;
+
+ switch (info_level) {
+ case 1:
+ num_entries = info.info1.count;
+ break;
+ case 2:
+ num_entries = info.info2.count;
+ break;
+ case 3:
+ num_entries = info.info3.count;
+ break;
+ case 4:
+ num_entries = info.info4.count;
+ break;
+ case 5:
+ num_entries = info.info5.count;
+ break;
+ default:
+ break;
+ }
- if (num_entries == 0)
+ start_idx += num_entries;
+
+ if (num_entries == 0)
break;
for (i = 0; i < num_entries; i++) {
switch (info_level) {
case 1:
- display_sam_info_1(&ctr.sam.info1->sam[i], &ctr.sam.info1->str[i]);
+ display_sam_info_1(&info.info1.entries[i]);
break;
case 2:
- display_sam_info_2(&ctr.sam.info2->sam[i], &ctr.sam.info2->str[i]);
+ display_sam_info_2(&info.info2.entries[i]);
break;
case 3:
- display_sam_info_3(&ctr.sam.info3->sam[i], &ctr.sam.info3->str[i]);
+ display_sam_info_3(&info.info3.entries[i]);
break;
case 4:
- display_sam_info_4(&ctr.sam.info4->sam[i], &ctr.sam.info4->str[i]);
+ display_sam_info_4(&info.info4.entries[i]);
break;
case 5:
- display_sam_info_5(&ctr.sam.info5->sam[i], &ctr.sam.info5->str[i]);
+ display_sam_info_5(&info.info5.entries[i]);
break;
}
}
} while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
+static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ return cmd_samr_query_dispinfo_internal(cli, mem_ctx, argc, argv,
+ NDR_SAMR_QUERYDISPLAYINFO);
+}
+
+static NTSTATUS cmd_samr_query_dispinfo2(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ return cmd_samr_query_dispinfo_internal(cli, mem_ctx, argc, argv,
+ NDR_SAMR_QUERYDISPLAYINFO2);
+}
+
+static NTSTATUS cmd_samr_query_dispinfo3(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ return cmd_samr_query_dispinfo_internal(cli, mem_ctx, argc, argv,
+ NDR_SAMR_QUERYDISPLAYINFO3);
+}
+
/* Query domain info */
-static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 switch_level = 2;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- SAM_UNK_CTR ctr;
+ union samr_DomainInfo *info = NULL;
if (argc > 3) {
printf("Usage: %s [info level] [access mask]\n", argv[0]);
@@ -1361,13 +1582,13 @@ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
if (argc > 1)
sscanf(argv[1], "%i", &switch_level);
-
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -1375,17 +1596,21 @@ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Query domain info */
- result = rpccli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
- switch_level, &ctr);
+ result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
+ &domain_pol,
+ switch_level,
+ &info);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1394,37 +1619,37 @@ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
switch (switch_level) {
case 1:
- display_sam_unk_info_1(&ctr.info.inf1);
+ display_sam_dom_info_1(&info->info1);
break;
case 2:
- display_sam_unk_info_2(&ctr.info.inf2);
+ display_sam_dom_info_2(&info->info2);
break;
case 3:
- display_sam_unk_info_3(&ctr.info.inf3);
+ display_sam_dom_info_3(&info->info3);
break;
case 4:
- display_sam_unk_info_4(&ctr.info.inf4);
+ display_sam_dom_info_4(&info->info4);
break;
case 5:
- display_sam_unk_info_5(&ctr.info.inf5);
+ display_sam_dom_info_5(&info->info5);
break;
case 6:
- display_sam_unk_info_6(&ctr.info.inf6);
+ display_sam_dom_info_6(&info->info6);
break;
case 7:
- display_sam_unk_info_7(&ctr.info.inf7);
+ display_sam_dom_info_7(&info->info7);
break;
case 8:
- display_sam_unk_info_8(&ctr.info.inf8);
+ display_sam_dom_info_8(&info->info8);
break;
case 9:
- display_sam_unk_info_9(&ctr.info.inf9);
+ display_sam_dom_info_9(&info->info9);
break;
case 12:
- display_sam_unk_info_12(&ctr.info.inf12);
+ display_sam_dom_info_12(&info->info12);
break;
case 13:
- display_sam_unk_info_13(&ctr.info.inf13);
+ display_sam_dom_info_13(&info->info13);
break;
default:
@@ -1434,38 +1659,39 @@ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
}
done:
-
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
}
/* Create domain user */
-static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, user_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *acct_name;
+ struct lsa_String acct_name;
uint32 acb_info;
- uint32 user_rid;
+ uint32 acct_flags, user_rid;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ uint32_t access_granted = 0;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s username [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
- acct_name = argv[1];
-
+ init_lsa_String(&acct_name, argv[1]);
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -1473,9 +1699,11 @@ static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1483,22 +1711,31 @@ static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
/* Create domain user */
acb_info = ACB_NORMAL;
- access_mask = 0xe005000b;
+ acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
+ SEC_STD_WRITE_DAC | SEC_STD_DELETE |
+ SAMR_USER_ACCESS_SET_PASSWORD |
+ SAMR_USER_ACCESS_GET_ATTRIBUTES |
+ SAMR_USER_ACCESS_SET_ATTRIBUTES;
- result = rpccli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
- acct_name, acb_info, access_mask,
- &user_pol, &user_rid);
+ result = rpccli_samr_CreateUser2(cli, mem_ctx,
+ &domain_pol,
+ &acct_name,
+ acb_info,
+ acct_flags,
+ &user_pol,
+ &access_granted,
+ &user_rid);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_close(cli, mem_ctx, &user_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &user_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
done:
@@ -1507,28 +1744,29 @@ static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
/* Create domain group */
-static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, group_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *grp_name;
+ struct lsa_String grp_name;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ uint32_t rid = 0;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s groupname [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
- grp_name = argv[1];
-
+ init_lsa_String(&grp_name, argv[1]);
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -1536,29 +1774,33 @@ static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Create domain user */
-
- result = rpccli_samr_create_dom_group(cli, mem_ctx, &domain_pol,
- grp_name, MAXIMUM_ALLOWED_ACCESS,
- &group_pol);
+ result = rpccli_samr_CreateDomainGroup(cli, mem_ctx,
+ &domain_pol,
+ &grp_name,
+ MAXIMUM_ALLOWED_ACCESS,
+ &group_pol,
+ &rid);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_close(cli, mem_ctx, &group_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &group_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
done:
@@ -1567,28 +1809,29 @@ static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli,
/* Create domain alias */
-static NTSTATUS cmd_samr_create_dom_alias(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_create_dom_alias(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, alias_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- const char *alias_name;
+ struct lsa_String alias_name;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ uint32_t rid = 0;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s aliasname [access mask]\n", argv[0]);
return NT_STATUS_OK;
}
- alias_name = argv[1];
-
+ init_lsa_String(&alias_name, argv[1]);
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -1596,28 +1839,34 @@ static NTSTATUS cmd_samr_create_dom_alias(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Create domain user */
- result = rpccli_samr_create_dom_alias(cli, mem_ctx, &domain_pol,
- alias_name, &alias_pol);
+ result = rpccli_samr_CreateDomAlias(cli, mem_ctx,
+ &domain_pol,
+ &alias_name,
+ MAXIMUM_ALLOWED_ACCESS,
+ &alias_pol,
+ &rid);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_close(cli, mem_ctx, &alias_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &alias_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
done:
@@ -1626,16 +1875,16 @@ static NTSTATUS cmd_samr_create_dom_alias(struct rpc_pipe_client *cli,
/* Lookup sam names */
-static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND connect_pol, domain_pol;
- uint32 flags = 0x000003e8; /* Unknown */
- uint32 num_rids, num_names, *name_types, *rids;
- const char **names;
+ uint32 num_names;
+ struct samr_Ids rids, name_types;
int i;
+ struct lsa_String *names = NULL;;
if (argc < 3) {
printf("Usage: %s domain|builtin name1 [name2 [name3] [...]]\n", argv[0]);
@@ -1646,20 +1895,24 @@ static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
/* Get sam policy and domain handles */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
@@ -1670,19 +1923,23 @@ static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
num_names = argc - 2;
- if ((names = TALLOC_ARRAY(mem_ctx, const char *, num_names)) == NULL) {
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ if ((names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names)) == NULL) {
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
result = NT_STATUS_NO_MEMORY;
goto done;
}
- for (i = 0; i < num_names; i++)
- names[i] = argv[i + 2];
+ for (i = 0; i < num_names; i++) {
+ init_lsa_String(&names[i], argv[i + 2]);
+ }
- result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- flags, num_names, names,
- &num_rids, &rids, &name_types);
+ result = rpccli_samr_LookupNames(cli, mem_ctx,
+ &domain_pol,
+ num_names,
+ names,
+ &rids,
+ &name_types);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1690,25 +1947,27 @@ static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
/* Display results */
for (i = 0; i < num_names; i++)
- printf("name %s: 0x%x (%d)\n", names[i], rids[i],
- name_types[i]);
+ printf("name %s: 0x%x (%d)\n", names[i].string, rids.ids[i],
+ name_types.ids[i]);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Lookup sam rids */
-static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND connect_pol, domain_pol;
- uint32 num_rids, num_names, *rids, *name_types;
- char **names;
+ uint32_t num_rids, *rids;
+ struct lsa_Strings names;
+ struct samr_Ids types;
+
int i;
if (argc < 3) {
@@ -1718,20 +1977,24 @@ static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
/* Get sam policy and domain handles */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (StrCaseCmp(argv[1], "domain")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
else if (StrCaseCmp(argv[1], "builtin")==0)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &global_sid_Builtin, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ &domain_pol);
else
return NT_STATUS_OK;
@@ -1743,8 +2006,8 @@ static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
num_rids = argc - 2;
if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) {
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
result = NT_STATUS_NO_MEMORY;
goto done;
}
@@ -1752,8 +2015,12 @@ static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
for (i = 0; i < argc - 2; i++)
sscanf(argv[i + 2], "%i", &rids[i]);
- result = rpccli_samr_lookup_rids(cli, mem_ctx, &domain_pol, num_rids, rids,
- &num_names, &names, &name_types);
+ result = rpccli_samr_LookupRids(cli, mem_ctx,
+ &domain_pol,
+ num_rids,
+ rids,
+ &names,
+ &types);
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
@@ -1761,20 +2028,22 @@ static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
/* Display results */
- for (i = 0; i < num_names; i++)
- printf("rid 0x%x: %s (%d)\n", rids[i], names[i], name_types[i]);
+ for (i = 0; i < num_rids; i++) {
+ printf("rid 0x%x: %s (%d)\n",
+ rids[i], names.names[i].string, types.ids[i]);
+ }
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Delete domain group */
-static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND connect_pol, domain_pol, group_pol;
@@ -1784,21 +2053,23 @@ static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
printf("Usage: %s groupname\n", argv[0]);
return NT_STATUS_OK;
}
-
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy and domain handles */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1806,37 +2077,43 @@ static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
/* Get handle on group */
{
- uint32 *group_rids, num_rids, *name_types;
- uint32 flags = 0x000003e8; /* Unknown */
+ struct samr_Ids group_rids, name_types;
+ struct lsa_String lsa_acct_name;
- result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- flags, 1, (const char **)&argv[1],
- &num_rids, &group_rids,
- &name_types);
+ init_lsa_String(&lsa_acct_name, argv[1]);
+ result = rpccli_samr_LookupNames(cli, mem_ctx,
+ &domain_pol,
+ 1,
+ &lsa_acct_name,
+ &group_rids,
+ &name_types);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
- access_mask,
- group_rids[0], &group_pol);
+ result = rpccli_samr_OpenGroup(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ group_rids.ids[0],
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
}
- /* Delete user */
+ /* Delete group */
- result = rpccli_samr_delete_dom_group(cli, mem_ctx, &group_pol);
+ result = rpccli_samr_DeleteDomainGroup(cli, mem_ctx,
+ &group_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Display results */
- rpccli_samr_close(cli, mem_ctx, &group_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &group_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
@@ -1844,9 +2121,9 @@ static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
/* Delete domain user */
-static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND connect_pol, domain_pol, user_pol;
@@ -1856,21 +2133,23 @@ static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
printf("Usage: %s username\n", argv[0]);
return NT_STATUS_OK;
}
-
+
if (argc > 2)
sscanf(argv[2], "%x", &access_mask);
/* Get sam policy and domain handles */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1878,20 +2157,26 @@ static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
/* Get handle on user */
{
- uint32 *user_rids, num_rids, *name_types;
- uint32 flags = 0x000003e8; /* Unknown */
+ struct samr_Ids user_rids, name_types;
+ struct lsa_String lsa_acct_name;
- result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
- flags, 1, (const char **)&argv[1],
- &num_rids, &user_rids,
- &name_types);
+ init_lsa_String(&lsa_acct_name, argv[1]);
+
+ result = rpccli_samr_LookupNames(cli, mem_ctx,
+ &domain_pol,
+ 1,
+ &lsa_acct_name,
+ &user_rids,
+ &name_types);
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- access_mask,
- user_rids[0], &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ access_mask,
+ user_rids.ids[0],
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1899,27 +2184,28 @@ static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
/* Delete user */
- result = rpccli_samr_delete_dom_user(cli, mem_ctx, &user_pol);
+ result = rpccli_samr_DeleteUser(cli, mem_ctx,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Display results */
- rpccli_samr_close(cli, mem_ctx, &user_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &user_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/**********************************************************************
- * Query user security object
+ * Query user security object
*/
-static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol, user_pol, *pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
@@ -1931,14 +2217,14 @@ static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
bool domain = False;
ctx=talloc_init("cmd_samr_query_sec_obj");
-
+
if ((argc < 1) || (argc > 3)) {
printf("Usage: %s [rid|-d] [sec_info]\n", argv[0]);
printf("\tSpecify rid for security on user, -d for security on domain\n");
talloc_destroy(ctx);
return NT_STATUS_OK;
}
-
+
if (argc > 1) {
if (strcmp(argv[1], "-d") == 0)
domain = True;
@@ -1949,7 +2235,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
if (argc == 3) {
sec_info = atoi(argv[2]);
}
-
+
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
strupper_m(server);
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
@@ -1959,17 +2245,21 @@ static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
goto done;
if (domain || user_rid)
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
if (user_rid)
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- user_rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ user_rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1986,97 +2276,103 @@ static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
/* Query SAM security object */
- result = rpccli_samr_query_sec_obj(cli, mem_ctx, pol, sec_info, ctx,
- &sec_desc_buf);
+ result = rpccli_samr_QuerySecurity(cli, mem_ctx,
+ pol,
+ sec_info,
+ &sec_desc_buf);
if (!NT_STATUS_IS_OK(result))
goto done;
display_sec_desc(sec_desc_buf->sd);
- rpccli_samr_close(cli, mem_ctx, &user_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &user_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
talloc_destroy(ctx);
return result;
}
-static NTSTATUS cmd_samr_get_usrdom_pwinfo(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_get_usrdom_pwinfo(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
POLICY_HND connect_pol, domain_pol, user_pol;
- uint16 min_pwd_length;
- uint32 password_properties, unknown1, rid;
+ struct samr_PwInfo info;
+ uint32_t rid;
if (argc != 2) {
printf("Usage: %s rid\n", argv[0]);
return NT_STATUS_OK;
}
-
+
sscanf(argv[1], "%i", &rid);
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
- MAXIMUM_ALLOWED_ACCESS,
- rid, &user_pol);
+ result = rpccli_samr_OpenUser(cli, mem_ctx,
+ &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ rid,
+ &user_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
- result = rpccli_samr_get_usrdom_pwinfo(cli, mem_ctx, &user_pol,
- &min_pwd_length, &password_properties,
- &unknown1) ;
-
+ result = rpccli_samr_GetUserPwInfo(cli, mem_ctx, &user_pol, &info);
if (NT_STATUS_IS_OK(result)) {
- printf("min_pwd_length: %d\n", min_pwd_length);
- printf("unknown1: %d\n", unknown1);
- display_password_properties(password_properties);
+ printf("min_password_length: %d\n", info.min_password_length);
+ printf("%s\n",
+ NDR_PRINT_STRUCT_STRING(mem_ctx,
+ samr_PasswordProperties, &info.password_properties));
}
done:
- rpccli_samr_close(cli, mem_ctx, &user_pol);
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &user_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
}
-
-static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- uint16 min_pwd_length;
- uint32 password_properties;
+ struct lsa_String domain_name;
+ struct samr_PwInfo info;
- if (argc != 1) {
- printf("Usage: %s\n", argv[0]);
+ if (argc < 1 || argc > 3) {
+ printf("Usage: %s <domain>\n", argv[0]);
return NT_STATUS_OK;
}
- result = rpccli_samr_get_dom_pwinfo(cli, mem_ctx, &min_pwd_length, &password_properties) ;
-
+ init_lsa_String(&domain_name, argv[1]);
+
+ result = rpccli_samr_GetDomPwInfo(cli, mem_ctx, &domain_name, &info);
+
if (NT_STATUS_IS_OK(result)) {
- printf("min_pwd_length: %d\n", min_pwd_length);
- display_password_properties(password_properties);
+ printf("min_password_length: %d\n", info.min_password_length);
+ display_password_properties(info.password_properties);
}
return result;
@@ -2084,54 +2380,60 @@ static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli,
/* Look up domain name */
-static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- fstring domain_name,sid_string;
- DOM_SID sid;
-
+ fstring sid_string;
+ struct lsa_String domain_name;
+ DOM_SID *sid = NULL;
+
if (argc != 2) {
printf("Usage: %s domain_name\n", argv[0]);
return NT_STATUS_OK;
}
-
- sscanf(argv[1], "%s", domain_name);
-
+
+ init_lsa_String(&domain_name, argv[1]);
+
result = try_samr_connects(cli, mem_ctx, access_mask, &connect_pol);
-
+
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask, &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
-
- result = rpccli_samr_lookup_domain(
- cli, mem_ctx, &connect_pol, domain_name, &sid);
+
+ result = rpccli_samr_LookupDomain(cli, mem_ctx,
+ &connect_pol,
+ &domain_name,
+ &sid);
if (NT_STATUS_IS_OK(result)) {
- sid_to_fstring(sid_string,&sid);
+ sid_to_fstring(sid_string, sid);
printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",
- domain_name,sid_string);
+ argv[1], sid_string);
}
- rpccli_samr_close(cli, mem_ctx, &domain_pol);
- rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ rpccli_samr_Close(cli, mem_ctx, &domain_pol);
+ rpccli_samr_Close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Change user password */
-static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
@@ -2146,10 +2448,10 @@ static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
user = argv[1];
oldpass = argv[2];
newpass = argv[3];
-
+
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -2157,9 +2459,11 @@ static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -2170,10 +2474,10 @@ static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
done:
@@ -2183,16 +2487,16 @@ static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
/* Change user password */
-static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
+static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+ int argc, const char **argv)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
const char *user, *oldpass, *newpass;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
- SAM_UNK_INFO_1 info;
- SAMR_CHANGE_REJECT reject;
+ struct samr_DomInfo1 *info = NULL;
+ struct samr_ChangeReject *reject = NULL;
if (argc < 3) {
printf("Usage: %s username oldpass newpass\n", argv[0]);
@@ -2202,10 +2506,10 @@ static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
user = argv[1];
oldpass = argv[2];
newpass = argv[3];
-
+
/* Get sam policy handle */
- result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result))
@@ -2213,35 +2517,43 @@ static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
/* Get domain policy handle */
- result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
- access_mask,
- &domain_sid, &domain_pol);
+ result = rpccli_samr_OpenDomain(cli, mem_ctx,
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Change user password */
- result = rpccli_samr_chgpasswd3(cli, mem_ctx, user, newpass, oldpass, &info, &reject);
+ result = rpccli_samr_chgpasswd3(cli, mem_ctx,
+ user,
+ newpass,
+ oldpass,
+ &info,
+ &reject);
if (NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_RESTRICTION)) {
-
- display_sam_unk_info_1(&info);
- switch (reject.reject_reason) {
- case REJECT_REASON_TOO_SHORT:
- d_printf("REJECT_REASON_TOO_SHORT\n");
+ display_sam_dom_info_1(info);
+
+ switch (reject->reason) {
+ case SAMR_REJECT_TOO_SHORT:
+ d_printf("SAMR_REJECT_TOO_SHORT\n");
break;
- case REJECT_REASON_IN_HISTORY:
- d_printf("REJECT_REASON_IN_HISTORY\n");
+ case SAMR_REJECT_IN_HISTORY:
+ d_printf("SAMR_REJECT_IN_HISTORY\n");
break;
- case REJECT_REASON_NOT_COMPLEX:
- d_printf("REJECT_REASON_NOT_COMPLEX\n");
+ case SAMR_REJECT_COMPLEXITY:
+ d_printf("SAMR_REJECT_COMPLEXITY\n");
break;
- case REJECT_REASON_OTHER:
- d_printf("REJECT_REASON_OTHER\n");
+ case SAMR_REJECT_OTHER:
+ d_printf("SAMR_REJECT_OTHER\n");
break;
default:
- d_printf("unknown reject reason: %d\n", reject.reject_reason);
+ d_printf("unknown reject reason: %d\n",
+ reject->reason);
break;
}
}
@@ -2249,10 +2561,10 @@ static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
- result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
+ result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
done:
@@ -2271,12 +2583,16 @@ struct cmd_set samr_commands[] = {
{ "queryuseraliases", RPC_RTYPE_NTSTATUS, cmd_samr_query_useraliases, NULL, PI_SAMR, NULL, "Query user aliases", "" },
{ "querygroupmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_groupmem, NULL, PI_SAMR, NULL, "Query group membership", "" },
{ "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, NULL, "Query alias membership", "" },
+ { "queryaliasinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasinfo, NULL, PI_SAMR, NULL, "Query alias info", "" },
{ "deletealias", RPC_RTYPE_NTSTATUS, cmd_samr_delete_alias, NULL, PI_SAMR, NULL, "Delete an alias", "" },
{ "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" },
+ { "querydispinfo2", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo2, NULL, PI_SAMR, NULL, "Query display info", "" },
+ { "querydispinfo3", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo3, NULL, PI_SAMR, NULL, "Query display info", "" },
{ "querydominfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, NULL, PI_SAMR, NULL, "Query domain info", "" },
- { "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" },
+ { "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" },
{ "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" },
{ "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, NULL, "Enumerate alias groups", "" },
+ { "enumdomains", RPC_RTYPE_NTSTATUS, cmd_samr_enum_domains, NULL, PI_SAMR, NULL, "Enumerate domains", "" },
{ "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, NULL, "Create domain user", "" },
{ "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, NULL, "Create domain group", "" },
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index a7969bddd1..e923302f4e 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -1222,9 +1222,10 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch)
static char* get_driver_3_param (char* str, const char* delim, UNISTR* dest)
{
char *ptr;
+ char *saveptr;
/* get the next token */
- ptr = strtok(str, delim);
+ ptr = strtok_r(str, delim, &saveptr);
/* a string of 'NULL' is used to represent an empty
parameter because two consecutive delimiters
@@ -1251,7 +1252,8 @@ static bool init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info,
{
char *str, *str2;
uint32 len, i;
-
+ char *saveptr = NULL;
+
/* fill in the UNISTR fields */
str = get_driver_3_param (args, ":", &info->name);
str = get_driver_3_param (NULL, ":", &info->driverpath);
@@ -1266,13 +1268,13 @@ static bool init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info,
str = str2;
/* begin to strip out each filename */
- str = strtok(str, ",");
+ str = strtok_r(str, ",", &saveptr);
len = 0;
while (str != NULL)
{
/* keep a cumlative count of the str lengths */
len += strlen(str)+1;
- str = strtok(NULL, ",");
+ str = strtok_r(NULL, ",", &saveptr);
}
/* allocate the space; add one extra slot for a terminating NULL.
@@ -1481,7 +1483,7 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
goto done;;
}
- printf("Succesfully set %s to driver %s.\n", argv[1], argv[2]);
+ printf("Successfully set %s to driver %s.\n", argv[1], argv[2]);
done:
/* Cleanup */
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 081e0fb15e..5e87058111 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -133,12 +133,10 @@ static void fetch_machine_sid(struct cli_state *cli)
{
POLICY_HND pol;
NTSTATUS result = NT_STATUS_OK;
- uint32 info_class = 5;
- const char *domain_name = NULL;
static bool got_domain_sid;
TALLOC_CTX *mem_ctx;
- DOM_SID *dom_sid = NULL;
struct rpc_pipe_client *lsapipe = NULL;
+ union lsa_PolicyInformation *info = NULL;
if (got_domain_sid) return;
@@ -159,14 +157,16 @@ static void fetch_machine_sid(struct cli_state *cli)
goto error;
}
- result = rpccli_lsa_query_info_policy(lsapipe, mem_ctx, &pol, info_class,
- &domain_name, &dom_sid);
+ result = rpccli_lsa_QueryInfoPolicy(lsapipe, mem_ctx,
+ &pol,
+ LSA_POLICY_INFO_ACCOUNT_DOMAIN,
+ &info);
if (!NT_STATUS_IS_OK(result)) {
goto error;
}
got_domain_sid = True;
- sid_copy( &domain_sid, dom_sid );
+ sid_copy(&domain_sid, info->account_domain.sid);
rpccli_lsa_Close(lsapipe, mem_ctx, &pol);
cli_rpc_pipe_close(lsapipe);
@@ -503,6 +503,7 @@ extern struct cmd_set echo_commands[];
extern struct cmd_set shutdown_commands[];
extern struct cmd_set test_commands[];
extern struct cmd_set wkssvc_commands[];
+extern struct cmd_set ntsvcs_commands[];
static struct cmd_set *rpcclient_command_list[] = {
rpcclient_commands,
@@ -517,6 +518,7 @@ static struct cmd_set *rpcclient_command_list[] = {
shutdown_commands,
test_commands,
wkssvc_commands,
+ ntsvcs_commands,
NULL
};
@@ -605,7 +607,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
}
if (cmd_entry->pipe_idx == PI_NETLOGON) {
- uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS;
+ uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS;
uint32 sec_channel_type;
uchar trust_password[16];