From bea13a02d4bc45b6041be435f129557fc1615ce3 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 31 Aug 2023 10:27:12 +0200 Subject: [PATCH] s3:utils: Use dcerpc_lsa_open_policy_fallback() in net_rpc_trust.c Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- source3/utils/net_rpc_trust.c | 40 +++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/source3/utils/net_rpc_trust.c b/source3/utils/net_rpc_trust.c index 9cfce005e56..a5e397471f0 100644 --- a/source3/utils/net_rpc_trust.c +++ b/source3/utils/net_rpc_trust.c @@ -203,7 +203,13 @@ static NTSTATUS connect_and_get_info(TALLOC_CTX *mem_ctx, DATA_BLOB *session_key) { NTSTATUS status; - NTSTATUS result; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + uint32_t out_version = 0; + union lsa_revision_info out_revision_info = { + .info1 = { + .revision = 0, + }, + }; status = net_make_ipc_connection_ex(net_ctx, NULL, NULL, NULL, NET_FLAGS_PDC, cli); @@ -220,25 +226,23 @@ static NTSTATUS connect_and_get_info(TALLOC_CTX *mem_ctx, return status; } - status = dcerpc_lsa_open_policy2((*pipe_hnd)->binding_handle, - mem_ctx, - (*pipe_hnd)->srv_name_slash, - false, - (LSA_POLICY_VIEW_LOCAL_INFORMATION | - LSA_POLICY_TRUST_ADMIN | - LSA_POLICY_CREATE_SECRET), - pol_hnd, - &result); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("Failed to open policy handle with error [%s]\n", - nt_errstr(status))); + status = dcerpc_lsa_open_policy_fallback( + (*pipe_hnd)->binding_handle, + mem_ctx, + (*pipe_hnd)->srv_name_slash, + false, + LSA_POLICY_VIEW_LOCAL_INFORMATION | + LSA_POLICY_TRUST_ADMIN | + LSA_POLICY_CREATE_SECRET, + &out_version, + &out_revision_info, + pol_hnd, + &result); + if (any_nt_status_not_ok(status, result, &status)) { + DBG_ERR("Failed to open policy handle: %s\n", + nt_errstr(result)); return status; } - if (!NT_STATUS_IS_OK(result)) { - DEBUG(0, ("lsa_open_policy2 with error [%s]\n", - nt_errstr(result))); - return result; - } status = get_domain_info(mem_ctx, (*pipe_hnd)->binding_handle, pol_hnd, dom_data); -- 2.47.3