wscript: Add check for --wrap linker flag
[vlendec/samba-autobuild/.git] / source3 / rpc_client / util_netlogon.c
1 /*
2    Unix SMB/CIFS implementation.
3    Authentication utility functions
4    Copyright (C) Volker Lendecke 2010
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "../librpc/gen_ndr/netlogon.h"
22 #include "../libcli/security/security.h"
23 #include "rpc_client/util_netlogon.h"
24
25 #define COPY_LSA_STRING(mem_ctx, in, out, name) do { \
26         if (in->name.string) { \
27                 out->name.string = talloc_strdup(mem_ctx, in->name.string); \
28                 NT_STATUS_HAVE_NO_MEMORY(out->name.string); \
29         } \
30 } while (0)
31
32 NTSTATUS copy_netr_SamBaseInfo(TALLOC_CTX *mem_ctx,
33                                const struct netr_SamBaseInfo *in,
34                                struct netr_SamBaseInfo *out)
35 {
36         /* first copy all, then realloc pointers */
37         *out = *in;
38
39         COPY_LSA_STRING(mem_ctx, in, out, account_name);
40         COPY_LSA_STRING(mem_ctx, in, out, full_name);
41         COPY_LSA_STRING(mem_ctx, in, out, logon_script);
42         COPY_LSA_STRING(mem_ctx, in, out, profile_path);
43         COPY_LSA_STRING(mem_ctx, in, out, home_directory);
44         COPY_LSA_STRING(mem_ctx, in, out, home_drive);
45
46         if (in->groups.count) {
47                 out->groups.rids = (struct samr_RidWithAttribute *)
48                         talloc_memdup(mem_ctx, in->groups.rids,
49                                 (sizeof(struct samr_RidWithAttribute) *
50                                         in->groups.count));
51                 NT_STATUS_HAVE_NO_MEMORY(out->groups.rids);
52         }
53
54         COPY_LSA_STRING(mem_ctx, in, out, logon_server);
55         COPY_LSA_STRING(mem_ctx, in, out, logon_domain);
56
57         if (in->domain_sid) {
58                 out->domain_sid = dom_sid_dup(mem_ctx, in->domain_sid);
59                 NT_STATUS_HAVE_NO_MEMORY(out->domain_sid);
60         }
61
62         return NT_STATUS_OK;
63 }