s3-rpc_client: add copy_netr_DsRGetDCNameInfo() helper
authorGünther Deschner <gd@samba.org>
Fri, 12 Feb 2021 22:56:10 +0000 (23:56 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 14 Jul 2021 16:49:30 +0000 (16:49 +0000)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/rpc_client/util_netlogon.c
source3/rpc_client/util_netlogon.h

index 4108707143fe309b6b7b97d7192adc353806a587..e24f0ff1e4ff70b35b702547fe06fcab80c9c761 100644 (file)
@@ -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;
+}
index c3ed3f67201ac6430a5ef8e8f0ed598eff587aa3..85680a9989f68f8c0db4995fa97ea6613e98f1d7 100644 (file)
@@ -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_ */