summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-01-12 12:08:42 +0100
committerAndreas Schneider <asn@samba.org>2011-01-13 14:09:18 +0100
commit5e4b327c4f1a9a09cb46514e7ed5c213031f1218 (patch)
treea2fd5c9b89a4ed6c425af26b5efcbe8e9536b0b8
parentc9b3404c68b0b5b1f2f3008736d77c476cc0e398 (diff)
downloadsamba-5e4b327c4f1a9a09cb46514e7ed5c213031f1218.tar.gz
samba-5e4b327c4f1a9a09cb46514e7ed5c213031f1218.tar.bz2
samba-5e4b327c4f1a9a09cb46514e7ed5c213031f1218.zip
s3-rpcclient: prefer dcerpc_netr_X functions.
Guenther Signed-off-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source3/rpcclient/cmd_netlogon.c109
1 files changed, 82 insertions, 27 deletions
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 4419485b54..1942352939 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -23,7 +23,7 @@
#include "rpcclient.h"
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/ndr_netlogon.h"
-#include "../librpc/gen_ndr/cli_netlogon.h"
+#include "../librpc/gen_ndr/ndr_netlogon_c.h"
#include "rpc_client/cli_netlogon.h"
#include "secrets.h"
@@ -39,6 +39,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli,
union netr_CONTROL_DATA_INFORMATION data;
union netr_CONTROL_QUERY_INFORMATION query;
const char *domain = lp_workgroup();
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc > 5) {
fprintf(stderr, "Usage: %s <logon_server> <function_code> "
@@ -71,7 +72,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli,
break;
}
- status = rpccli_netr_LogonControl2(cli, mem_ctx,
+ status = dcerpc_netr_LogonControl2(b, mem_ctx,
logon_server,
function_code,
level,
@@ -99,6 +100,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
WERROR werr;
NTSTATUS status;
int old_timeout;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc != 2) {
fprintf(stderr, "Usage: %s domainname\n", argv[0]);
@@ -109,7 +111,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */
rpccli_set_timeout(cli, MAX(old_timeout, 30000)); /* At least 30 sec */
- status = rpccli_netr_GetAnyDCName(cli, mem_ctx,
+ status = dcerpc_netr_GetAnyDCName(b, mem_ctx,
cli->desthost,
argv[1],
&dcname,
@@ -139,6 +141,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
NTSTATUS status;
WERROR werr;
int old_timeout;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc != 2) {
fprintf(stderr, "Usage: %s domainname\n", argv[0]);
@@ -149,7 +152,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */
rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */
- status = rpccli_netr_GetDcName(cli, mem_ctx,
+ status = dcerpc_netr_GetDcName(b, mem_ctx,
cli->desthost,
argv[1],
&dcname,
@@ -183,6 +186,7 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
struct GUID domain_guid = GUID_zero();
struct GUID site_guid = GUID_zero();
struct netr_DsRGetDCNameInfo *info = NULL;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 2) {
fprintf(stderr, "Usage: %s [domain_name] [domain_guid] "
@@ -210,7 +214,7 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
debug_dsdcinfo_flags(1,flags);
- result = rpccli_netr_DsRGetDCName(cli, mem_ctx,
+ result = dcerpc_netr_DsRGetDCName(b, mem_ctx,
server_name,
domain_name,
&domain_guid,
@@ -218,6 +222,9 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
flags,
&info,
&werr);
+ if (!NT_STATUS_IS_OK(result)) {
+ return ntstatus_to_werror(result);
+ }
if (W_ERROR_IS_OK(werr)) {
d_printf("DsGetDcName gave: %s\n",
@@ -243,6 +250,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
const char *site_name = NULL;
struct GUID domain_guid = GUID_zero();
struct netr_DsRGetDCNameInfo *info = NULL;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 2) {
fprintf(stderr, "Usage: %s [domain_name] [domain_guid] "
@@ -268,7 +276,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli,
debug_dsdcinfo_flags(1,flags);
- status = rpccli_netr_DsRGetDCNameEx(cli, mem_ctx,
+ status = dcerpc_netr_DsRGetDCNameEx(b, mem_ctx,
server_name,
domain_name,
&domain_guid,
@@ -304,6 +312,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli,
const char *site_name = NULL;
struct GUID domain_guid = GUID_zero();
struct netr_DsRGetDCNameInfo *info = NULL;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 2) {
fprintf(stderr, "Usage: %s [client_account] [acb_mask] "
@@ -340,7 +349,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli,
debug_dsdcinfo_flags(1,flags);
- status = rpccli_netr_DsRGetDCNameEx2(cli, mem_ctx,
+ status = dcerpc_netr_DsRGetDCNameEx2(b, mem_ctx,
server_name,
client_account,
mask,
@@ -372,13 +381,14 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli,
WERROR werr;
NTSTATUS status;
const char *sitename = NULL;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc != 2) {
fprintf(stderr, "Usage: %s computername\n", argv[0]);
return WERR_OK;
}
- status = rpccli_netr_DsRGetSiteName(cli, mem_ctx,
+ status = dcerpc_netr_DsRGetSiteName(b, mem_ctx,
argv[1],
&sitename,
&werr);
@@ -407,6 +417,7 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli,
enum netr_LogonControlCode function_code = 1;
uint32_t level = 1;
union netr_CONTROL_QUERY_INFORMATION info;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc > 4) {
fprintf(stderr, "Usage: %s <logon_server> <function_code> "
@@ -426,7 +437,7 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli,
level = atoi(argv[3]);
}
- status = rpccli_netr_LogonControl(cli, mem_ctx,
+ status = dcerpc_netr_LogonControl(b, mem_ctx,
logon_server,
function_code,
level,
@@ -567,6 +578,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status;
const char *logon_server = cli->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
@@ -574,6 +586,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
uint16_t restart_state = 0;
uint32_t sync_context = 0;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc > 2) {
fprintf(stderr, "Usage: %s [database_id]\n", argv[0]);
@@ -591,7 +604,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
netlogon_creds_client_authenticator(cli->dc, &credential);
- result = rpccli_netr_DatabaseSync2(cli, mem_ctx,
+ status = dcerpc_netr_DatabaseSync2(b, mem_ctx,
logon_server,
computername,
&credential,
@@ -600,7 +613,11 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli,
restart_state,
&sync_context,
&delta_enum_array,
- 0xffff);
+ 0xffff,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
/* Check returned credentials. */
if (!netlogon_creds_client_check(cli->dc,
@@ -631,6 +648,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status;
uint32_t tmp;
const char *logon_server = cli->desthost;
const char *computername = global_myname();
@@ -638,6 +656,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
struct netr_Authenticator return_authenticator;
enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
uint64_t sequence_num;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc != 3) {
fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]);
@@ -654,7 +673,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
netlogon_creds_client_authenticator(cli->dc, &credential);
- result = rpccli_netr_DatabaseDeltas(cli, mem_ctx,
+ status = dcerpc_netr_DatabaseDeltas(b, mem_ctx,
logon_server,
computername,
&credential,
@@ -662,7 +681,11 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
database_id,
&sequence_num,
&delta_enum_array,
- 0xffff);
+ 0xffff,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
/* Check returned credentials. */
if (!netlogon_creds_client_check(cli->dc,
@@ -769,6 +792,7 @@ static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli,
const char *server_name = cli->desthost;
const char *domain_name = lp_workgroup();
uint32_t rid = 0;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 3) {
fprintf(stderr, "Usage: %s <server_name> <domain_name>\n",
@@ -784,12 +808,13 @@ static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli,
domain_name = argv[2];
}
- status = rpccli_netr_LogonGetTrustRid(cli, mem_ctx,
+ status = dcerpc_netr_LogonGetTrustRid(b, mem_ctx,
server_name,
domain_name,
&rid,
&werr);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -809,6 +834,7 @@ static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli,
const char *server_name = cli->desthost;
uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST;
struct netr_DomainTrustList trusts;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 3) {
fprintf(stderr, "Usage: %s <server_name> <trust_flags>\n",
@@ -824,12 +850,13 @@ static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli,
sscanf(argv[2], "%x", &trust_flags);
}
- status = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,
+ status = dcerpc_netr_DsrEnumerateDomainTrusts(b, mem_ctx,
server_name,
trust_flags,
&trusts,
&werr);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -857,6 +884,7 @@ static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli,
const char *server_name = cli->desthost;
const char *domain = lp_workgroup();
const char *dns_host = NULL;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 4) {
fprintf(stderr, "Usage: %s <server_name> <domain_name> "
@@ -876,7 +904,7 @@ static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli,
dns_host = argv[3];
}
- status = rpccli_netr_DsrDeregisterDNSHostRecords(cli, mem_ctx,
+ status = dcerpc_netr_DsrDeregisterDNSHostRecords(b, mem_ctx,
server_name,
domain,
NULL,
@@ -884,6 +912,7 @@ static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli,
dns_host,
&werr);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -904,6 +933,7 @@ static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli,
const char *trusted_domain_name = NULL;
struct lsa_ForestTrustInformation *info = NULL;
uint32_t flags = 0;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 4) {
fprintf(stderr, "Usage: %s <server_name> <trusted_domain_name> "
@@ -923,13 +953,14 @@ static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli,
sscanf(argv[3], "%x", &flags);
}
- status = rpccli_netr_DsRGetForestTrustInformation(cli, mem_ctx,
+ status = dcerpc_netr_DsRGetForestTrustInformation(b, mem_ctx,
server_name,
trusted_domain_name,
flags,
&info,
&werr);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -945,8 +976,10 @@ static NTSTATUS cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,
const char **argv)
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS result;
const char *server_name = cli->desthost;
struct netr_Blob blob;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 3) {
@@ -958,13 +991,19 @@ static NTSTATUS cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,
server_name = argv[1];
}
- status = rpccli_netr_NetrEnumerateTrustedDomains(cli, mem_ctx,
+ status = dcerpc_netr_NetrEnumerateTrustedDomains(b, mem_ctx,
server_name,
- &blob);
+ &blob,
+ &result);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
+ if (!NT_STATUS_IS_OK(result)) {
+ status = result;
+ goto done;
+ }
+
printf("success\n");
dump_data(1, blob.data, blob.length);
done:
@@ -979,6 +1018,7 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli,
WERROR werr = WERR_GENERAL_FAILURE;
const char *server_name = cli->desthost;
struct netr_DomainTrustList list;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 3) {
fprintf(stderr, "Usage: %s <server_name>\n", argv[0]);
@@ -989,11 +1029,12 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli,
server_name = argv[1];
}
- status = rpccli_netr_NetrEnumerateTrustedDomainsEx(cli, mem_ctx,
+ status = dcerpc_netr_NetrEnumerateTrustedDomainsEx(b, mem_ctx,
server_name,
&list,
&werr);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -1012,6 +1053,7 @@ static WERROR cmd_netlogon_getdcsitecoverage(struct rpc_pipe_client *cli,
WERROR werr = WERR_GENERAL_FAILURE;
const char *server_name = cli->desthost;
struct DcSitesCtr *ctr = NULL;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc < 1 || argc > 3) {
fprintf(stderr, "Usage: %s <server_name>\n", argv[0]);
@@ -1022,11 +1064,12 @@ static WERROR cmd_netlogon_getdcsitecoverage(struct rpc_pipe_client *cli,
server_name = argv[1];
}
- status = rpccli_netr_DsrGetDcSiteCoverageW(cli, mem_ctx,
+ status = dcerpc_netr_DsrGetDcSiteCoverageW(b, mem_ctx,
server_name,
&ctr,
&werr);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -1046,6 +1089,7 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli,
const char **argv)
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS result;
const char *server_name = cli->desthost;
uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
struct netr_Authenticator clnt_creds, srv_cred;
@@ -1054,6 +1098,7 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli,
enum netr_SchannelType sec_channel_type = 0;
struct netr_ChangeLogEntry e;
uint32_t rid = 500;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc > 2) {
fprintf(stderr, "Usage: %s <user rid>\n", argv[0]);
@@ -1091,21 +1136,25 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli,
e.db_index = SAM_DATABASE_DOMAIN;
e.delta_type = NETR_DELTA_USER;
- status = rpccli_netr_DatabaseRedo(cli, mem_ctx,
+ status = dcerpc_netr_DatabaseRedo(b, mem_ctx,
server_name,
global_myname(),
&clnt_creds,
&srv_cred,
e,
0, /* is calculated automatically */
- &delta_enum_array);
+ &delta_enum_array,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) {
DEBUG(0,("credentials chain check failed\n"));
return NT_STATUS_ACCESS_DENIED;
}
- return status;
+ return result;
}
static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli,
@@ -1113,10 +1162,12 @@ static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli,
const char **argv)
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS result;
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
union netr_Capabilities capabilities;
uint32_t level = 1;
+ struct dcerpc_binding_handle *b = cli->binding_handle;
if (argc > 2) {
fprintf(stderr, "Usage: %s <level>\n", argv[0]);
@@ -1131,13 +1182,17 @@ static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli,
netlogon_creds_client_authenticator(cli->dc, &credential);
- status = rpccli_netr_LogonGetCapabilities(cli, mem_ctx,
+ status = dcerpc_netr_LogonGetCapabilities(b, mem_ctx,
cli->desthost,
global_myname(),
&credential,
&return_authenticator,
level,
- &capabilities);
+ &capabilities,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (!netlogon_creds_client_check(cli->dc,
&return_authenticator.cred)) {
@@ -1147,7 +1202,7 @@ static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli,
printf("capabilities: 0x%08x\n", capabilities.server_capabilities);
- return status;
+ return result;
}
/* List of commands exported by this module */