summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-11-29 00:27:28 +0100
committerGünther Deschner <gd@samba.org>2008-12-05 14:27:02 +0100
commite9269e57fce69a4ad9dcf19444e60ff3cd489d18 (patch)
treeb974d9e234c6b74cd794955ba4d52b9fe3b6a89b /source3
parent0f74de3d37cdb03f622d9cdc1cdcc4aa6ede5ce3 (diff)
downloadsamba-e9269e57fce69a4ad9dcf19444e60ff3cd489d18.tar.gz
samba-e9269e57fce69a4ad9dcf19444e60ff3cd489d18.tar.bz2
samba-e9269e57fce69a4ad9dcf19444e60ff3cd489d18.zip
s3-rpcclient: add get_domain_handle for samr commands.
Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/cmd_samr.c168
1 files changed, 64 insertions, 104 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index eaf5adbfa5..139702cc74 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -264,6 +264,35 @@ static void display_sam_info_5(struct samr_DispEntryAscii *r)
printf("Account: %s\n", r->account_name.string);
}
+/****************************************************************************
+ ****************************************************************************/
+
+static NTSTATUS get_domain_handle(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *sam,
+ struct policy_handle *connect_pol,
+ uint32_t access_mask,
+ struct dom_sid *_domain_sid,
+ struct policy_handle *domain_pol)
+{
+
+ if (StrCaseCmp(sam, "domain") == 0) {
+ return rpccli_samr_OpenDomain(cli, mem_ctx,
+ connect_pol,
+ access_mask,
+ _domain_sid,
+ domain_pol);
+ } else if (StrCaseCmp(sam, "builtin") == 0) {
+ return rpccli_samr_OpenDomain(cli, mem_ctx,
+ connect_pol,
+ access_mask,
+ CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ domain_pol);
+ }
+
+ return NT_STATUS_INVALID_PARAMETER;
+}
+
/**********************************************************************
* Query user information
*/
@@ -649,21 +678,11 @@ static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- if (StrCaseCmp(argv[1], "domain")==0)
- 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_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;
- }
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -955,20 +974,11 @@ 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_OpenDomain(cli, mem_ctx,
- &connect_pol,
- access_mask,
- &domain_sid,
- &domain_pol);
- else if (StrCaseCmp(argv[1], "builtin")==0)
- 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;
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ access_mask,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1107,20 +1117,11 @@ static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
/* Open handle on domain */
- if (StrCaseCmp(argv[1], "domain")==0)
- 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_OpenDomain(cli, mem_ctx,
- &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
- &domain_pol);
- else
- return NT_STATUS_OK;
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1197,25 +1198,11 @@ static NTSTATUS cmd_samr_query_aliasinfo(struct rpc_pipe_client *cli,
/* 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;
- }
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
goto done;
@@ -1294,20 +1281,11 @@ static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
/* Open handle on domain */
- if (StrCaseCmp(argv[1], "domain")==0)
- 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_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;
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1890,20 +1868,11 @@ static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- if (StrCaseCmp(argv[1], "domain")==0)
- 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_OpenDomain(cli, mem_ctx,
- &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
- &domain_pol);
- else
- return NT_STATUS_OK;
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -1973,20 +1942,11 @@ static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- if (StrCaseCmp(argv[1], "domain")==0)
- 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_OpenDomain(cli, mem_ctx,
- &connect_pol,
- MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
- &domain_pol);
- else
- return NT_STATUS_OK;
+ result = get_domain_handle(cli, mem_ctx, argv[1],
+ &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid,
+ &domain_pol);
if (!NT_STATUS_IS_OK(result))
goto done;