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