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