Attempt to fix bug #6099. According to Microsoft
[samba.git] / source3 / rpc_server / srv_netlog_nt.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Jeremy Allison               1998-2001.
8  *  Copyright (C) Andrew Bartlett                   2001.
9  *  Copyright (C) Guenther Deschner                 2008.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 3 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24
25 /* This is the implementation of the netlogon pipe. */
26
27 #include "includes.h"
28
29 extern userdom_struct current_user_info;
30
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_SRV
33
34 /*************************************************************************
35  init_net_r_req_chal:
36  *************************************************************************/
37
38 static void init_net_r_req_chal(struct netr_Credential *r,
39                                 struct netr_Credential *srv_chal)
40 {
41         DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__));
42
43         memcpy(r->data, srv_chal->data, sizeof(r->data));
44 }
45
46 /*******************************************************************
47  Inits a netr_NETLOGON_INFO_1 structure.
48 ********************************************************************/
49
50 static void init_netlogon_info1(struct netr_NETLOGON_INFO_1 *r,
51                                 uint32_t flags,
52                                 uint32_t pdc_connection_status)
53 {
54         r->flags = flags;
55         r->pdc_connection_status = pdc_connection_status;
56 }
57
58 /*******************************************************************
59  Inits a netr_NETLOGON_INFO_2 structure.
60 ********************************************************************/
61
62 static void init_netlogon_info2(struct netr_NETLOGON_INFO_2 *r,
63                                 uint32_t flags,
64                                 uint32_t pdc_connection_status,
65                                 const char *trusted_dc_name,
66                                 uint32_t tc_connection_status)
67 {
68         r->flags = flags;
69         r->pdc_connection_status = pdc_connection_status;
70         r->trusted_dc_name = trusted_dc_name;
71         r->tc_connection_status = tc_connection_status;
72 }
73
74 /*******************************************************************
75  Inits a netr_NETLOGON_INFO_3 structure.
76 ********************************************************************/
77
78 static void init_netlogon_info3(struct netr_NETLOGON_INFO_3 *r,
79                                 uint32_t flags,
80                                 uint32_t logon_attempts)
81 {
82         r->flags = flags;
83         r->logon_attempts = logon_attempts;
84 }
85
86 /*************************************************************************
87  _netr_LogonControl
88  *************************************************************************/
89
90 WERROR _netr_LogonControl(pipes_struct *p,
91                           struct netr_LogonControl *r)
92 {
93         struct netr_LogonControl2Ex l;
94
95         switch (r->in.level) {
96         case 1:
97                 break;
98         case 2:
99                 return WERR_NOT_SUPPORTED;
100         default:
101                 return WERR_UNKNOWN_LEVEL;
102         }
103
104         l.in.logon_server       = r->in.logon_server;
105         l.in.function_code      = r->in.function_code;
106         l.in.level              = r->in.level;
107         l.in.data               = NULL;
108         l.out.query             = r->out.info;
109
110         return _netr_LogonControl2Ex(p, &l);
111 }
112
113 /****************************************************************************
114 Send a message to smbd to do a sam synchronisation
115 **************************************************************************/
116
117 static void send_sync_message(void)
118 {
119         DEBUG(3, ("sending sam synchronisation message\n"));
120         message_send_all(smbd_messaging_context(), MSG_SMB_SAM_SYNC, NULL, 0,
121                          NULL);
122 }
123
124 /*************************************************************************
125  _netr_LogonControl2
126  *************************************************************************/
127
128 WERROR _netr_LogonControl2(pipes_struct *p,
129                            struct netr_LogonControl2 *r)
130 {
131         struct netr_LogonControl2Ex l;
132
133         l.in.logon_server       = r->in.logon_server;
134         l.in.function_code      = r->in.function_code;
135         l.in.level              = r->in.level;
136         l.in.data               = r->in.data;
137         l.out.query             = r->out.query;
138
139         return _netr_LogonControl2Ex(p, &l);
140 }
141
142 /****************************************************************
143  _netr_LogonControl2Ex
144 ****************************************************************/
145
146 WERROR _netr_LogonControl2Ex(pipes_struct *p,
147                              struct netr_LogonControl2Ex *r)
148 {
149         uint32 flags = 0x0;
150         uint32 pdc_connection_status = 0x0;
151         uint32 logon_attempts = 0x0;
152         uint32 tc_status;
153         fstring dc_name2;
154         const char *dc_name = NULL;
155         struct sockaddr_storage dc_ss;
156         const char *domain = NULL;
157         struct netr_NETLOGON_INFO_1 *info1;
158         struct netr_NETLOGON_INFO_2 *info2;
159         struct netr_NETLOGON_INFO_3 *info3;
160         const char *fn;
161
162         switch (p->hdr_req.opnum) {
163                 case NDR_NETR_LOGONCONTROL:
164                         fn = "_netr_LogonControl";
165                         break;
166                 case NDR_NETR_LOGONCONTROL2:
167                         fn = "_netr_LogonControl2";
168                         break;
169                 case NDR_NETR_LOGONCONTROL2EX:
170                         fn = "_netr_LogonControl2Ex";
171                         break;
172                 default:
173                         return WERR_INVALID_PARAM;
174         }
175
176         tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN);
177
178         switch (r->in.function_code) {
179                 case NETLOGON_CONTROL_TC_QUERY:
180                         domain = r->in.data->domain;
181
182                         if ( !is_trusted_domain( domain ) )
183                                 break;
184
185                         if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) {
186                                 tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS);
187                                 break;
188                         }
189
190                         dc_name = talloc_asprintf(p->mem_ctx, "\\\\%s", dc_name2);
191                         if (!dc_name) {
192                                 return WERR_NOMEM;
193                         }
194
195                         tc_status = W_ERROR_V(WERR_OK);
196
197                         break;
198
199                 case NETLOGON_CONTROL_REDISCOVER:
200                         domain = r->in.data->domain;
201
202                         if ( !is_trusted_domain( domain ) )
203                                 break;
204
205                         if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) {
206                                 tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS);
207                                 break;
208                         }
209
210                         dc_name = talloc_asprintf(p->mem_ctx, "\\\\%s", dc_name2);
211                         if (!dc_name) {
212                                 return WERR_NOMEM;
213                         }
214
215                         tc_status = W_ERROR_V(WERR_OK);
216
217                         break;
218
219                 default:
220                         /* no idea what this should be */
221                         DEBUG(0,("%s: unimplemented function level [%d]\n",
222                                 fn, r->in.function_code));
223                         return WERR_UNKNOWN_LEVEL;
224         }
225
226         /* prepare the response */
227
228         switch (r->in.level) {
229                 case 1:
230                         info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1);
231                         W_ERROR_HAVE_NO_MEMORY(info1);
232
233                         init_netlogon_info1(info1,
234                                             flags,
235                                             pdc_connection_status);
236                         r->out.query->info1 = info1;
237                         break;
238                 case 2:
239                         info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2);
240                         W_ERROR_HAVE_NO_MEMORY(info2);
241
242                         init_netlogon_info2(info2,
243                                             flags,
244                                             pdc_connection_status,
245                                             dc_name,
246                                             tc_status);
247                         r->out.query->info2 = info2;
248                         break;
249                 case 3:
250                         info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3);
251                         W_ERROR_HAVE_NO_MEMORY(info3);
252
253                         init_netlogon_info3(info3,
254                                             flags,
255                                             logon_attempts);
256                         r->out.query->info3 = info3;
257                         break;
258                 default:
259                         return WERR_UNKNOWN_LEVEL;
260         }
261
262         if (lp_server_role() == ROLE_DOMAIN_BDC) {
263                 send_sync_message();
264         }
265
266         return WERR_OK;
267 }
268
269 /*************************************************************************
270  _netr_NetrEnumerateTrustedDomains
271  *************************************************************************/
272
273 WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p,
274                                          struct netr_NetrEnumerateTrustedDomains *r)
275 {
276         struct netr_Blob trusted_domains_blob;
277         DATA_BLOB blob;
278
279         DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
280
281         /* set up the Trusted Domain List response */
282
283         blob = data_blob_talloc_zero(p->mem_ctx, 2);
284         trusted_domains_blob.data = blob.data;
285         trusted_domains_blob.length = blob.length;
286
287         DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
288
289         *r->out.trusted_domains_blob = trusted_domains_blob;
290
291         return WERR_OK;
292 }
293
294 /******************************************************************
295  gets a machine password entry.  checks access rights of the host.
296  ******************************************************************/
297
298 static NTSTATUS get_md4pw(char *md4pw, const char *mach_acct,
299                           uint16_t sec_chan_type, uint32_t *rid)
300 {
301         struct samu *sampass = NULL;
302         const uint8 *pass;
303         bool ret;
304         uint32 acct_ctrl;
305
306 #if 0
307         char addr[INET6_ADDRSTRLEN];
308
309     /*
310      * Currently this code is redundent as we already have a filter
311      * by hostname list. What this code really needs to do is to
312      * get a hosts allowed/hosts denied list from the SAM database
313      * on a per user basis, and make the access decision there.
314      * I will leave this code here for now as a reminder to implement
315      * this at a later date. JRA.
316      */
317
318         if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(),
319                         client_name(get_client_fd()),
320                         client_addr(get_client_fd(),addr,sizeof(addr)))) {
321                 DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct));
322                 return False;
323         }
324 #endif /* 0 */
325
326         if ( !(sampass = samu_new( NULL )) ) {
327                 return NT_STATUS_NO_MEMORY;
328         }
329
330         /* JRA. This is ok as it is only used for generating the challenge. */
331         become_root();
332         ret = pdb_getsampwnam(sampass, mach_acct);
333         unbecome_root();
334
335         if (!ret) {
336                 DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct));
337                 TALLOC_FREE(sampass);
338                 return NT_STATUS_ACCESS_DENIED;
339         }
340
341         acct_ctrl = pdb_get_acct_ctrl(sampass);
342         if (acct_ctrl & ACB_DISABLED) {
343                 DEBUG(0,("get_md4pw: Workstation %s: account is disabled\n", mach_acct));
344                 TALLOC_FREE(sampass);
345                 return NT_STATUS_ACCOUNT_DISABLED;
346         }
347
348         if (!(acct_ctrl & ACB_SVRTRUST) &&
349             !(acct_ctrl & ACB_WSTRUST) &&
350             !(acct_ctrl & ACB_DOMTRUST))
351         {
352                 DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct));
353                 TALLOC_FREE(sampass);
354                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
355         }
356
357         switch (sec_chan_type) {
358                 case SEC_CHAN_BDC:
359                         if (!(acct_ctrl & ACB_SVRTRUST)) {
360                                 DEBUG(0,("get_md4pw: Workstation %s: BDC secure channel requested "
361                                          "but not a server trust account\n", mach_acct));
362                                 TALLOC_FREE(sampass);
363                                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
364                         }
365                         break;
366                 case SEC_CHAN_WKSTA:
367                         if (!(acct_ctrl & ACB_WSTRUST)) {
368                                 DEBUG(0,("get_md4pw: Workstation %s: WORKSTATION secure channel requested "
369                                          "but not a workstation trust account\n", mach_acct));
370                                 TALLOC_FREE(sampass);
371                                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
372                         }
373                         break;
374                 case SEC_CHAN_DOMAIN:
375                         if (!(acct_ctrl & ACB_DOMTRUST)) {
376                                 DEBUG(0,("get_md4pw: Workstation %s: DOMAIN secure channel requested "
377                                          "but not a interdomain trust account\n", mach_acct));
378                                 TALLOC_FREE(sampass);
379                                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
380                         }
381                         break;
382                 default:
383                         break;
384         }
385
386         if ((pass = pdb_get_nt_passwd(sampass)) == NULL) {
387                 DEBUG(0,("get_md4pw: Workstation %s: account does not have a password\n", mach_acct));
388                 TALLOC_FREE(sampass);
389                 return NT_STATUS_LOGON_FAILURE;
390         }
391
392         memcpy(md4pw, pass, 16);
393         dump_data(5, (uint8 *)md4pw, 16);
394
395         if (rid) {
396                 *rid = pdb_get_user_rid(sampass);
397         }
398
399         TALLOC_FREE(sampass);
400
401         return NT_STATUS_OK;
402
403
404 }
405
406 /*************************************************************************
407  _netr_ServerReqChallenge
408  *************************************************************************/
409
410 NTSTATUS _netr_ServerReqChallenge(pipes_struct *p,
411                                   struct netr_ServerReqChallenge *r)
412 {
413         if (!p->dc) {
414                 p->dc = TALLOC_ZERO_P(p, struct dcinfo);
415                 if (!p->dc) {
416                         return NT_STATUS_NO_MEMORY;
417                 }
418         } else {
419                 DEBUG(10,("_netr_ServerReqChallenge: new challenge requested. Clearing old state.\n"));
420                 ZERO_STRUCTP(p->dc);
421         }
422
423         fstrcpy(p->dc->remote_machine, r->in.computer_name);
424
425         /* Save the client challenge to the server. */
426         memcpy(p->dc->clnt_chal.data, r->in.credentials->data,
427                 sizeof(r->in.credentials->data));
428
429         /* Create a server challenge for the client */
430         /* Set this to a random value. */
431         generate_random_buffer(p->dc->srv_chal.data, 8);
432
433         /* set up the LSA REQUEST CHALLENGE response */
434         init_net_r_req_chal(r->out.return_credentials, &p->dc->srv_chal);
435
436         p->dc->challenge_sent = True;
437
438         return NT_STATUS_OK;
439 }
440
441 /*************************************************************************
442  _netr_ServerAuthenticate
443  Create the initial credentials.
444  *************************************************************************/
445
446 NTSTATUS _netr_ServerAuthenticate(pipes_struct *p,
447                                   struct netr_ServerAuthenticate *r)
448 {
449         NTSTATUS status;
450         struct netr_Credential srv_chal_out;
451
452         if (!p->dc || !p->dc->challenge_sent) {
453                 return NT_STATUS_ACCESS_DENIED;
454         }
455
456         status = get_md4pw((char *)p->dc->mach_pw,
457                            r->in.account_name,
458                            r->in.secure_channel_type,
459                            NULL);
460         if (!NT_STATUS_IS_OK(status)) {
461                 DEBUG(0,("_netr_ServerAuthenticate: get_md4pw failed. Failed to "
462                         "get password for machine account %s "
463                         "from client %s: %s\n",
464                         r->in.account_name,
465                         r->in.computer_name,
466                         nt_errstr(status) ));
467                 /* always return NT_STATUS_ACCESS_DENIED */
468                 return NT_STATUS_ACCESS_DENIED;
469         }
470
471         /* From the client / server challenges and md4 password, generate sess key */
472         creds_server_init(0,                    /* No neg flags. */
473                         p->dc,
474                         &p->dc->clnt_chal,      /* Stored client chal. */
475                         &p->dc->srv_chal,       /* Stored server chal. */
476                         p->dc->mach_pw,
477                         &srv_chal_out);
478
479         /* Check client credentials are valid. */
480         if (!netlogon_creds_server_check(p->dc, r->in.credentials)) {
481                 DEBUG(0,("_netr_ServerAuthenticate: netlogon_creds_server_check failed. Rejecting auth "
482                         "request from client %s machine account %s\n",
483                         r->in.computer_name,
484                         r->in.account_name));
485                 return NT_STATUS_ACCESS_DENIED;
486         }
487
488         fstrcpy(p->dc->mach_acct, r->in.account_name);
489         fstrcpy(p->dc->remote_machine, r->in.computer_name);
490         p->dc->authenticated = True;
491
492         /* set up the LSA AUTH response */
493         /* Return the server credentials. */
494
495         memcpy(r->out.return_credentials->data, &srv_chal_out.data,
496                sizeof(r->out.return_credentials->data));
497
498         return NT_STATUS_OK;
499 }
500
501 /*************************************************************************
502  _netr_ServerAuthenticate3
503  *************************************************************************/
504
505 NTSTATUS _netr_ServerAuthenticate3(pipes_struct *p,
506                                    struct netr_ServerAuthenticate3 *r)
507 {
508         NTSTATUS status;
509         uint32_t srv_flgs;
510         struct netr_Credential srv_chal_out;
511         const char *fn;
512
513         /* According to Microsoft (see bugid #6099)
514          * Windows 7 looks at the negotiate_flags
515          * returned in this structure *even if the
516          * call fails with access denied ! So in order
517          * to allow Win7 to connect to a Samba NT style
518          * PDC we set the flags before we know if it's
519          * an error or not.
520          */
521
522         /* 0x000001ff */
523         srv_flgs = NETLOGON_NEG_ACCOUNT_LOCKOUT |
524                    NETLOGON_NEG_PERSISTENT_SAMREPL |
525                    NETLOGON_NEG_ARCFOUR |
526                    NETLOGON_NEG_PROMOTION_COUNT |
527                    NETLOGON_NEG_CHANGELOG_BDC |
528                    NETLOGON_NEG_FULL_SYNC_REPL |
529                    NETLOGON_NEG_MULTIPLE_SIDS |
530                    NETLOGON_NEG_REDO |
531                    NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL;
532
533         if (lp_server_schannel() != false) {
534                 srv_flgs |= NETLOGON_NEG_SCHANNEL;
535         }
536
537         *r->out.negotiate_flags = srv_flgs;
538
539         switch (p->hdr_req.opnum) {
540                 case NDR_NETR_SERVERAUTHENTICATE2:
541                         fn = "_netr_ServerAuthenticate2";
542                         break;
543                 case NDR_NETR_SERVERAUTHENTICATE3:
544                         fn = "_netr_ServerAuthenticate3";
545                         break;
546                 default:
547                         return NT_STATUS_INTERNAL_ERROR;
548         }
549
550         /* We use this as the key to store the creds: */
551         /* r->in.computer_name */
552
553         if (!p->dc || !p->dc->challenge_sent) {
554                 DEBUG(0,("%s: no challenge sent to client %s\n", fn,
555                         r->in.computer_name));
556                 return NT_STATUS_ACCESS_DENIED;
557         }
558
559         if ( (lp_server_schannel() == true) &&
560              ((*r->in.negotiate_flags & NETLOGON_NEG_SCHANNEL) == 0) ) {
561
562                 /* schannel must be used, but client did not offer it. */
563                 DEBUG(0,("%s: schannel required but client failed "
564                         "to offer it. Client was %s\n",
565                         fn, r->in.account_name));
566                 return NT_STATUS_ACCESS_DENIED;
567         }
568
569         status = get_md4pw((char *)p->dc->mach_pw,
570                            r->in.account_name,
571                            r->in.secure_channel_type,
572                            r->out.rid);
573         if (!NT_STATUS_IS_OK(status)) {
574                 DEBUG(0,("%s: failed to get machine password for "
575                         "account %s: %s\n",
576                         fn, r->in.account_name, nt_errstr(status) ));
577                 /* always return NT_STATUS_ACCESS_DENIED */
578                 return NT_STATUS_ACCESS_DENIED;
579         }
580
581         /* From the client / server challenges and md4 password, generate sess key */
582         creds_server_init(*r->in.negotiate_flags,
583                         p->dc,
584                         &p->dc->clnt_chal,      /* Stored client chal. */
585                         &p->dc->srv_chal,       /* Stored server chal. */
586                         p->dc->mach_pw,
587                         &srv_chal_out);
588
589         /* Check client credentials are valid. */
590         if (!netlogon_creds_server_check(p->dc, r->in.credentials)) {
591                 DEBUG(0,("%s: netlogon_creds_server_check failed. Rejecting auth "
592                         "request from client %s machine account %s\n",
593                         fn, r->in.computer_name,
594                         r->in.account_name));
595                 return NT_STATUS_ACCESS_DENIED;
596         }
597         /* set up the LSA AUTH 2 response */
598         memcpy(r->out.return_credentials->data, &srv_chal_out.data,
599                sizeof(r->out.return_credentials->data));
600
601         fstrcpy(p->dc->mach_acct, r->in.account_name);
602         fstrcpy(p->dc->remote_machine, r->in.computer_name);
603         fstrcpy(p->dc->domain, lp_workgroup() );
604
605         p->dc->authenticated = True;
606
607         /* Store off the state so we can continue after client disconnect. */
608         become_root();
609         secrets_store_schannel_session_info(p->mem_ctx,
610                                             r->in.computer_name,
611                                             p->dc);
612         unbecome_root();
613
614         return NT_STATUS_OK;
615 }
616
617 /*************************************************************************
618  _netr_ServerAuthenticate2
619  *************************************************************************/
620
621 NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p,
622                                    struct netr_ServerAuthenticate2 *r)
623 {
624         struct netr_ServerAuthenticate3 a;
625         uint32_t rid;
626
627         a.in.server_name                = r->in.server_name;
628         a.in.account_name               = r->in.account_name;
629         a.in.secure_channel_type        = r->in.secure_channel_type;
630         a.in.computer_name              = r->in.computer_name;
631         a.in.credentials                = r->in.credentials;
632         a.in.negotiate_flags            = r->in.negotiate_flags;
633
634         a.out.return_credentials        = r->out.return_credentials;
635         a.out.rid                       = &rid;
636         a.out.negotiate_flags           = r->out.negotiate_flags;
637
638         return _netr_ServerAuthenticate3(p, &a);
639 }
640
641 /*************************************************************************
642  _netr_ServerPasswordSet
643  *************************************************************************/
644
645 NTSTATUS _netr_ServerPasswordSet(pipes_struct *p,
646                                  struct netr_ServerPasswordSet *r)
647 {
648         NTSTATUS status = NT_STATUS_OK;
649         fstring remote_machine;
650         struct samu *sampass=NULL;
651         bool ret = False;
652         unsigned char pwd[16];
653         int i;
654         uint32 acct_ctrl;
655         struct netr_Authenticator cred_out;
656         const uchar *old_pw;
657
658         DEBUG(5,("_netr_ServerPasswordSet: %d\n", __LINE__));
659
660         /* We need the remote machine name for the creds lookup. */
661         fstrcpy(remote_machine, r->in.computer_name);
662
663         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
664                 /* 'server schannel = yes' should enforce use of
665                    schannel, the client did offer it in auth2, but
666                    obviously did not use it. */
667                 DEBUG(0,("_netr_ServerPasswordSet: client %s not using schannel for netlogon\n",
668                         remote_machine ));
669                 return NT_STATUS_ACCESS_DENIED;
670         }
671
672         if (!p->dc) {
673                 /* Restore the saved state of the netlogon creds. */
674                 become_root();
675                 ret = secrets_restore_schannel_session_info(p, remote_machine,
676                                                             &p->dc);
677                 unbecome_root();
678                 if (!ret) {
679                         return NT_STATUS_INVALID_HANDLE;
680                 }
681         }
682
683         if (!p->dc || !p->dc->authenticated) {
684                 return NT_STATUS_INVALID_HANDLE;
685         }
686
687         DEBUG(3,("_netr_ServerPasswordSet: Server Password Set by remote machine:[%s] on account [%s]\n",
688                         remote_machine, p->dc->mach_acct));
689
690         /* Step the creds chain forward. */
691         if (!netlogon_creds_server_step(p->dc, r->in.credential, &cred_out)) {
692                 DEBUG(2,("_netr_ServerPasswordSet: netlogon_creds_server_step failed. Rejecting auth "
693                         "request from client %s machine account %s\n",
694                         remote_machine, p->dc->mach_acct ));
695                 return NT_STATUS_INVALID_PARAMETER;
696         }
697
698         /* We must store the creds state after an update. */
699         sampass = samu_new( NULL );
700         if (!sampass) {
701                 return NT_STATUS_NO_MEMORY;
702         }
703
704         become_root();
705         secrets_store_schannel_session_info(p, remote_machine, p->dc);
706         ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
707         unbecome_root();
708
709         if (!ret) {
710                 TALLOC_FREE(sampass);
711                 return NT_STATUS_ACCESS_DENIED;
712         }
713
714         /* Ensure the account exists and is a machine account. */
715
716         acct_ctrl = pdb_get_acct_ctrl(sampass);
717
718         if (!(acct_ctrl & ACB_WSTRUST ||
719                       acct_ctrl & ACB_SVRTRUST ||
720                       acct_ctrl & ACB_DOMTRUST)) {
721                 TALLOC_FREE(sampass);
722                 return NT_STATUS_NO_SUCH_USER;
723         }
724
725         if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
726                 TALLOC_FREE(sampass);
727                 return NT_STATUS_ACCOUNT_DISABLED;
728         }
729
730         /* Woah - what does this to to the credential chain ? JRA */
731         cred_hash3(pwd, r->in.new_password->hash, p->dc->sess_key, 0);
732
733         DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n"));
734         for(i = 0; i < sizeof(pwd); i++)
735                 DEBUG(100,("%02X ", pwd[i]));
736         DEBUG(100,("\n"));
737
738         old_pw = pdb_get_nt_passwd(sampass);
739
740         if (old_pw && memcmp(pwd, old_pw, 16) == 0) {
741                 /* Avoid backend modificiations and other fun if the
742                    client changed the password to the *same thing* */
743
744                 ret = True;
745         } else {
746
747                 /* LM password should be NULL for machines */
748                 if (!pdb_set_lanman_passwd(sampass, NULL, PDB_CHANGED)) {
749                         TALLOC_FREE(sampass);
750                         return NT_STATUS_NO_MEMORY;
751                 }
752
753                 if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) {
754                         TALLOC_FREE(sampass);
755                         return NT_STATUS_NO_MEMORY;
756                 }
757
758                 if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) {
759                         TALLOC_FREE(sampass);
760                         /* Not quite sure what this one qualifies as, but this will do */
761                         return NT_STATUS_UNSUCCESSFUL;
762                 }
763
764                 become_root();
765                 status = pdb_update_sam_account(sampass);
766                 unbecome_root();
767         }
768
769         /* set up the LSA Server Password Set response */
770
771         memcpy(r->out.return_authenticator, &cred_out,
772                sizeof(r->out.return_authenticator));
773
774         TALLOC_FREE(sampass);
775         return status;
776 }
777
778 /*************************************************************************
779  _netr_LogonSamLogoff
780  *************************************************************************/
781
782 NTSTATUS _netr_LogonSamLogoff(pipes_struct *p,
783                               struct netr_LogonSamLogoff *r)
784 {
785         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
786                 /* 'server schannel = yes' should enforce use of
787                    schannel, the client did offer it in auth2, but
788                    obviously did not use it. */
789                 DEBUG(0,("_netr_LogonSamLogoff: client %s not using schannel for netlogon\n",
790                         get_remote_machine_name() ));
791                 return NT_STATUS_ACCESS_DENIED;
792         }
793
794
795         /* Using the remote machine name for the creds store: */
796         /* r->in.computer_name */
797
798         if (!p->dc) {
799                 /* Restore the saved state of the netlogon creds. */
800                 bool ret;
801
802                 become_root();
803                 ret = secrets_restore_schannel_session_info(
804                         p, r->in.computer_name, &p->dc);
805                 unbecome_root();
806                 if (!ret) {
807                         return NT_STATUS_INVALID_HANDLE;
808                 }
809         }
810
811         if (!p->dc || !p->dc->authenticated) {
812                 return NT_STATUS_INVALID_HANDLE;
813         }
814
815         /* checks and updates credentials.  creates reply credentials */
816         if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) {
817                 DEBUG(2,("_netr_LogonSamLogoff: netlogon_creds_server_step failed. Rejecting auth "
818                         "request from client %s machine account %s\n",
819                         r->in.computer_name, p->dc->mach_acct ));
820                 return NT_STATUS_INVALID_PARAMETER;
821         }
822
823         /* We must store the creds state after an update. */
824         become_root();
825         secrets_store_schannel_session_info(p, r->in.computer_name, p->dc);
826         unbecome_root();
827
828         return NT_STATUS_OK;
829 }
830
831 /*************************************************************************
832  _netr_LogonSamLogon
833  *************************************************************************/
834
835 NTSTATUS _netr_LogonSamLogon(pipes_struct *p,
836                              struct netr_LogonSamLogon *r)
837 {
838         NTSTATUS status = NT_STATUS_OK;
839         struct netr_SamInfo3 *sam3 = NULL;
840         union netr_LogonLevel *logon = r->in.logon;
841         fstring nt_username, nt_domain, nt_workstation;
842         auth_usersupplied_info *user_info = NULL;
843         auth_serversupplied_info *server_info = NULL;
844         struct auth_context *auth_context = NULL;
845         uint8_t pipe_session_key[16];
846         bool process_creds = true;
847         const char *fn;
848
849         switch (p->hdr_req.opnum) {
850                 case NDR_NETR_LOGONSAMLOGON:
851                         process_creds = true;
852                         fn = "_netr_LogonSamLogon";
853                         break;
854                 case NDR_NETR_LOGONSAMLOGONEX:
855                         fn = "_netr_LogonSamLogonEx";
856                 default:
857                         fn = "";
858                         process_creds = false;
859         }
860
861         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
862                 /* 'server schannel = yes' should enforce use of
863                    schannel, the client did offer it in auth2, but
864                    obviously did not use it. */
865                 DEBUG(0,("%s: client %s not using schannel for netlogon\n",
866                         fn, get_remote_machine_name() ));
867                 return NT_STATUS_ACCESS_DENIED;
868         }
869
870         sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3);
871         if (!sam3) {
872                 return NT_STATUS_NO_MEMORY;
873         }
874
875         /* store the user information, if there is any. */
876         r->out.validation->sam3 = sam3;
877         *r->out.authoritative = true; /* authoritative response */
878         if (r->in.validation_level != 2 && r->in.validation_level != 3) {
879                 DEBUG(0,("%s: bad validation_level value %d.\n",
880                         fn, (int)r->in.validation_level));
881                 return NT_STATUS_ACCESS_DENIED;
882         }
883
884         if (process_creds) {
885
886                 /* Get the remote machine name for the creds store. */
887                 /* Note this is the remote machine this request is coming from (member server),
888                    not neccessarily the workstation name the user is logging onto.
889                 */
890
891                 if (!p->dc) {
892                         /* Restore the saved state of the netlogon creds. */
893                         bool ret;
894
895                         become_root();
896                         ret = secrets_restore_schannel_session_info(
897                                 p, r->in.computer_name, &p->dc);
898                         unbecome_root();
899                         if (!ret) {
900                                 return NT_STATUS_INVALID_HANDLE;
901                         }
902                 }
903
904                 if (!p->dc || !p->dc->authenticated) {
905                         return NT_STATUS_INVALID_HANDLE;
906                 }
907
908                 /* checks and updates credentials.  creates reply credentials */
909                 if (!netlogon_creds_server_step(p->dc, r->in.credential,  r->out.return_authenticator)) {
910                         DEBUG(2,("%s: creds_server_step failed. Rejecting auth "
911                                 "request from client %s machine account %s\n",
912                                 fn, r->in.computer_name, p->dc->mach_acct ));
913                         return NT_STATUS_INVALID_PARAMETER;
914                 }
915
916                 /* We must store the creds state after an update. */
917                 become_root();
918                 secrets_store_schannel_session_info(p, r->in.computer_name, p->dc);
919                 unbecome_root();
920         }
921
922         switch (r->in.logon_level) {
923         case NetlogonInteractiveInformation:
924                 fstrcpy(nt_username,
925                         logon->password->identity_info.account_name.string);
926                 fstrcpy(nt_domain,
927                         logon->password->identity_info.domain_name.string);
928                 fstrcpy(nt_workstation,
929                         logon->password->identity_info.workstation.string);
930
931                 DEBUG(3,("SAM Logon (Interactive). Domain:[%s].  ", lp_workgroup()));
932                 break;
933         case NetlogonNetworkInformation:
934                 fstrcpy(nt_username,
935                         logon->network->identity_info.account_name.string);
936                 fstrcpy(nt_domain,
937                         logon->network->identity_info.domain_name.string);
938                 fstrcpy(nt_workstation,
939                         logon->network->identity_info.workstation.string);
940
941                 DEBUG(3,("SAM Logon (Network). Domain:[%s].  ", lp_workgroup()));
942                 break;
943         default:
944                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
945                 return NT_STATUS_INVALID_INFO_CLASS;
946         } /* end switch */
947
948         DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain));
949         fstrcpy(current_user_info.smb_name, nt_username);
950         sub_set_smb_name(nt_username);
951
952         DEBUG(5,("Attempting validation level %d for unmapped username %s.\n",
953                 r->in.validation_level, nt_username));
954
955         status = NT_STATUS_OK;
956
957         switch (r->in.logon_level) {
958         case NetlogonNetworkInformation:
959         {
960                 const char *wksname = nt_workstation;
961
962                 status = make_auth_context_fixed(&auth_context,
963                                                  logon->network->challenge);
964                 if (!NT_STATUS_IS_OK(status)) {
965                         return status;
966                 }
967
968                 /* For a network logon, the workstation name comes in with two
969                  * backslashes in the front. Strip them if they are there. */
970
971                 if (*wksname == '\\') wksname++;
972                 if (*wksname == '\\') wksname++;
973
974                 /* Standard challenge/response authenticaion */
975                 if (!make_user_info_netlogon_network(&user_info,
976                                                      nt_username, nt_domain,
977                                                      wksname,
978                                                      logon->network->identity_info.parameter_control,
979                                                      logon->network->lm.data,
980                                                      logon->network->lm.length,
981                                                      logon->network->nt.data,
982                                                      logon->network->nt.length)) {
983                         status = NT_STATUS_NO_MEMORY;
984                 }
985                 break;
986         }
987         case NetlogonInteractiveInformation:
988                 /* 'Interactive' authentication, supplies the password in its
989                    MD4 form, encrypted with the session key.  We will convert
990                    this to challenge/response for the auth subsystem to chew
991                    on */
992         {
993                 const uint8 *chal;
994
995                 if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) {
996                         return status;
997                 }
998
999                 chal = auth_context->get_ntlm_challenge(auth_context);
1000
1001                 if (!make_user_info_netlogon_interactive(&user_info,
1002                                                          nt_username, nt_domain,
1003                                                          nt_workstation,
1004                                                          logon->password->identity_info.parameter_control,
1005                                                          chal,
1006                                                          logon->password->lmpassword.hash,
1007                                                          logon->password->ntpassword.hash,
1008                                                          p->dc->sess_key)) {
1009                         status = NT_STATUS_NO_MEMORY;
1010                 }
1011                 break;
1012         }
1013         default:
1014                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
1015                 return NT_STATUS_INVALID_INFO_CLASS;
1016         } /* end switch */
1017
1018         if ( NT_STATUS_IS_OK(status) ) {
1019                 status = auth_context->check_ntlm_password(auth_context,
1020                         user_info, &server_info);
1021         }
1022
1023         (auth_context->free)(&auth_context);
1024         free_user_info(&user_info);
1025
1026         DEBUG(5,("%s: check_password returned status %s\n",
1027                   fn, nt_errstr(status)));
1028
1029         /* Check account and password */
1030
1031         if (!NT_STATUS_IS_OK(status)) {
1032                 /* If we don't know what this domain is, we need to
1033                    indicate that we are not authoritative.  This
1034                    allows the client to decide if it needs to try
1035                    a local user.  Fix by jpjanosi@us.ibm.com, #2976 */
1036                 if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)
1037                      && !strequal(nt_domain, get_global_sam_name())
1038                      && !is_trusted_domain(nt_domain) )
1039                         *r->out.authoritative = false; /* We are not authoritative */
1040
1041                 TALLOC_FREE(server_info);
1042                 return status;
1043         }
1044
1045         if (server_info->guest) {
1046                 /* We don't like guest domain logons... */
1047                 DEBUG(5,("%s: Attempted domain logon as GUEST "
1048                          "denied.\n", fn));
1049                 TALLOC_FREE(server_info);
1050                 return NT_STATUS_LOGON_FAILURE;
1051         }
1052
1053         /* This is the point at which, if the login was successful, that
1054            the SAM Local Security Authority should record that the user is
1055            logged in to the domain.  */
1056
1057         if (process_creds) {
1058                 /* Get the pipe session key from the creds. */
1059                 memcpy(pipe_session_key, p->dc->sess_key, 16);
1060         } else {
1061                 /* Get the pipe session key from the schannel. */
1062                 if ((p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL)
1063                     || (p->auth.a_u.schannel_auth == NULL)) {
1064                         return NT_STATUS_INVALID_HANDLE;
1065                 }
1066                 memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
1067         }
1068
1069         status = serverinfo_to_SamInfo3(server_info, pipe_session_key, 16, sam3);
1070         TALLOC_FREE(server_info);
1071         return status;
1072 }
1073
1074 /*************************************************************************
1075  _netr_LogonSamLogonEx
1076  - no credential chaining. Map into net sam logon.
1077  *************************************************************************/
1078
1079 NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p,
1080                                struct netr_LogonSamLogonEx *r)
1081 {
1082         struct netr_LogonSamLogon q;
1083
1084         /* Only allow this if the pipe is protected. */
1085         if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1086                 DEBUG(0,("_netr_LogonSamLogonEx: client %s not using schannel for netlogon\n",
1087                         get_remote_machine_name() ));
1088                 return NT_STATUS_INVALID_PARAMETER;
1089         }
1090
1091         q.in.server_name        = r->in.server_name;
1092         q.in.computer_name      = r->in.computer_name;
1093         q.in.logon_level        = r->in.logon_level;
1094         q.in.logon              = r->in.logon;
1095         q.in.validation_level   = r->in.validation_level;
1096         /* we do not handle the flags */
1097         /*                      = r->in.flags; */
1098
1099         q.out.validation        = r->out.validation;
1100         q.out.authoritative     = r->out.authoritative;
1101         /* we do not handle the flags */
1102         /*                      = r->out.flags; */
1103
1104         return _netr_LogonSamLogon(p, &q);
1105 }
1106
1107 /*************************************************************************
1108  _ds_enum_dom_trusts
1109  *************************************************************************/
1110 #if 0   /* JERRY -- not correct */
1111  NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u,
1112                              DS_R_ENUM_DOM_TRUSTS *r_u)
1113 {
1114         NTSTATUS status = NT_STATUS_OK;
1115
1116         /* TODO: According to MSDN, the can only be executed against a
1117            DC or domain member running Windows 2000 or later.  Need
1118            to test against a standalone 2k server and see what it
1119            does.  A windows 2000 DC includes its own domain in the
1120            list.  --jerry */
1121
1122         return status;
1123 }
1124 #endif  /* JERRY */
1125
1126
1127 /****************************************************************
1128 ****************************************************************/
1129
1130 WERROR _netr_LogonUasLogon(pipes_struct *p,
1131                            struct netr_LogonUasLogon *r)
1132 {
1133         p->rng_fault_state = true;
1134         return WERR_NOT_SUPPORTED;
1135 }
1136
1137 /****************************************************************
1138 ****************************************************************/
1139
1140 WERROR _netr_LogonUasLogoff(pipes_struct *p,
1141                             struct netr_LogonUasLogoff *r)
1142 {
1143         p->rng_fault_state = true;
1144         return WERR_NOT_SUPPORTED;
1145 }
1146
1147 /****************************************************************
1148 ****************************************************************/
1149
1150 NTSTATUS _netr_DatabaseDeltas(pipes_struct *p,
1151                               struct netr_DatabaseDeltas *r)
1152 {
1153         p->rng_fault_state = true;
1154         return NT_STATUS_NOT_IMPLEMENTED;
1155 }
1156
1157 /****************************************************************
1158 ****************************************************************/
1159
1160 NTSTATUS _netr_DatabaseSync(pipes_struct *p,
1161                             struct netr_DatabaseSync *r)
1162 {
1163         p->rng_fault_state = true;
1164         return NT_STATUS_NOT_IMPLEMENTED;
1165 }
1166
1167 /****************************************************************
1168 ****************************************************************/
1169
1170 NTSTATUS _netr_AccountDeltas(pipes_struct *p,
1171                              struct netr_AccountDeltas *r)
1172 {
1173         p->rng_fault_state = true;
1174         return NT_STATUS_NOT_IMPLEMENTED;
1175 }
1176
1177 /****************************************************************
1178 ****************************************************************/
1179
1180 NTSTATUS _netr_AccountSync(pipes_struct *p,
1181                            struct netr_AccountSync *r)
1182 {
1183         p->rng_fault_state = true;
1184         return NT_STATUS_NOT_IMPLEMENTED;
1185 }
1186
1187 /****************************************************************
1188 ****************************************************************/
1189
1190 WERROR _netr_GetDcName(pipes_struct *p,
1191                        struct netr_GetDcName *r)
1192 {
1193         p->rng_fault_state = true;
1194         return WERR_NOT_SUPPORTED;
1195 }
1196
1197 /****************************************************************
1198 ****************************************************************/
1199
1200 WERROR _netr_GetAnyDCName(pipes_struct *p,
1201                           struct netr_GetAnyDCName *r)
1202 {
1203         p->rng_fault_state = true;
1204         return WERR_NOT_SUPPORTED;
1205 }
1206
1207 /****************************************************************
1208 ****************************************************************/
1209
1210 NTSTATUS _netr_DatabaseSync2(pipes_struct *p,
1211                              struct netr_DatabaseSync2 *r)
1212 {
1213         p->rng_fault_state = true;
1214         return NT_STATUS_NOT_IMPLEMENTED;
1215 }
1216
1217 /****************************************************************
1218 ****************************************************************/
1219
1220 NTSTATUS _netr_DatabaseRedo(pipes_struct *p,
1221                             struct netr_DatabaseRedo *r)
1222 {
1223         p->rng_fault_state = true;
1224         return NT_STATUS_NOT_IMPLEMENTED;
1225 }
1226
1227 /****************************************************************
1228 ****************************************************************/
1229
1230 WERROR _netr_DsRGetDCName(pipes_struct *p,
1231                           struct netr_DsRGetDCName *r)
1232 {
1233         p->rng_fault_state = true;
1234         return WERR_NOT_SUPPORTED;
1235 }
1236
1237 /****************************************************************
1238 ****************************************************************/
1239
1240 WERROR _netr_NETRLOGONDUMMYROUTINE1(pipes_struct *p,
1241                                     struct netr_NETRLOGONDUMMYROUTINE1 *r)
1242 {
1243         p->rng_fault_state = true;
1244         return WERR_NOT_SUPPORTED;
1245 }
1246
1247 /****************************************************************
1248 ****************************************************************/
1249
1250 WERROR _netr_NETRLOGONSETSERVICEBITS(pipes_struct *p,
1251                                      struct netr_NETRLOGONSETSERVICEBITS *r)
1252 {
1253         p->rng_fault_state = true;
1254         return WERR_NOT_SUPPORTED;
1255 }
1256
1257 /****************************************************************
1258 ****************************************************************/
1259
1260 WERROR _netr_LogonGetTrustRid(pipes_struct *p,
1261                               struct netr_LogonGetTrustRid *r)
1262 {
1263         p->rng_fault_state = true;
1264         return WERR_NOT_SUPPORTED;
1265 }
1266
1267 /****************************************************************
1268 ****************************************************************/
1269
1270 WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p,
1271                                           struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
1272 {
1273         p->rng_fault_state = true;
1274         return WERR_NOT_SUPPORTED;
1275 }
1276
1277 /****************************************************************
1278 ****************************************************************/
1279
1280 WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p,
1281                                           struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
1282 {
1283         p->rng_fault_state = true;
1284         return WERR_NOT_SUPPORTED;
1285 }
1286
1287 /****************************************************************
1288 ****************************************************************/
1289
1290 WERROR _netr_DsRGetDCNameEx(pipes_struct *p,
1291                             struct netr_DsRGetDCNameEx *r)
1292 {
1293         p->rng_fault_state = true;
1294         return WERR_NOT_SUPPORTED;
1295 }
1296
1297 /****************************************************************
1298 ****************************************************************/
1299
1300 WERROR _netr_DsRGetSiteName(pipes_struct *p,
1301                             struct netr_DsRGetSiteName *r)
1302 {
1303         p->rng_fault_state = true;
1304         return WERR_NOT_SUPPORTED;
1305 }
1306
1307 /****************************************************************
1308 ****************************************************************/
1309
1310 NTSTATUS _netr_LogonGetDomainInfo(pipes_struct *p,
1311                                   struct netr_LogonGetDomainInfo *r)
1312 {
1313         p->rng_fault_state = true;
1314         return NT_STATUS_NOT_IMPLEMENTED;
1315 }
1316
1317 /****************************************************************
1318 ****************************************************************/
1319
1320 NTSTATUS _netr_ServerPasswordSet2(pipes_struct *p,
1321                                   struct netr_ServerPasswordSet2 *r)
1322 {
1323         p->rng_fault_state = true;
1324         return NT_STATUS_NOT_IMPLEMENTED;
1325 }
1326
1327 /****************************************************************
1328 ****************************************************************/
1329
1330 WERROR _netr_ServerPasswordGet(pipes_struct *p,
1331                                struct netr_ServerPasswordGet *r)
1332 {
1333         p->rng_fault_state = true;
1334         return WERR_NOT_SUPPORTED;
1335 }
1336
1337 /****************************************************************
1338 ****************************************************************/
1339
1340 WERROR _netr_NETRLOGONSENDTOSAM(pipes_struct *p,
1341                                 struct netr_NETRLOGONSENDTOSAM *r)
1342 {
1343         p->rng_fault_state = true;
1344         return WERR_NOT_SUPPORTED;
1345 }
1346
1347 /****************************************************************
1348 ****************************************************************/
1349
1350 WERROR _netr_DsRAddressToSitenamesW(pipes_struct *p,
1351                                     struct netr_DsRAddressToSitenamesW *r)
1352 {
1353         p->rng_fault_state = true;
1354         return WERR_NOT_SUPPORTED;
1355 }
1356
1357 /****************************************************************
1358 ****************************************************************/
1359
1360 WERROR _netr_DsRGetDCNameEx2(pipes_struct *p,
1361                              struct netr_DsRGetDCNameEx2 *r)
1362 {
1363         p->rng_fault_state = true;
1364         return WERR_NOT_SUPPORTED;
1365 }
1366
1367 /****************************************************************
1368 ****************************************************************/
1369
1370 WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p,
1371                                                  struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1372 {
1373         p->rng_fault_state = true;
1374         return WERR_NOT_SUPPORTED;
1375 }
1376
1377 /****************************************************************
1378 ****************************************************************/
1379
1380 WERROR _netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p,
1381                                            struct netr_NetrEnumerateTrustedDomainsEx *r)
1382 {
1383         p->rng_fault_state = true;
1384         return WERR_NOT_SUPPORTED;
1385 }
1386
1387 /****************************************************************
1388 ****************************************************************/
1389
1390 WERROR _netr_DsRAddressToSitenamesExW(pipes_struct *p,
1391                                       struct netr_DsRAddressToSitenamesExW *r)
1392 {
1393         p->rng_fault_state = true;
1394         return WERR_NOT_SUPPORTED;
1395 }
1396
1397 /****************************************************************
1398 ****************************************************************/
1399
1400 WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p,
1401                                    struct netr_DsrGetDcSiteCoverageW *r)
1402 {
1403         p->rng_fault_state = true;
1404         return WERR_NOT_SUPPORTED;
1405 }
1406
1407 /****************************************************************
1408 ****************************************************************/
1409
1410 WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p,
1411                                       struct netr_DsrEnumerateDomainTrusts *r)
1412 {
1413         p->rng_fault_state = true;
1414         return WERR_NOT_SUPPORTED;
1415 }
1416
1417 /****************************************************************
1418 ****************************************************************/
1419
1420 WERROR _netr_DsrDeregisterDNSHostRecords(pipes_struct *p,
1421                                          struct netr_DsrDeregisterDNSHostRecords *r)
1422 {
1423         p->rng_fault_state = true;
1424         return WERR_NOT_SUPPORTED;
1425 }
1426
1427 /****************************************************************
1428 ****************************************************************/
1429
1430 NTSTATUS _netr_ServerTrustPasswordsGet(pipes_struct *p,
1431                                        struct netr_ServerTrustPasswordsGet *r)
1432 {
1433         p->rng_fault_state = true;
1434         return NT_STATUS_NOT_IMPLEMENTED;
1435 }
1436
1437 /****************************************************************
1438 ****************************************************************/
1439
1440 WERROR _netr_DsRGetForestTrustInformation(pipes_struct *p,
1441                                           struct netr_DsRGetForestTrustInformation *r)
1442 {
1443         p->rng_fault_state = true;
1444         return WERR_NOT_SUPPORTED;
1445 }
1446
1447 /****************************************************************
1448 ****************************************************************/
1449
1450 WERROR _netr_GetForestTrustInformation(pipes_struct *p,
1451                                        struct netr_GetForestTrustInformation *r)
1452 {
1453         p->rng_fault_state = true;
1454         return WERR_NOT_SUPPORTED;
1455 }
1456
1457 /****************************************************************
1458 ****************************************************************/
1459
1460 NTSTATUS _netr_LogonSamLogonWithFlags(pipes_struct *p,
1461                                       struct netr_LogonSamLogonWithFlags *r)
1462 {
1463         p->rng_fault_state = true;
1464         return NT_STATUS_NOT_IMPLEMENTED;
1465 }
1466
1467 /****************************************************************
1468 ****************************************************************/
1469
1470 NTSTATUS _netr_ServerGetTrustInfo(pipes_struct *p,
1471                                   struct netr_ServerGetTrustInfo *r)
1472 {
1473         p->rng_fault_state = true;
1474         return NT_STATUS_NOT_IMPLEMENTED;
1475 }
1476