s3/packaging: pam_winbind has been moved to section 8.
[Samba/gebeck_regimport.git] / source3 / rpc_client / init_netlogon.c
blob99803aa597555b11149fffe624a493824bd60f72
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Guenther Deschner 2008.
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.
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.
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/>.
20 #include "includes.h"
21 #include "../libcli/auth/libcli_auth.h"
23 /*******************************************************************
24 inits a structure.
25 ********************************************************************/
27 void init_netr_SamBaseInfo(struct netr_SamBaseInfo *r,
28 NTTIME last_logon,
29 NTTIME last_logoff,
30 NTTIME acct_expiry,
31 NTTIME last_password_change,
32 NTTIME allow_password_change,
33 NTTIME force_password_change,
34 const char *account_name,
35 const char *full_name,
36 const char *logon_script,
37 const char *profile_path,
38 const char *home_directory,
39 const char *home_drive,
40 uint16_t logon_count,
41 uint16_t bad_password_count,
42 uint32_t rid,
43 uint32_t primary_gid,
44 struct samr_RidWithAttributeArray groups,
45 uint32_t user_flags,
46 struct netr_UserSessionKey key,
47 const char *logon_server,
48 const char *domain,
49 struct dom_sid2 *domain_sid,
50 struct netr_LMSessionKey LMSessKey,
51 uint32_t acct_flags)
53 r->last_logon = last_logon;
54 r->last_logoff = last_logoff;
55 r->acct_expiry = acct_expiry;
56 r->last_password_change = last_password_change;
57 r->allow_password_change = allow_password_change;
58 r->force_password_change = force_password_change;
59 init_lsa_String(&r->account_name, account_name);
60 init_lsa_String(&r->full_name, full_name);
61 init_lsa_String(&r->logon_script, logon_script);
62 init_lsa_String(&r->profile_path, profile_path);
63 init_lsa_String(&r->home_directory, home_directory);
64 init_lsa_String(&r->home_drive, home_drive);
65 r->logon_count = logon_count;
66 r->bad_password_count = bad_password_count;
67 r->rid = rid;
68 r->primary_gid = primary_gid;
69 r->groups = groups;
70 r->user_flags = user_flags;
71 r->key = key;
72 init_lsa_StringLarge(&r->logon_server, logon_server);
73 init_lsa_StringLarge(&r->domain, domain);
74 r->domain_sid = domain_sid;
75 r->LMSessKey = LMSessKey;
76 r->acct_flags = acct_flags;
79 /*******************************************************************
80 inits a structure.
81 ********************************************************************/
83 void init_netr_SamInfo3(struct netr_SamInfo3 *r,
84 NTTIME last_logon,
85 NTTIME last_logoff,
86 NTTIME acct_expiry,
87 NTTIME last_password_change,
88 NTTIME allow_password_change,
89 NTTIME force_password_change,
90 const char *account_name,
91 const char *full_name,
92 const char *logon_script,
93 const char *profile_path,
94 const char *home_directory,
95 const char *home_drive,
96 uint16_t logon_count,
97 uint16_t bad_password_count,
98 uint32_t rid,
99 uint32_t primary_gid,
100 struct samr_RidWithAttributeArray groups,
101 uint32_t user_flags,
102 struct netr_UserSessionKey key,
103 const char *logon_server,
104 const char *domain,
105 struct dom_sid2 *domain_sid,
106 struct netr_LMSessionKey LMSessKey,
107 uint32_t acct_flags,
108 uint32_t sidcount,
109 struct netr_SidAttr *sids)
111 init_netr_SamBaseInfo(&r->base,
112 last_logon,
113 last_logoff,
114 acct_expiry,
115 last_password_change,
116 allow_password_change,
117 force_password_change,
118 account_name,
119 full_name,
120 logon_script,
121 profile_path,
122 home_directory,
123 home_drive,
124 logon_count,
125 bad_password_count,
126 rid,
127 primary_gid,
128 groups,
129 user_flags,
130 key,
131 logon_server,
132 domain,
133 domain_sid,
134 LMSessKey,
135 acct_flags);
136 r->sidcount = sidcount;
137 r->sids = sids;
140 /*******************************************************************
141 inits a structure.
142 ********************************************************************/
144 void init_netr_IdentityInfo(struct netr_IdentityInfo *r,
145 const char *domain_name,
146 uint32_t parameter_control,
147 uint32_t logon_id_low,
148 uint32_t logon_id_high,
149 const char *account_name,
150 const char *workstation)
152 init_lsa_String(&r->domain_name, domain_name);
153 r->parameter_control = parameter_control;
154 r->logon_id_low = logon_id_low;
155 r->logon_id_high = logon_id_high;
156 init_lsa_String(&r->account_name, account_name);
157 init_lsa_String(&r->workstation, workstation);
160 /*******************************************************************
161 inits a structure.
162 This is a network logon packet. The log_id parameters
163 are what an NT server would generate for LUID once the
164 user is logged on. I don't think we care about them.
166 Note that this has no access to the NT and LM hashed passwords,
167 so it forwards the challenge, and the NT and LM responses (24
168 bytes each) over the secure channel to the Domain controller
169 for it to say yea or nay. This is the preferred method of
170 checking for a logon as it doesn't export the password
171 hashes to anyone who has compromised the secure channel. JRA.
173 ********************************************************************/
175 void init_netr_NetworkInfo(struct netr_NetworkInfo *r,
176 const char *domain_name,
177 uint32_t parameter_control,
178 uint32_t logon_id_low,
179 uint32_t logon_id_high,
180 const char *account_name,
181 const char *workstation,
182 uint8_t challenge[8],
183 struct netr_ChallengeResponse nt,
184 struct netr_ChallengeResponse lm)
186 init_netr_IdentityInfo(&r->identity_info,
187 domain_name,
188 parameter_control,
189 logon_id_low,
190 logon_id_high,
191 account_name,
192 workstation);
193 memcpy(r->challenge, challenge, 8);
194 r->nt = nt;
195 r->lm = lm;
198 /*******************************************************************
199 inits a structure.
200 ********************************************************************/
202 void init_netr_PasswordInfo(struct netr_PasswordInfo *r,
203 const char *domain_name,
204 uint32_t parameter_control,
205 uint32_t logon_id_low,
206 uint32_t logon_id_high,
207 const char *account_name,
208 const char *workstation,
209 struct samr_Password lmpassword,
210 struct samr_Password ntpassword)
212 init_netr_IdentityInfo(&r->identity_info,
213 domain_name,
214 parameter_control,
215 logon_id_low,
216 logon_id_high,
217 account_name,
218 workstation);
219 r->lmpassword = lmpassword;
220 r->ntpassword = ntpassword;
223 /*************************************************************************
224 inits a netr_CryptPassword structure
225 *************************************************************************/
227 void init_netr_CryptPassword(const char *pwd,
228 unsigned char session_key[16],
229 struct netr_CryptPassword *pwd_buf)
231 struct samr_CryptPassword password_buf;
233 encode_pw_buffer(password_buf.data, pwd, STR_UNICODE);
235 arcfour_crypt(password_buf.data, session_key, 516);
236 memcpy(pwd_buf->data, password_buf.data, 512);
237 pwd_buf->length = IVAL(password_buf.data, 512);