diff options
author | Stefan Metzmacher <metze@samba.org> | 2018-03-06 16:38:10 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2018-03-20 17:13:08 +0100 |
commit | 104de61756e6b098985c3a599a3ccf62cbbe7299 (patch) | |
tree | 6eaa38ddd1d8e36b38783dde8945cc36a3c4bdaa /auth | |
parent | 8b5253e5d4c79265a9c35955f83407a0c11a76d1 (diff) | |
download | samba-104de61756e6b098985c3a599a3ccf62cbbe7299.tar.gz |
auth: add auth_user_info_copy() function
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13328
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit 6ff891195855403bc485725aef8d43d4e3cabacb)
Diffstat (limited to 'auth')
-rw-r--r-- | auth/auth_sam_reply.c | 35 | ||||
-rw-r--r-- | auth/auth_sam_reply.h | 3 |
2 files changed, 38 insertions, 0 deletions
diff --git a/auth/auth_sam_reply.c b/auth/auth_sam_reply.c index 15d17b0745e..bd695151dc0 100644 --- a/auth/auth_sam_reply.c +++ b/auth/auth_sam_reply.c @@ -333,6 +333,41 @@ NTSTATUS make_user_info_SamBaseInfo(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +struct auth_user_info *auth_user_info_copy(TALLOC_CTX *mem_ctx, + const struct auth_user_info *src) +{ + struct auth_user_info *dst = NULL; + + dst = talloc_zero(mem_ctx, struct auth_user_info); + if (dst == NULL) { + return NULL; + } + + *dst = *src; +#define _COPY_STRING(_mem, _str) do { \ + if ((_str) != NULL) { \ + (_str) = talloc_strdup((_mem), (_str)); \ + if ((_str) == NULL) { \ + TALLOC_FREE(dst); \ + return NULL; \ + } \ + } \ +} while(0) + _COPY_STRING(dst, dst->account_name); + _COPY_STRING(dst, dst->user_principal_name); + _COPY_STRING(dst, dst->domain_name); + _COPY_STRING(dst, dst->dns_domain_name); + _COPY_STRING(dst, dst->full_name); + _COPY_STRING(dst, dst->logon_script); + _COPY_STRING(dst, dst->profile_path); + _COPY_STRING(dst, dst->home_directory); + _COPY_STRING(dst, dst->home_drive); + _COPY_STRING(dst, dst->logon_server); +#undef _COPY_STRING + + return dst; +} + /** * Make a user_info_dc struct from the info3 returned by a domain logon */ diff --git a/auth/auth_sam_reply.h b/auth/auth_sam_reply.h index 4aa3096c889..e4b26e961d7 100644 --- a/auth/auth_sam_reply.h +++ b/auth/auth_sam_reply.h @@ -38,6 +38,9 @@ NTSTATUS make_user_info_SamBaseInfo(TALLOC_CTX *mem_ctx, bool authenticated, struct auth_user_info **_user_info); +struct auth_user_info *auth_user_info_copy(TALLOC_CTX *mem_ctx, + const struct auth_user_info *src); + NTSTATUS auth_convert_user_info_dc_saminfo6(TALLOC_CTX *mem_ctx, const struct auth_user_info_dc *user_info_dc, struct netr_SamInfo6 **_sam6); |