From 9a0db8c8ed11f990e14a7c72fa86b87a209e2713 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Fri, 12 Feb 2021 23:56:10 +0100 Subject: [PATCH] s3-rpc_client: add copy_netr_DsRGetDCNameInfo() helper Guenther Signed-off-by: Guenther Deschner Reviewed-by: Alexander Bokovoy --- source3/rpc_client/util_netlogon.c | 60 ++++++++++++++++++++++++++++++ source3/rpc_client/util_netlogon.h | 3 ++ 2 files changed, 63 insertions(+) diff --git a/source3/rpc_client/util_netlogon.c b/source3/rpc_client/util_netlogon.c index 4108707143f..e24f0ff1e4f 100644 --- a/source3/rpc_client/util_netlogon.c +++ b/source3/rpc_client/util_netlogon.c @@ -387,3 +387,63 @@ NTSTATUS map_info6_to_validation(TALLOC_CTX *mem_ctx, *_validation = validation; return NT_STATUS_OK; } + +/**************************************************************** +****************************************************************/ + +NTSTATUS copy_netr_DsRGetDCNameInfo(TALLOC_CTX *mem_ctx, + const struct netr_DsRGetDCNameInfo *in, + struct netr_DsRGetDCNameInfo **pout) +{ + struct netr_DsRGetDCNameInfo *r; + + r = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo); + if (r == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->dc_unc = talloc_strdup(r, in->dc_unc); + if (r->dc_unc == NULL) { + talloc_free(r); + return NT_STATUS_NO_MEMORY; + } + r->dc_address = talloc_strdup(r, in->dc_address); + if (r->dc_address == NULL) { + talloc_free(r); + return NT_STATUS_NO_MEMORY; + } + r->dc_address_type = in->dc_address_type; + r->domain_guid = in->domain_guid; + r->domain_name = talloc_strdup(r, in->domain_name); + if (r->domain_name == NULL) { + talloc_free(r); + return NT_STATUS_NO_MEMORY; + } + /* forest could be empty */ + if (in->forest_name != NULL) { + r->forest_name = talloc_strdup(r, in->forest_name); + if (r->forest_name == NULL) { + talloc_free(r); + return NT_STATUS_NO_MEMORY; + } + } + r->dc_flags = in->dc_flags; + if (in->dc_site_name != NULL) { + r->dc_site_name = talloc_strdup(r, in->dc_site_name); + if (r->dc_site_name == NULL) { + talloc_free(r); + return NT_STATUS_NO_MEMORY; + } + } + if (in->client_site_name != NULL) { + r->client_site_name = talloc_strdup(r, in->client_site_name); + if (r->client_site_name == NULL) { + talloc_free(r); + return NT_STATUS_NO_MEMORY; + } + } + + *pout = r; + + return NT_STATUS_OK; +} diff --git a/source3/rpc_client/util_netlogon.h b/source3/rpc_client/util_netlogon.h index c3ed3f67201..85680a9989f 100644 --- a/source3/rpc_client/util_netlogon.h +++ b/source3/rpc_client/util_netlogon.h @@ -47,5 +47,8 @@ NTSTATUS map_info6_to_validation(TALLOC_CTX *mem_ctx, const struct netr_SamInfo6 *info6, uint16_t *_validation_level, union netr_Validation **_validation); +NTSTATUS copy_netr_DsRGetDCNameInfo(TALLOC_CTX *mem_ctx, + const struct netr_DsRGetDCNameInfo *in, + struct netr_DsRGetDCNameInfo **pout); #endif /* _RPC_CLIENT_UTIL_NETLOGON_H_ */ -- 2.34.1