r2515: Fixes from smbtorture - these session keys are not individually encrypted.
[abartlet/samba.git/.git] / source4 / rpc_server / netlogon / dcerpc_netlogon.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    endpoint server for the netlogon pipe
5
6    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "rpc_server/common/common.h"
25
26 struct server_pipe_state {
27         TALLOC_CTX *mem_ctx;
28         struct netr_Credential client_challenge;
29         struct netr_Credential server_challenge;
30         BOOL authenticated;
31         char *account_name;
32         char *computer_name;  /* for logging only */
33         uint32_t acct_flags;
34         uint16_t sec_chan_type;
35         struct creds_CredentialState *creds;
36 };
37
38
39 /*
40   a client has connected to the netlogon server using schannel, so we need
41   to re-establish the credentials state
42 */
43 static NTSTATUS netlogon_schannel_setup(struct dcesrv_call_state *dce_call) 
44 {
45         struct server_pipe_state *state;
46         NTSTATUS status;
47         TALLOC_CTX *mem_ctx;
48
49         mem_ctx = talloc_init("netlogon_bind");
50         if (!mem_ctx) {
51                 return NT_STATUS_NO_MEMORY;
52         }
53         state = talloc_p(mem_ctx, struct server_pipe_state);
54         if (state == NULL) {
55                 talloc_free(mem_ctx);
56                 return NT_STATUS_NO_MEMORY;
57         }
58         ZERO_STRUCTP(state);
59         state->mem_ctx = mem_ctx;
60         state->authenticated = True;
61         
62         if (dce_call->conn->auth_state.session_info == NULL) {
63                 talloc_free(mem_ctx);
64                 smb_panic("No session info provided by schannel level setup!");
65                 return NT_STATUS_NO_USER_SESSION_KEY;
66         }
67         
68         status = dcerpc_schannel_creds(dce_call->conn->auth_state.gensec_security, 
69                                        mem_ctx, 
70                                        &state->creds);
71
72         if (!NT_STATUS_IS_OK(status)) {
73                 DEBUG(3, ("getting schannel credentials failed with %s\n", nt_errstr(status)));
74                 talloc_free(mem_ctx);
75                 return status;
76         }
77         
78         dce_call->conn->private = state;
79
80         return NT_STATUS_OK;
81 }
82
83 /*
84   a hook for bind on the netlogon pipe
85 */
86 static NTSTATUS netlogon_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *di) 
87 {
88         dce_call->conn->private = NULL;
89
90         /* if this is a schannel bind then we need to reconstruct the pipe state */
91         if (dce_call->conn->auth_state.auth_info &&
92             dce_call->conn->auth_state.auth_info->auth_type == DCERPC_AUTH_TYPE_SCHANNEL) {
93                 NTSTATUS status;
94
95                 DEBUG(5, ("schannel bind on netlogon\n"));
96
97                 status = netlogon_schannel_setup(dce_call);
98                 if (!NT_STATUS_IS_OK(status)) {
99                         DEBUG(3, ("schannel bind on netlogon failed with %s\n", nt_errstr(status)));
100                         return status;
101                 }
102         }
103
104         return NT_STATUS_OK;
105 }
106
107 /* this function is called when the client disconnects the endpoint */
108 static void netlogon_unbind(struct dcesrv_connection *conn, const struct dcesrv_interface *di) 
109 {
110         struct server_pipe_state *pipe_state = conn->private;
111
112         if (pipe_state) {
113                 talloc_free(pipe_state->mem_ctx);
114         }
115
116         conn->private = NULL;
117 }
118
119 #define DCESRV_INTERFACE_NETLOGON_BIND netlogon_bind
120 #define DCESRV_INTERFACE_NETLOGON_UNBIND netlogon_unbind
121
122 static NTSTATUS netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
123                                         struct netr_ServerReqChallenge *r)
124 {
125         struct server_pipe_state *pipe_state = dce_call->conn->private;
126         TALLOC_CTX *pipe_mem_ctx;
127
128         ZERO_STRUCTP(r->out.credentials);
129
130         /* destroyed on pipe shutdown */
131
132         if (pipe_state) {
133                 talloc_free(pipe_state->mem_ctx);
134                 dce_call->conn->private = NULL;
135         }
136         
137         pipe_mem_ctx = talloc_init("internal netlogon pipe state for %s", 
138                                    r->in.computer_name);
139         
140         if (!pipe_mem_ctx) {
141                 return NT_STATUS_NO_MEMORY;
142         }
143
144         pipe_state = talloc_p(pipe_mem_ctx, struct server_pipe_state);
145         if (!pipe_state) {
146                 talloc_free(pipe_mem_ctx);
147                 return NT_STATUS_NO_MEMORY;
148         }
149
150         pipe_state->mem_ctx = pipe_mem_ctx;
151         pipe_state->authenticated = False;
152         pipe_state->creds = NULL;
153         pipe_state->account_name = NULL;
154         pipe_state->computer_name = NULL;
155
156         pipe_state->client_challenge = *r->in.credentials;
157
158         generate_random_buffer(pipe_state->server_challenge.data, 
159                                sizeof(pipe_state->server_challenge.data));
160
161         *r->out.credentials = pipe_state->server_challenge;
162
163         dce_call->conn->private = pipe_state;
164
165         return NT_STATUS_OK;
166 }
167
168 static NTSTATUS netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
169                                          struct netr_ServerAuthenticate3 *r)
170 {
171         struct server_pipe_state *pipe_state = dce_call->conn->private;
172         void *sam_ctx;
173         struct samr_Password *mach_pwd;
174         uint16_t acct_flags;
175         int num_records;
176         struct ldb_message **msgs;
177         NTSTATUS nt_status;
178         const char *attrs[] = {"unicodePwd", "lmPwdHash", "ntPwdHash", "userAccountControl", 
179                                "objectSid", NULL};
180
181         ZERO_STRUCTP(r->out.credentials);
182         *r->out.rid = 0;
183         *r->out.negotiate_flags = *r->in.negotiate_flags;
184
185         if (!pipe_state) {
186                 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
187                 return NT_STATUS_ACCESS_DENIED;
188         }
189
190         sam_ctx = samdb_connect(mem_ctx);
191         if (sam_ctx == NULL) {
192                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
193         }
194         /* pull the user attributes */
195         num_records = samdb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs,
196                                    "(&(sAMAccountName=%s)(objectclass=user))", 
197                                    r->in.account_name);
198
199         if (num_records == 0) {
200                 DEBUG(3,("Couldn't find user [%s] in samdb.\n", 
201                          r->in.account_name));
202                 return NT_STATUS_NO_SUCH_USER;
203         }
204
205         if (num_records > 1) {
206                 DEBUG(0,("Found %d records matching user [%s]\n", num_records, r->in.account_name));
207                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
208         }
209
210         acct_flags = samdb_result_acct_flags(msgs[0], 
211                                              "userAccountControl");
212
213         if (acct_flags & ACB_DISABLED) {
214                 DEBUG(1, ("Account [%s] is disabled\n", r->in.account_name));
215                 return NT_STATUS_ACCESS_DENIED;
216         }
217
218         if (r->in.secure_channel_type == SEC_CHAN_WKSTA) {
219                 if (!(acct_flags & ACB_WSTRUST)) {
220                         DEBUG(1, ("Client asked for a workstation secure channel, but is not a workstation (member server) acb flags: 0x%x\n", acct_flags));
221                         return NT_STATUS_ACCESS_DENIED;
222                 }
223         } else if (r->in.secure_channel_type == SEC_CHAN_DOMAIN) {
224                 if (!(acct_flags & ACB_DOMTRUST)) {
225                         DEBUG(1, ("Client asked for a trusted domain secure channel, but is not a trusted domain: acb flags: 0x%x\n", acct_flags));
226                         return NT_STATUS_ACCESS_DENIED;
227                 }
228         } else if (r->in.secure_channel_type == SEC_CHAN_BDC) {
229                 if (!(acct_flags & ACB_SVRTRUST)) {
230                         DEBUG(1, ("Client asked for a server secure channel, but is not a server (domain controller): acb flags: 0x%x\n", acct_flags));
231                         return NT_STATUS_ACCESS_DENIED;
232                 }
233         } else {
234                 DEBUG(1, ("Client asked for an invalid secure channel type: %d\n", 
235                           r->in.secure_channel_type));
236                 return NT_STATUS_ACCESS_DENIED;
237         }
238
239         pipe_state->acct_flags = acct_flags;
240         pipe_state->sec_chan_type = r->in.secure_channel_type;
241
242         *r->out.rid = samdb_result_rid_from_sid(mem_ctx, msgs[0], "objectSid", 0);
243
244         nt_status = samdb_result_passwords(mem_ctx, msgs[0], NULL, &mach_pwd);
245         if (!NT_STATUS_IS_OK(nt_status) || mach_pwd == NULL) {
246                 return NT_STATUS_ACCESS_DENIED;
247         }
248
249         if (!pipe_state->creds) {
250                 pipe_state->creds = talloc_p(pipe_state->mem_ctx, struct creds_CredentialState);
251                 if (!pipe_state->creds) {
252                         return NT_STATUS_NO_MEMORY;
253                 }
254         }
255
256         creds_server_init(pipe_state->creds, &pipe_state->client_challenge, 
257                           &pipe_state->server_challenge, mach_pwd,
258                           r->out.credentials,
259                           *r->in.negotiate_flags);
260         
261         if (!creds_server_check(pipe_state->creds, r->in.credentials)) {
262                 return NT_STATUS_ACCESS_DENIED;
263         }
264
265         pipe_state->authenticated = True;
266
267         if (pipe_state->account_name) {
268                 /* We don't want a memory leak on this long-lived talloc context */
269                 talloc_free(pipe_state->account_name);
270         }
271
272         pipe_state->account_name = talloc_strdup(pipe_state->mem_ctx, r->in.account_name);
273         
274         if (pipe_state->computer_name) {
275                 /* We don't want a memory leak on this long-lived talloc context */
276                 talloc_free(pipe_state->account_name);
277         }
278
279         pipe_state->computer_name = talloc_strdup(pipe_state->mem_ctx, r->in.computer_name);
280
281         /* remember this session key state */
282         nt_status = schannel_store_session_key(mem_ctx, pipe_state->computer_name, pipe_state->creds);
283
284         return nt_status;
285 }
286                                                  
287 static NTSTATUS netr_ServerAuthenticate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
288                                         struct netr_ServerAuthenticate *r)
289 {
290         struct netr_ServerAuthenticate3 r3;
291         uint32_t rid = 0;
292         /* TODO: 
293          * negotiate_flags is used as an [in] parameter
294          * so it need to be initialised.
295          *
296          * (I think ... = 0; seems wrong here --metze)
297          */
298         uint32 negotiate_flags = 0;  
299
300         r3.in.server_name = r->in.server_name;
301         r3.in.account_name = r->in.account_name;
302         r3.in.secure_channel_type = r->in.secure_channel_type;
303         r3.in.computer_name = r->in.computer_name;
304         r3.in.credentials = r->in.credentials;
305         r3.out.credentials = r->out.credentials;
306         r3.in.negotiate_flags = &negotiate_flags;
307         r3.out.negotiate_flags = &negotiate_flags;
308         r3.out.rid = &rid;
309         
310         return netr_ServerAuthenticate3(dce_call, mem_ctx, &r3);
311 }
312
313 static NTSTATUS netr_ServerAuthenticate2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
314                                          struct netr_ServerAuthenticate2 *r)
315 {
316         struct netr_ServerAuthenticate3 r3;
317         uint32 rid = 0;
318
319         r3.in.server_name = r->in.server_name;
320         r3.in.account_name = r->in.account_name;
321         r3.in.secure_channel_type = r->in.secure_channel_type;
322         r3.in.computer_name = r->in.computer_name;
323         r3.in.credentials = r->in.credentials;
324         r3.out.credentials = r->out.credentials;
325         r3.in.negotiate_flags = r->in.negotiate_flags;
326         r3.out.negotiate_flags = r->out.negotiate_flags;
327         r3.out.rid = &rid;
328         
329         return netr_ServerAuthenticate3(dce_call, mem_ctx, &r3);
330 }
331
332
333 static BOOL netr_creds_server_step_check(struct server_pipe_state *pipe_state,
334                                          struct netr_Authenticator *received_authenticator,
335                                          struct netr_Authenticator *return_authenticator) 
336 {
337         if (!pipe_state->authenticated) {
338                 return False;
339         }
340         return creds_server_step_check(pipe_state->creds, 
341                                        received_authenticator, 
342                                        return_authenticator);
343 }
344
345
346 static NTSTATUS netr_ServerPasswordSet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
347                                        struct netr_ServerPasswordSet *r)
348 {
349         struct server_pipe_state *pipe_state = dce_call->conn->private;
350
351         void *sam_ctx;
352         int num_records;
353         int num_records_domain;
354         int ret;
355         struct ldb_message **msgs;
356         struct ldb_message **msgs_domain;
357         NTSTATUS nt_status;
358         struct ldb_message mod, *msg_set_pw = &mod;
359         const char *domain_dn;
360         const char *domain_sid;
361
362         const char *attrs[] = {"objectSid", NULL };
363
364         const char **domain_attrs = attrs;
365         ZERO_STRUCT(mod);
366
367         if (!pipe_state) {
368                 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
369                 return NT_STATUS_ACCESS_DENIED;
370         }
371
372         if (!netr_creds_server_step_check(pipe_state, &r->in.credential, &r->out.return_authenticator)) {
373                 return NT_STATUS_ACCESS_DENIED;
374         }
375
376         sam_ctx = samdb_connect(mem_ctx);
377         if (sam_ctx == NULL) {
378                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
379         }
380         /* pull the user attributes */
381         num_records = samdb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs,
382                                    "(&(sAMAccountName=%s)(objectclass=user))", 
383                                    pipe_state->account_name);
384
385         if (num_records == 0) {
386                 DEBUG(3,("Couldn't find user [%s] in samdb.\n", 
387                          pipe_state->account_name));
388                 return NT_STATUS_NO_SUCH_USER;
389         }
390
391         if (num_records > 1) {
392                 DEBUG(0,("Found %d records matching user [%s]\n", num_records, 
393                          pipe_state->account_name));
394                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
395         }
396
397         domain_sid = samdb_result_sid_prefix(mem_ctx, msgs[0], "objectSid");
398         if (!domain_sid) {
399                 DEBUG(0,("no objectSid in user record\n"));
400                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
401         }
402
403         /* find the domain's DN */
404         num_records_domain = samdb_search(sam_ctx, mem_ctx, NULL, 
405                                           &msgs_domain, domain_attrs,
406                                           "(&(objectSid=%s)(objectclass=domain))", 
407                                           domain_sid);
408
409         if (num_records_domain == 0) {
410                 DEBUG(3,("check_sam_security: Couldn't find domain [%s] in passdb file.\n", 
411                          domain_sid));
412                 return NT_STATUS_NO_SUCH_USER;
413         }
414
415         if (num_records_domain > 1) {
416                 DEBUG(0,("Found %d records matching domain [%s]\n", 
417                          num_records_domain, domain_sid));
418                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
419         }
420
421         domain_dn = msgs_domain[0]->dn;
422         
423         mod.dn = talloc_strdup(mem_ctx, msgs[0]->dn);
424         if (!mod.dn) {
425                 return NT_STATUS_NO_MEMORY;
426         }
427         
428         creds_des_decrypt(pipe_state->creds, &r->in.new_password);
429
430         /* set the password - samdb needs to know both the domain and user DNs,
431            so the domain password policy can be used */
432         nt_status = samdb_set_password(sam_ctx, mem_ctx,
433                                        msgs[0]->dn, domain_dn,
434                                        msg_set_pw, 
435                                        NULL, /* Don't have plaintext */
436                                        NULL, &r->in.new_password,
437                                        False /* This is not considered a password change */,
438                                        NULL);
439         
440         if (!NT_STATUS_IS_OK(nt_status)) {
441                 return nt_status;
442         }
443
444         ret = samdb_replace(sam_ctx, mem_ctx, msg_set_pw);
445         if (ret != 0) {
446                 /* we really need samdb.c to return NTSTATUS */
447                 return NT_STATUS_UNSUCCESSFUL;
448         }
449
450         return NT_STATUS_OK;
451 }
452
453
454 /* 
455   netr_LogonUasLogon 
456 */
457 static WERROR netr_LogonUasLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
458                                  struct netr_LogonUasLogon *r)
459 {
460         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
461 }
462
463
464 /* 
465   netr_LogonUasLogoff 
466 */
467 static WERROR netr_LogonUasLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
468                        struct netr_LogonUasLogoff *r)
469 {
470         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
471 }
472
473
474 /* 
475   netr_LogonSamLogonWithFlags
476
477 */
478 static NTSTATUS netr_LogonSamLogonWithFlags(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
479                                             struct netr_LogonSamLogonWithFlags *r)
480 {
481         struct server_pipe_state *pipe_state = dce_call->conn->private;
482
483         struct auth_context *auth_context;
484         struct auth_usersupplied_info *user_info;
485         struct auth_serversupplied_info *server_info;
486         NTSTATUS nt_status;
487         const uint8_t *chal;
488         static const char zeros[16];
489         struct netr_SamBaseInfo *sam;
490         struct netr_SamInfo2 *sam2;
491         struct netr_SamInfo3 *sam3;
492         struct netr_SamInfo6 *sam6;
493         
494         if (!pipe_state) {
495                 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
496                 return NT_STATUS_ACCESS_DENIED;
497         }
498
499         r->out.return_authenticator = talloc_p(mem_ctx, struct netr_Authenticator);
500         if (!r->out.return_authenticator) {
501                 return NT_STATUS_NO_MEMORY;
502         }
503
504         if (!netr_creds_server_step_check(pipe_state, r->in.credential, r->out.return_authenticator)) {
505                 return NT_STATUS_ACCESS_DENIED;
506         }
507
508         switch (r->in.logon_level) {
509         case 1:
510         case 3:
511         case 5:
512                 creds_arcfour_crypt(pipe_state->creds, 
513                                     r->in.logon.password->lmpassword.hash, 
514                                     sizeof(r->in.logon.password->lmpassword.hash));
515                 creds_arcfour_crypt(pipe_state->creds, 
516                                     r->in.logon.password->ntpassword.hash, 
517                                     sizeof(r->in.logon.password->ntpassword.hash));
518
519                 nt_status = make_auth_context_subsystem(&auth_context);
520                 if (!NT_STATUS_IS_OK(nt_status)) {
521                         return nt_status;
522                 }
523
524                 chal = auth_context->get_ntlm_challenge(auth_context);
525                 nt_status = make_user_info_netlogon_interactive(&user_info,
526                                                                 r->in.logon.password->identity_info.account_name.string,
527                                                                 r->in.logon.password->identity_info.domain_name.string,
528                                                                 r->in.logon.password->identity_info.workstation.string,
529                                                                 chal,
530                                                                 &r->in.logon.password->lmpassword,
531                                                                 &r->in.logon.password->ntpassword);
532                 break;
533                 
534         case 2:
535         case 6:
536                 nt_status = make_auth_context_fixed(&auth_context, r->in.logon.network->challenge);
537                 if (!NT_STATUS_IS_OK(nt_status)) {
538                         return nt_status;
539                 }
540
541                 nt_status = make_user_info_netlogon_network(&user_info,
542                                                             r->in.logon.network->identity_info.account_name.string,
543                                                             r->in.logon.network->identity_info.domain_name.string,
544                                                             r->in.logon.network->identity_info.workstation.string,
545                                                             r->in.logon.network->lm.data, r->in.logon.network->lm.length,
546                                                             r->in.logon.network->nt.data, r->in.logon.network->nt.length);
547                 break;
548         default:
549                 free_auth_context(&auth_context);
550                 return NT_STATUS_INVALID_PARAMETER;
551         }
552         
553         if (!NT_STATUS_IS_OK(nt_status)) {
554                 return nt_status;
555         }
556
557         nt_status = auth_context->check_ntlm_password(auth_context,
558                                                       user_info, 
559                                                       &server_info);
560
561         if (!NT_STATUS_IS_OK(nt_status)) {
562                 free_auth_context(&auth_context);
563                 return nt_status;
564         }
565         free_auth_context(&auth_context);
566
567         sam = talloc_p(mem_ctx, struct netr_SamBaseInfo);
568
569         ZERO_STRUCTP(sam);
570         
571         sam->last_logon = server_info->last_logon;
572         sam->last_logoff = server_info->last_logoff;
573         sam->acct_expiry = server_info->acct_expiry;
574         sam->last_password_change = server_info->last_password_change;
575         sam->allow_password_change = server_info->allow_password_change;
576         sam->force_password_change = server_info->force_password_change;
577         
578         sam->account_name.string = talloc_strdup(mem_ctx, server_info->account_name);
579         sam->full_name.string = talloc_strdup(mem_ctx, server_info->full_name);
580         sam->logon_script.string = talloc_strdup(mem_ctx, server_info->logon_script);
581         sam->profile_path.string = talloc_strdup(mem_ctx, server_info->profile_path);
582         sam->home_directory.string = talloc_strdup(mem_ctx, server_info->home_directory);
583         sam->home_drive.string = talloc_strdup(mem_ctx, server_info->home_drive);
584         
585         sam->logon_count = server_info->logon_count;
586         sam->bad_password_count = sam->bad_password_count;
587         sam->rid = server_info->user_sid->sub_auths[server_info->user_sid->num_auths-1];
588         sam->primary_gid = server_info->primary_group_sid->sub_auths[server_info->primary_group_sid->num_auths-1];
589         sam->group_count = 0;
590         sam->groupids = NULL;
591         sam->user_flags = 0; /* TODO: w2k3 uses 0x120 - what is this? */
592         sam->acct_flags = server_info->acct_flags;      
593         sam->logon_server.string = lp_netbios_name();
594         
595         sam->domain.string = talloc_strdup(mem_ctx, server_info->domain);
596         
597         sam->domain_sid = dom_sid_dup(mem_ctx, server_info->user_sid);
598         sam->domain_sid->num_auths--;
599
600         if (server_info->user_session_key.length == sizeof(sam->key.key)) {
601                 memcpy(sam->key.key, server_info->user_session_key.data, sizeof(sam->key.key));
602         } else {
603                 ZERO_STRUCT(sam->key.key);
604         }
605         
606         /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
607         /* It appears that level 6 is not individually encrypted */
608         if ((r->in.validation_level != 6) 
609             && memcmp(sam->key.key, zeros,  
610                       sizeof(sam->key.key)) != 0) {
611                 creds_arcfour_crypt(pipe_state->creds, 
612                                     sam->key.key, 
613                                     sizeof(sam->key.key));
614         }
615         
616         if (server_info->lm_session_key.length == sizeof(sam->LMSessKey.key)) {
617                 memcpy(sam->LMSessKey.key, server_info->lm_session_key.data, 
618                        sizeof(sam->LMSessKey.key));
619         } else {
620                 ZERO_STRUCT(sam->LMSessKey.key);
621         }
622         
623         /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
624         /* It appears that level 6 is not individually encrypted */
625         if ((r->in.validation_level != 6) 
626             && memcmp(sam->LMSessKey.key, zeros,  
627                       sizeof(sam->LMSessKey.key)) != 0) {
628                 creds_arcfour_crypt(pipe_state->creds, 
629                                     sam->LMSessKey.key, 
630                                     sizeof(sam->LMSessKey.key));
631         }
632
633         switch (r->in.validation_level) {
634         case 2:
635                 sam2 = talloc_p(mem_ctx, struct netr_SamInfo2);
636                 ZERO_STRUCTP(sam2);
637                 sam2->base = *sam;
638                 r->out.validation.sam2 = sam2;
639                 break;
640
641         case 3:
642                 sam3 = talloc_p(mem_ctx, struct netr_SamInfo3);
643                 ZERO_STRUCTP(sam3);
644                 sam3->base = *sam;
645                 r->out.validation.sam3 = sam3;
646                 break;
647
648         case 6:
649                 sam6 = talloc_p(mem_ctx, struct netr_SamInfo6);
650                 ZERO_STRUCTP(sam6);
651                 sam6->base = *sam;
652                 sam6->forest.string = lp_realm();
653                 sam6->principle.string = talloc_asprintf(mem_ctx, "%s@%s", 
654                                                          sam->account_name.string, sam6->forest.string);
655                 r->out.validation.sam6 = sam6;
656                 break;
657
658         default:
659                 break;
660         }
661
662         r->out.authoritative = 1;
663
664         return NT_STATUS_OK;
665 }
666
667 /* 
668   netr_LogonSamLogon
669 */
670 static NTSTATUS netr_LogonSamLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
671                                    struct netr_LogonSamLogon *r)
672 {
673         struct netr_LogonSamLogonWithFlags r2;
674         NTSTATUS status;
675
676         ZERO_STRUCT(r2);
677
678         r2.in.server_name = r->in.server_name;
679         r2.in.workstation = r->in.workstation;
680         r2.in.credential  = r->in.credential;
681         r2.in.return_authenticator = r->in.return_authenticator;
682         r2.in.logon_level = r->in.logon_level;
683         r2.in.logon = r->in.logon;
684         r2.in.validation_level = r->in.validation_level;
685         r2.in.flags = 0;
686
687         status = netr_LogonSamLogonWithFlags(dce_call, mem_ctx, &r2);
688
689         r->out.return_authenticator = r2.out.return_authenticator;
690         r->out.validation = r2.out.validation;
691         r->out.authoritative = r2.out.authoritative;
692
693         return status;
694 }
695
696
697 /* 
698   netr_LogonSamLogoff 
699 */
700 static NTSTATUS netr_LogonSamLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
701                        struct netr_LogonSamLogoff *r)
702 {
703         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
704 }
705
706
707
708 /* 
709   netr_DatabaseDeltas 
710 */
711 static NTSTATUS netr_DatabaseDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
712                        struct netr_DatabaseDeltas *r)
713 {
714         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
715 }
716
717
718 /* 
719   netr_DatabaseSync 
720 */
721 static NTSTATUS netr_DatabaseSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
722                        struct netr_DatabaseSync *r)
723 {
724         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
725 }
726
727
728 /* 
729   netr_AccountDeltas 
730 */
731 static NTSTATUS netr_AccountDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
732                        struct netr_AccountDeltas *r)
733 {
734         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
735 }
736
737
738 /* 
739   netr_AccountSync 
740 */
741 static NTSTATUS netr_AccountSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
742                        struct netr_AccountSync *r)
743 {
744         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
745 }
746
747
748 /* 
749   netr_GetDcName 
750 */
751 static NTSTATUS netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
752                        struct netr_GetDcName *r)
753 {
754         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
755 }
756
757
758 /* 
759   netr_LogonControl 
760 */
761 static WERROR netr_LogonControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
762                        struct netr_LogonControl *r)
763 {
764         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
765 }
766
767
768 /* 
769   netr_GetAnyDCName 
770 */
771 static WERROR netr_GetAnyDCName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
772                        struct netr_GetAnyDCName *r)
773 {
774         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
775 }
776
777
778 /* 
779   netr_LogonControl2 
780 */
781 static WERROR netr_LogonControl2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
782                        struct netr_LogonControl2 *r)
783 {
784         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
785 }
786
787
788 /* 
789   netr_DatabaseSync2 
790 */
791 static NTSTATUS netr_DatabaseSync2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
792                        struct netr_DatabaseSync2 *r)
793 {
794         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
795 }
796
797
798 /* 
799   netr_DatabaseRedo 
800 */
801 static NTSTATUS netr_DatabaseRedo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
802                        struct netr_DatabaseRedo *r)
803 {
804         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
805 }
806
807
808 /* 
809   netr_LogonControl2Ex 
810 */
811 static WERROR netr_LogonControl2Ex(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
812                        struct netr_LogonControl2Ex *r)
813 {
814         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
815 }
816
817
818 /* 
819   netr_NETRENUMERATETRUSTEDDOMAINS 
820 */
821 static WERROR netr_NETRENUMERATETRUSTEDDOMAINS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
822                        struct netr_NETRENUMERATETRUSTEDDOMAINS *r)
823 {
824         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
825 }
826
827
828 /* 
829   netr_DSRGETDCNAME 
830 */
831 static WERROR netr_DSRGETDCNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
832                        struct netr_DSRGETDCNAME *r)
833 {
834         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
835 }
836
837
838 /* 
839   netr_NETRLOGONDUMMYROUTINE1 
840 */
841 static WERROR netr_NETRLOGONDUMMYROUTINE1(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
842                        struct netr_NETRLOGONDUMMYROUTINE1 *r)
843 {
844         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
845 }
846
847
848 /* 
849   netr_NETRLOGONSETSERVICEBITS 
850 */
851 static WERROR netr_NETRLOGONSETSERVICEBITS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
852                        struct netr_NETRLOGONSETSERVICEBITS *r)
853 {
854         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
855 }
856
857
858 /* 
859   netr_NETRLOGONGETTRUSTRID 
860 */
861 static WERROR netr_NETRLOGONGETTRUSTRID(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
862                        struct netr_NETRLOGONGETTRUSTRID *r)
863 {
864         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
865 }
866
867
868 /* 
869   netr_NETRLOGONCOMPUTESERVERDIGEST 
870 */
871 static WERROR netr_NETRLOGONCOMPUTESERVERDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
872                        struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
873 {
874         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
875 }
876
877
878 /* 
879   netr_NETRLOGONCOMPUTECLIENTDIGEST 
880 */
881 static WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
882                        struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
883 {
884         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
885 }
886
887
888 /* 
889   netr_DSRGETDCNAMEX 
890 */
891 static WERROR netr_DSRGETDCNAMEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
892                        struct netr_DSRGETDCNAMEX *r)
893 {
894         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
895 }
896
897
898 /* 
899   netr_DSRGETSITENAME 
900 */
901 static WERROR netr_DSRGETSITENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
902                        struct netr_DSRGETSITENAME *r)
903 {
904         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
905 }
906
907
908 /*
909   fill in a netr_DomainTrustInfo from a ldb search result
910 */
911 static NTSTATUS fill_domain_trust_info(TALLOC_CTX *mem_ctx, struct ldb_message *res,
912                                        struct netr_DomainTrustInfo *info)
913 {
914         ZERO_STRUCTP(info);
915         
916         info->domainname.string = samdb_result_string(res, "flatName", NULL);
917         if (info->domainname.string == NULL) {
918                 info->domainname.string = samdb_result_string(res, "name", NULL);
919                 info->fulldomainname.string = samdb_result_string(res, "dnsDomain", NULL);
920         } else {
921                 info->fulldomainname.string = samdb_result_string(res, "name", NULL);
922         }
923
924         /* TODO: we need proper forest support */
925         info->forest.string = info->fulldomainname.string;
926
927         info->guid = samdb_result_guid(res, "objectGUID");
928         info->sid = samdb_result_dom_sid(mem_ctx, res, "objectSid");
929
930         return NT_STATUS_OK;
931 }
932
933 /* 
934   netr_LogonGetDomainInfo
935   this is called as part of the ADS domain logon procedure.
936 */
937 static NTSTATUS netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
938                                         struct netr_LogonGetDomainInfo *r)
939 {
940         struct server_pipe_state *pipe_state = dce_call->conn->private;
941         const char * const attrs[] = { "name", "dnsDomain", "objectSid", 
942                                        "objectGUID", "flatName", NULL };
943         void *sam_ctx;
944         struct ldb_message **res1, **res2;
945         struct netr_DomainInfo1 *info1;
946         int ret1, ret2, i;
947         NTSTATUS status;
948
949         if (!pipe_state) {
950                 return NT_STATUS_ACCESS_DENIED;
951         }
952
953         if (!netr_creds_server_step_check(pipe_state, 
954                                           r->in.credential, r->out.credential)) {
955                 return NT_STATUS_ACCESS_DENIED;
956         }
957
958         sam_ctx = samdb_connect(mem_ctx);
959         if (sam_ctx == NULL) {
960                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
961         }
962
963         /* we need to do two searches. The first will pull our primary
964            domain and the second will pull any trusted domains. Our
965            primary domain is also a "trusted" domain, so we need to
966            put the primary domain into the lists of returned trusts as
967            well */
968         ret1 = samdb_search(sam_ctx, mem_ctx, NULL, &res1, attrs, "(objectClass=domainDNS)");
969         if (ret1 != 1) {
970                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
971         }
972
973         ret2 = samdb_search(sam_ctx, mem_ctx, NULL, &res2, attrs, "(objectClass=trustedDomain)");
974         if (ret2 == -1) {
975                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
976         }
977
978         info1 = talloc_p(mem_ctx, struct netr_DomainInfo1);
979         if (info1 == NULL) {
980                 return NT_STATUS_NO_MEMORY;
981         }
982
983         ZERO_STRUCTP(info1);
984
985         info1->num_trusts = ret2 + 1;
986         info1->trusts = talloc_array_p(mem_ctx, struct netr_DomainTrustInfo, 
987                                        info1->num_trusts);
988         if (info1->trusts == NULL) {
989                 return NT_STATUS_NO_MEMORY;
990         }
991
992         status = fill_domain_trust_info(mem_ctx, res1[0], &info1->domaininfo);
993         if (!NT_STATUS_IS_OK(status)) {
994                 return status;
995         }
996
997         status = fill_domain_trust_info(mem_ctx, res1[0], &info1->trusts[0]);
998         if (!NT_STATUS_IS_OK(status)) {
999                 return status;
1000         }
1001
1002         for (i=0;i<ret2;i++) {
1003                 status = fill_domain_trust_info(mem_ctx, res2[i], &info1->trusts[i+1]);
1004                 if (!NT_STATUS_IS_OK(status)) {
1005                         return status;
1006                 }
1007         }
1008
1009         r->out.info.info1 = info1;
1010
1011         return NT_STATUS_OK;
1012 }
1013
1014
1015 /* 
1016   netr_NETRSERVERPASSWORDSET2 
1017 */
1018 static WERROR netr_NETRSERVERPASSWORDSET2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1019                        struct netr_NETRSERVERPASSWORDSET2 *r)
1020 {
1021         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1022 }
1023
1024
1025 /* 
1026   netr_NETRSERVERPASSWORDGET 
1027 */
1028 static WERROR netr_NETRSERVERPASSWORDGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1029                        struct netr_NETRSERVERPASSWORDGET *r)
1030 {
1031         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1032 }
1033
1034
1035 /* 
1036   netr_NETRLOGONSENDTOSAM 
1037 */
1038 static WERROR netr_NETRLOGONSENDTOSAM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1039                        struct netr_NETRLOGONSENDTOSAM *r)
1040 {
1041         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1042 }
1043
1044
1045 /* 
1046   netr_DSRADDRESSTOSITENAMESW 
1047 */
1048 static WERROR netr_DSRADDRESSTOSITENAMESW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1049                        struct netr_DSRADDRESSTOSITENAMESW *r)
1050 {
1051         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1052 }
1053
1054
1055 /* 
1056   netr_DSRGETDCNAMEEX2 
1057 */
1058 static WERROR netr_DSRGETDCNAMEEX2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1059                        struct netr_DSRGETDCNAMEEX2 *r)
1060 {
1061         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1062 }
1063
1064
1065 /* 
1066   netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN 
1067 */
1068 static WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1069                        struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1070 {
1071         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1072 }
1073
1074
1075 /* 
1076   netr_NETRENUMERATETRUSTEDDOMAINSEX 
1077 */
1078 static WERROR netr_NETRENUMERATETRUSTEDDOMAINSEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1079                        struct netr_NETRENUMERATETRUSTEDDOMAINSEX *r)
1080 {
1081         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1082 }
1083
1084
1085 /* 
1086   netr_DSRADDRESSTOSITENAMESEXW 
1087 */
1088 static WERROR netr_DSRADDRESSTOSITENAMESEXW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1089                        struct netr_DSRADDRESSTOSITENAMESEXW *r)
1090 {
1091         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1092 }
1093
1094
1095 /* 
1096   netr_DSRGETDCSITECOVERAGEW 
1097 */
1098 static WERROR netr_DSRGETDCSITECOVERAGEW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1099                        struct netr_DSRGETDCSITECOVERAGEW *r)
1100 {
1101         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1102 }
1103
1104
1105 /* 
1106   netr_NETRLOGONSAMLOGONEX 
1107 */
1108 static WERROR netr_NETRLOGONSAMLOGONEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1109                        struct netr_NETRLOGONSAMLOGONEX *r)
1110 {
1111         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1112 }
1113
1114
1115 /* 
1116   netr_DsrEnumerateDomainTrusts 
1117 */
1118 static WERROR netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1119                                               struct netr_DsrEnumerateDomainTrusts *r)
1120 {
1121         struct netr_DomainTrust *trusts;
1122         void *sam_ctx;
1123         int ret, i;
1124         struct ldb_message **res;
1125         const char * const attrs[] = { "name", "dnsDomain", "objectSid", "objectGUID", NULL };
1126
1127         ZERO_STRUCT(r->out);
1128
1129         sam_ctx = samdb_connect(mem_ctx);
1130         if (sam_ctx == NULL) {
1131                 return WERR_GENERAL_FAILURE;
1132         }
1133
1134         ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs, "(objectClass=domainDNS)");
1135         if (ret == -1) {
1136                 return WERR_GENERAL_FAILURE;            
1137         }
1138
1139         if (ret == 0) {
1140                 return WERR_OK;
1141         }
1142
1143         trusts = talloc_array_p(mem_ctx, struct netr_DomainTrust, ret);
1144         if (trusts == NULL) {
1145                 return WERR_NOMEM;
1146         }
1147         
1148         r->out.count = ret;
1149         r->out.trusts = trusts;
1150
1151         /* TODO: add filtering by trust_flags, and correct trust_type
1152            and attributes */
1153         for (i=0;i<ret;i++) {
1154                 trusts[i].netbios_name = samdb_result_string(res[i], "name", NULL);
1155                 trusts[i].dns_name     = samdb_result_string(res[i], "dnsDomain", NULL);
1156                 trusts[i].trust_flags = 
1157                         NETR_TRUST_FLAG_TREEROOT | 
1158                         NETR_TRUST_FLAG_IN_FOREST | 
1159                         NETR_TRUST_FLAG_PRIMARY;
1160                 trusts[i].parent_index = 0;
1161                 trusts[i].trust_type = 2;
1162                 trusts[i].trust_attributes = 0;
1163                 trusts[i].sid  = samdb_result_dom_sid(mem_ctx, res[i], "objectSid");
1164                 trusts[i].guid = samdb_result_guid(res[i], "objectGUID");
1165         }
1166         
1167
1168         return WERR_OK;
1169 }
1170
1171
1172 /* 
1173   netr_DSRDEREGISTERDNSHOSTRECORDS 
1174 */
1175 static WERROR netr_DSRDEREGISTERDNSHOSTRECORDS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1176                        struct netr_DSRDEREGISTERDNSHOSTRECORDS *r)
1177 {
1178         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1179 }
1180
1181
1182 /* 
1183   netr_NETRSERVERTRUSTPASSWORDSGET 
1184 */
1185 static WERROR netr_NETRSERVERTRUSTPASSWORDSGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1186                        struct netr_NETRSERVERTRUSTPASSWORDSGET *r)
1187 {
1188         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1189 }
1190
1191
1192 /* 
1193   netr_DSRGETFORESTTRUSTINFORMATION 
1194 */
1195 static WERROR netr_DSRGETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1196                        struct netr_DSRGETFORESTTRUSTINFORMATION *r)
1197 {
1198         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1199 }
1200
1201
1202 /* 
1203   netr_NETRGETFORESTTRUSTINFORMATION 
1204 */
1205 static WERROR netr_NETRGETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1206                        struct netr_NETRGETFORESTTRUSTINFORMATION *r)
1207 {
1208         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1209 }
1210
1211
1212 /* 
1213   netr_NETRSERVERGETTRUSTINFO 
1214 */
1215 static WERROR netr_NETRSERVERGETTRUSTINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1216                        struct netr_NETRSERVERGETTRUSTINFO *r)
1217 {
1218         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1219 }
1220
1221
1222 /* include the generated boilerplate */
1223 #include "librpc/gen_ndr/ndr_netlogon_s.c"