summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-10-28 15:37:11 +0100
committerGünther Deschner <gd@samba.org>2009-10-30 12:28:48 +0100
commit2f3a40844dbac11345a9aabf4a3edd71bab3fec6 (patch)
treef9c98960a4f60ca5261d210bc297cf5d38cb03e7 /source3
parentfbdda195498a9868b9a11a4e0621fadab1ce0963 (diff)
downloadsamba-2f3a40844dbac11345a9aabf4a3edd71bab3fec6.tar.gz
samba-2f3a40844dbac11345a9aabf4a3edd71bab3fec6.tar.bz2
samba-2f3a40844dbac11345a9aabf4a3edd71bab3fec6.zip
s3-rpcclient: add deletetrustdom command.
Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/cmd_lsarpc.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 641b38e340..45868bf5a9 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -1881,6 +1881,94 @@ static NTSTATUS cmd_lsa_create_trusted_domain(struct rpc_pipe_client *cli,
return status;
}
+static NTSTATUS cmd_lsa_delete_trusted_domain(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status;
+ struct policy_handle handle, trustdom_handle;
+ struct lsa_String name;
+ struct dom_sid *sid = NULL;
+
+ if (argc < 2) {
+ printf("Usage: %s name\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ status = rpccli_lsa_open_policy2(cli, mem_ctx,
+ true,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ init_lsa_String(&name, argv[1]);
+
+ status = rpccli_lsa_OpenTrustedDomainByName(cli, mem_ctx,
+ &handle,
+ name,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &trustdom_handle);
+ if (NT_STATUS_IS_OK(status)) {
+ goto delete_object;
+ }
+
+ {
+ uint32_t resume_handle = 0;
+ struct lsa_DomainList domains;
+ int i;
+
+ status = rpccli_lsa_EnumTrustDom(cli, mem_ctx,
+ &handle,
+ &resume_handle,
+ &domains,
+ 0xffff);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ for (i=0; i < domains.count; i++) {
+ if (strequal(domains.domains[i].name.string, argv[1])) {
+ sid = domains.domains[i].sid;
+ break;
+ }
+ }
+
+ if (!sid) {
+ return NT_STATUS_INVALID_SID;
+ }
+ }
+
+ status = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,
+ &handle,
+ sid,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &trustdom_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ delete_object:
+ status = rpccli_lsa_DeleteObject(cli, mem_ctx,
+ &trustdom_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ done:
+ if (is_valid_policy_hnd(&trustdom_handle)) {
+ rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);
+ }
+
+ if (is_valid_policy_hnd(&handle)) {
+ rpccli_lsa_Close(cli, mem_ctx, &handle);
+ }
+
+ return status;
+}
+
+
/* List of commands exported by this module */
struct cmd_set lsarpc_commands[] = {
@@ -1917,6 +2005,7 @@ struct cmd_set lsarpc_commands[] = {
{ "retrieveprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_retrieve_private_data, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Retrieve Private Data", "" },
{ "storeprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_store_private_data, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Store Private Data", "" },
{ "createtrustdom", RPC_RTYPE_NTSTATUS, cmd_lsa_create_trusted_domain, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Create Trusted Domain", "" },
+ { "deletetrustdom", RPC_RTYPE_NTSTATUS, cmd_lsa_delete_trusted_domain, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Delete Trusted Domain", "" },
{ NULL }
};