From a872670fd6ccbd375f40ccacf29c74c8c9be9206 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 7 Jan 2016 15:23:56 +0100 Subject: [PATCH] auth/auth_sam_reply: add auth_convert_user_info_dc_saminfo2() helper function Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- auth/auth_sam_reply.c | 26 ++++++++++++++++++++++++++ auth/auth_sam_reply.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/auth/auth_sam_reply.c b/auth/auth_sam_reply.c index 5602daf62de..b3255864047 100644 --- a/auth/auth_sam_reply.c +++ b/auth/auth_sam_reply.c @@ -202,6 +202,32 @@ NTSTATUS auth_convert_user_info_dc_saminfo6(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +/* Note that the validity of the _sam2 structure is only as long as + * the user_info_dc it was generated from */ +NTSTATUS auth_convert_user_info_dc_saminfo2(TALLOC_CTX *mem_ctx, + const struct auth_user_info_dc *user_info_dc, + struct netr_SamInfo2 **_sam2) +{ + NTSTATUS status; + struct netr_SamInfo6 *sam6 = NULL; + struct netr_SamInfo2 *sam2 = NULL; + + sam2 = talloc_zero(mem_ctx, struct netr_SamInfo2); + if (sam2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = auth_convert_user_info_dc_saminfo6(sam2, user_info_dc, &sam6); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(sam2); + return status; + } + sam2->base = sam6->base; + + *_sam2 = sam2; + return NT_STATUS_OK; +} + /* Note that the validity of the _sam3 structure is only as long as * the user_info_dc it was generated from */ NTSTATUS auth_convert_user_info_dc_saminfo3(TALLOC_CTX *mem_ctx, diff --git a/auth/auth_sam_reply.h b/auth/auth_sam_reply.h index c163bcaa288..22e3c77e267 100644 --- a/auth/auth_sam_reply.h +++ b/auth/auth_sam_reply.h @@ -44,6 +44,9 @@ NTSTATUS auth_convert_user_info_dc_sambaseinfo(TALLOC_CTX *mem_ctx, NTSTATUS auth_convert_user_info_dc_saminfo6(TALLOC_CTX *mem_ctx, const struct auth_user_info_dc *user_info_dc, struct netr_SamInfo6 **_sam6); +NTSTATUS auth_convert_user_info_dc_saminfo2(TALLOC_CTX *mem_ctx, + const struct auth_user_info_dc *user_info_dc, + struct netr_SamInfo2 **_sam2); NTSTATUS auth_convert_user_info_dc_saminfo3(TALLOC_CTX *mem_ctx, const struct auth_user_info_dc *user_info_dc, struct netr_SamInfo3 **_sam3); -- 2.34.1