Add some more samlogon related netlogon init functions.
[gd/samba/.git] / source / rpc_client / init_netlogon.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Guenther Deschner                  2008.
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
22 /*******************************************************************
23  inits a structure.
24 ********************************************************************/
25
26 void init_netr_SamBaseInfo(struct netr_SamBaseInfo *r,
27                            NTTIME last_logon,
28                            NTTIME last_logoff,
29                            NTTIME acct_expiry,
30                            NTTIME last_password_change,
31                            NTTIME allow_password_change,
32                            NTTIME force_password_change,
33                            const char *account_name,
34                            const char *full_name,
35                            const char *logon_script,
36                            const char *profile_path,
37                            const char *home_directory,
38                            const char *home_drive,
39                            uint16_t logon_count,
40                            uint16_t bad_password_count,
41                            uint32_t rid,
42                            uint32_t primary_gid,
43                            struct samr_RidWithAttributeArray groups,
44                            uint32_t user_flags,
45                            struct netr_UserSessionKey key,
46                            const char *logon_server,
47                            const char *domain,
48                            struct dom_sid2 *domain_sid,
49                            struct netr_LMSessionKey LMSessKey,
50                            uint32_t acct_flags)
51 {
52         r->last_logon = last_logon;
53         r->last_logoff = last_logoff;
54         r->acct_expiry = acct_expiry;
55         r->last_password_change = last_password_change;
56         r->allow_password_change = allow_password_change;
57         r->force_password_change = force_password_change;
58         init_lsa_String(&r->account_name, account_name);
59         init_lsa_String(&r->full_name, full_name);
60         init_lsa_String(&r->logon_script, logon_script);
61         init_lsa_String(&r->profile_path, profile_path);
62         init_lsa_String(&r->home_directory, home_directory);
63         init_lsa_String(&r->home_drive, home_drive);
64         r->logon_count = logon_count;
65         r->bad_password_count = bad_password_count;
66         r->rid = rid;
67         r->primary_gid = primary_gid;
68         r->groups = groups;
69         r->user_flags = user_flags;
70         r->key = key;
71         init_lsa_StringLarge(&r->logon_server, logon_server);
72         init_lsa_StringLarge(&r->domain, domain);
73         r->domain_sid = domain_sid;
74         r->LMSessKey = LMSessKey;
75         r->acct_flags = acct_flags;
76 }
77
78 /*******************************************************************
79  inits a structure.
80 ********************************************************************/
81
82 void init_netr_SamInfo3(struct netr_SamInfo3 *r,
83                         NTTIME last_logon,
84                         NTTIME last_logoff,
85                         NTTIME acct_expiry,
86                         NTTIME last_password_change,
87                         NTTIME allow_password_change,
88                         NTTIME force_password_change,
89                         const char *account_name,
90                         const char *full_name,
91                         const char *logon_script,
92                         const char *profile_path,
93                         const char *home_directory,
94                         const char *home_drive,
95                         uint16_t logon_count,
96                         uint16_t bad_password_count,
97                         uint32_t rid,
98                         uint32_t primary_gid,
99                         struct samr_RidWithAttributeArray groups,
100                         uint32_t user_flags,
101                         struct netr_UserSessionKey key,
102                         const char *logon_server,
103                         const char *domain,
104                         struct dom_sid2 *domain_sid,
105                         struct netr_LMSessionKey LMSessKey,
106                         uint32_t acct_flags,
107                         uint32_t sidcount,
108                         struct netr_SidAttr *sids)
109 {
110         init_netr_SamBaseInfo(&r->base,
111                               last_logon,
112                               last_logoff,
113                               acct_expiry,
114                               last_password_change,
115                               allow_password_change,
116                               force_password_change,
117                               account_name,
118                               full_name,
119                               logon_script,
120                               profile_path,
121                               home_directory,
122                               home_drive,
123                               logon_count,
124                               bad_password_count,
125                               rid,
126                               primary_gid,
127                               groups,
128                               user_flags,
129                               key,
130                               logon_server,
131                               domain,
132                               domain_sid,
133                               LMSessKey,
134                               acct_flags);
135         r->sidcount = sidcount;
136         r->sids = sids;
137 }
138
139 /*******************************************************************
140  inits a structure.
141 ********************************************************************/
142
143 void init_netr_IdentityInfo(struct netr_IdentityInfo *r,
144                             const char *domain_name,
145                             uint32_t parameter_control,
146                             uint32_t logon_id_low,
147                             uint32_t logon_id_high,
148                             const char *account_name,
149                             const char *workstation)
150 {
151         init_lsa_String(&r->domain_name, domain_name);
152         r->parameter_control = parameter_control;
153         r->logon_id_low = logon_id_low;
154         r->logon_id_high = logon_id_high;
155         init_lsa_String(&r->account_name, account_name);
156         init_lsa_String(&r->workstation, workstation);
157 }
158
159 /*******************************************************************
160  inits a structure.
161 ********************************************************************/
162
163 void init_netr_NetworkInfo(struct netr_NetworkInfo *r,
164                            const char *domain_name,
165                            uint32_t parameter_control,
166                            uint32_t logon_id_low,
167                            uint32_t logon_id_high,
168                            const char *account_name,
169                            const char *workstation,
170                            uint8_t challenge[8],
171                            struct netr_ChallengeResponse nt,
172                            struct netr_ChallengeResponse lm)
173 {
174         init_netr_IdentityInfo(&r->identity_info,
175                                domain_name,
176                                parameter_control,
177                                logon_id_low,
178                                logon_id_high,
179                                account_name,
180                                workstation);
181         memcpy(r->challenge, challenge, 8);
182         r->nt = nt;
183         r->lm = lm;
184 }
185
186 /*******************************************************************
187  inits a structure.
188 ********************************************************************/
189
190 void init_netr_PasswordInfo(struct netr_PasswordInfo *r,
191                             const char *domain_name,
192                             uint32_t parameter_control,
193                             uint32_t logon_id_low,
194                             uint32_t logon_id_high,
195                             const char *account_name,
196                             const char *workstation,
197                             struct samr_Password lmpassword,
198                             struct samr_Password ntpassword)
199 {
200         init_netr_IdentityInfo(&r->identity_info,
201                                domain_name,
202                                parameter_control,
203                                logon_id_low,
204                                logon_id_high,
205                                account_name,
206                                workstation);
207         r->lmpassword = lmpassword;
208         r->ntpassword = ntpassword;
209 }