s3-netlogon: let get_md4pw() return a struct samr_Password.
[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.query;
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(struct samr_Password *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->hash, pass, 16);
394         dump_data(5, md4pw->hash, 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         struct netr_ServerAuthenticate3 a;
451         uint32_t negotiate_flags = 0;
452         uint32_t rid;
453
454         a.in.server_name                = r->in.server_name;
455         a.in.account_name               = r->in.account_name;
456         a.in.secure_channel_type        = r->in.secure_channel_type;
457         a.in.computer_name              = r->in.computer_name;
458         a.in.credentials                = r->in.credentials;
459         a.in.negotiate_flags            = &negotiate_flags;
460
461         a.out.return_credentials        = r->out.return_credentials;
462         a.out.rid                       = &rid;
463         a.out.negotiate_flags           = &negotiate_flags;
464
465         return _netr_ServerAuthenticate3(p, &a);
466
467 }
468
469 /*************************************************************************
470  _netr_ServerAuthenticate3
471  *************************************************************************/
472
473 NTSTATUS _netr_ServerAuthenticate3(pipes_struct *p,
474                                    struct netr_ServerAuthenticate3 *r)
475 {
476         NTSTATUS status;
477         uint32_t srv_flgs;
478         /* r->in.negotiate_flags is an aliased pointer to r->out.negotiate_flags,
479          * so use a copy to avoid destroying the client values. */
480         uint32_t in_neg_flags = *r->in.negotiate_flags;
481         struct netr_Credential srv_chal_out;
482         const char *fn;
483         uint32_t rid;
484         struct samr_Password mach_pwd;
485
486         /* According to Microsoft (see bugid #6099)
487          * Windows 7 looks at the negotiate_flags
488          * returned in this structure *even if the
489          * call fails with access denied* ! So in order
490          * to allow Win7 to connect to a Samba NT style
491          * PDC we set the flags before we know if it's
492          * an error or not.
493          */
494
495         /* 0x000001ff */
496         srv_flgs = NETLOGON_NEG_ACCOUNT_LOCKOUT |
497                    NETLOGON_NEG_PERSISTENT_SAMREPL |
498                    NETLOGON_NEG_ARCFOUR |
499                    NETLOGON_NEG_PROMOTION_COUNT |
500                    NETLOGON_NEG_CHANGELOG_BDC |
501                    NETLOGON_NEG_FULL_SYNC_REPL |
502                    NETLOGON_NEG_MULTIPLE_SIDS |
503                    NETLOGON_NEG_REDO |
504                    NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL;
505
506         /* Ensure we support strong (128-bit) keys. */
507         if (in_neg_flags & NETLOGON_NEG_STRONG_KEYS) {
508                 srv_flgs |= NETLOGON_NEG_STRONG_KEYS;
509         }
510
511         if (lp_server_schannel() != false) {
512                 srv_flgs |= NETLOGON_NEG_SCHANNEL;
513         }
514
515         switch (p->hdr_req.opnum) {
516                 case NDR_NETR_SERVERAUTHENTICATE:
517                         fn = "_netr_ServerAuthenticate";
518                         break;
519                 case NDR_NETR_SERVERAUTHENTICATE2:
520                         fn = "_netr_ServerAuthenticate2";
521                         break;
522                 case NDR_NETR_SERVERAUTHENTICATE3:
523                         fn = "_netr_ServerAuthenticate3";
524                         break;
525                 default:
526                         return NT_STATUS_INTERNAL_ERROR;
527         }
528
529         /* We use this as the key to store the creds: */
530         /* r->in.computer_name */
531
532         if (!p->dc || !p->dc->challenge_sent) {
533                 DEBUG(0,("%s: no challenge sent to client %s\n", fn,
534                         r->in.computer_name));
535                 status = NT_STATUS_ACCESS_DENIED;
536                 goto out;
537         }
538
539         if ( (lp_server_schannel() == true) &&
540              ((in_neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) {
541
542                 /* schannel must be used, but client did not offer it. */
543                 DEBUG(0,("%s: schannel required but client failed "
544                         "to offer it. Client was %s\n",
545                         fn, r->in.account_name));
546                 status = NT_STATUS_ACCESS_DENIED;
547                 goto out;
548         }
549
550         status = get_md4pw(&mach_pwd,
551                            r->in.account_name,
552                            r->in.secure_channel_type,
553                            &rid);
554         if (!NT_STATUS_IS_OK(status)) {
555                 DEBUG(0,("%s: failed to get machine password for "
556                         "account %s: %s\n",
557                         fn, r->in.account_name, nt_errstr(status) ));
558                 /* always return NT_STATUS_ACCESS_DENIED */
559                 status = NT_STATUS_ACCESS_DENIED;
560                 goto out;
561         }
562
563         /* From the client / server challenges and md4 password, generate sess key */
564         creds_server_init(in_neg_flags,
565                         p->dc,
566                         &p->dc->clnt_chal,      /* Stored client chal. */
567                         &p->dc->srv_chal,       /* Stored server chal. */
568                         mach_pwd.hash,
569                         &srv_chal_out);
570
571         /* Check client credentials are valid. */
572         if (!netlogon_creds_server_check(p->dc, r->in.credentials)) {
573                 DEBUG(0,("%s: netlogon_creds_server_check failed. Rejecting auth "
574                         "request from client %s machine account %s\n",
575                         fn, r->in.computer_name,
576                         r->in.account_name));
577                 status = NT_STATUS_ACCESS_DENIED;
578                 goto out;
579         }
580         /* set up the LSA AUTH 2 response */
581         memcpy(r->out.return_credentials->data, &srv_chal_out.data,
582                sizeof(r->out.return_credentials->data));
583
584         fstrcpy(p->dc->mach_acct, r->in.account_name);
585         fstrcpy(p->dc->remote_machine, r->in.computer_name);
586         fstrcpy(p->dc->domain, lp_workgroup() );
587
588         p->dc->authenticated = True;
589
590         /* Store off the state so we can continue after client disconnect. */
591         become_root();
592         secrets_store_schannel_session_info(p->mem_ctx,
593                                             r->in.computer_name,
594                                             p->dc);
595         unbecome_root();
596
597         *r->out.rid = rid;
598
599         status = NT_STATUS_OK;
600
601   out:
602
603         *r->out.negotiate_flags = srv_flgs;
604         return status;
605 }
606
607 /*************************************************************************
608  _netr_ServerAuthenticate2
609  *************************************************************************/
610
611 NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p,
612                                    struct netr_ServerAuthenticate2 *r)
613 {
614         struct netr_ServerAuthenticate3 a;
615         uint32_t rid;
616
617         a.in.server_name                = r->in.server_name;
618         a.in.account_name               = r->in.account_name;
619         a.in.secure_channel_type        = r->in.secure_channel_type;
620         a.in.computer_name              = r->in.computer_name;
621         a.in.credentials                = r->in.credentials;
622         a.in.negotiate_flags            = r->in.negotiate_flags;
623
624         a.out.return_credentials        = r->out.return_credentials;
625         a.out.rid                       = &rid;
626         a.out.negotiate_flags           = r->out.negotiate_flags;
627
628         return _netr_ServerAuthenticate3(p, &a);
629 }
630
631 /*************************************************************************
632  _netr_ServerPasswordSet
633  *************************************************************************/
634
635 NTSTATUS _netr_ServerPasswordSet(pipes_struct *p,
636                                  struct netr_ServerPasswordSet *r)
637 {
638         NTSTATUS status = NT_STATUS_OK;
639         struct samu *sampass=NULL;
640         bool ret = False;
641         unsigned char pwd[16];
642         int i;
643         uint32 acct_ctrl;
644         struct netr_Authenticator cred_out;
645         const uchar *old_pw;
646
647         DEBUG(5,("_netr_ServerPasswordSet: %d\n", __LINE__));
648
649         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
650                 /* 'server schannel = yes' should enforce use of
651                    schannel, the client did offer it in auth2, but
652                    obviously did not use it. */
653                 DEBUG(0,("_netr_ServerPasswordSet: client %s not using schannel for netlogon\n",
654                         r->in.computer_name));
655                 return NT_STATUS_ACCESS_DENIED;
656         }
657
658         if (!p->dc) {
659                 /* Restore the saved state of the netlogon creds. */
660                 become_root();
661                 ret = secrets_restore_schannel_session_info(p, r->in.computer_name,
662                                                             &p->dc);
663                 unbecome_root();
664                 if (!ret) {
665                         return NT_STATUS_INVALID_HANDLE;
666                 }
667         }
668
669         if (!p->dc || !p->dc->authenticated) {
670                 return NT_STATUS_INVALID_HANDLE;
671         }
672
673         DEBUG(3,("_netr_ServerPasswordSet: Server Password Set by remote machine:[%s] on account [%s]\n",
674                         r->in.computer_name, p->dc->mach_acct));
675
676         /* Step the creds chain forward. */
677         if (!netlogon_creds_server_step(p->dc, r->in.credential, &cred_out)) {
678                 DEBUG(2,("_netr_ServerPasswordSet: netlogon_creds_server_step failed. Rejecting auth "
679                         "request from client %s machine account %s\n",
680                         r->in.computer_name, p->dc->mach_acct ));
681                 return NT_STATUS_INVALID_PARAMETER;
682         }
683
684         /* We must store the creds state after an update. */
685         sampass = samu_new( NULL );
686         if (!sampass) {
687                 return NT_STATUS_NO_MEMORY;
688         }
689
690         become_root();
691         secrets_store_schannel_session_info(p, r->in.computer_name, p->dc);
692         ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
693         unbecome_root();
694
695         if (!ret) {
696                 TALLOC_FREE(sampass);
697                 return NT_STATUS_ACCESS_DENIED;
698         }
699
700         /* Ensure the account exists and is a machine account. */
701
702         acct_ctrl = pdb_get_acct_ctrl(sampass);
703
704         if (!(acct_ctrl & ACB_WSTRUST ||
705                       acct_ctrl & ACB_SVRTRUST ||
706                       acct_ctrl & ACB_DOMTRUST)) {
707                 TALLOC_FREE(sampass);
708                 return NT_STATUS_NO_SUCH_USER;
709         }
710
711         if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
712                 TALLOC_FREE(sampass);
713                 return NT_STATUS_ACCOUNT_DISABLED;
714         }
715
716         /* Woah - what does this to to the credential chain ? JRA */
717         cred_hash3(pwd, r->in.new_password->hash, p->dc->sess_key, 0);
718
719         DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n"));
720         for(i = 0; i < sizeof(pwd); i++)
721                 DEBUG(100,("%02X ", pwd[i]));
722         DEBUG(100,("\n"));
723
724         old_pw = pdb_get_nt_passwd(sampass);
725
726         if (old_pw && memcmp(pwd, old_pw, 16) == 0) {
727                 /* Avoid backend modificiations and other fun if the
728                    client changed the password to the *same thing* */
729
730                 ret = True;
731         } else {
732
733                 /* LM password should be NULL for machines */
734                 if (!pdb_set_lanman_passwd(sampass, NULL, PDB_CHANGED)) {
735                         TALLOC_FREE(sampass);
736                         return NT_STATUS_NO_MEMORY;
737                 }
738
739                 if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) {
740                         TALLOC_FREE(sampass);
741                         return NT_STATUS_NO_MEMORY;
742                 }
743
744                 if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) {
745                         TALLOC_FREE(sampass);
746                         /* Not quite sure what this one qualifies as, but this will do */
747                         return NT_STATUS_UNSUCCESSFUL;
748                 }
749
750                 become_root();
751                 status = pdb_update_sam_account(sampass);
752                 unbecome_root();
753         }
754
755         /* set up the LSA Server Password Set response */
756
757         memcpy(r->out.return_authenticator, &cred_out,
758                sizeof(*(r->out.return_authenticator)));
759
760         TALLOC_FREE(sampass);
761         return status;
762 }
763
764 /*************************************************************************
765  _netr_LogonSamLogoff
766  *************************************************************************/
767
768 NTSTATUS _netr_LogonSamLogoff(pipes_struct *p,
769                               struct netr_LogonSamLogoff *r)
770 {
771         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
772                 /* 'server schannel = yes' should enforce use of
773                    schannel, the client did offer it in auth2, but
774                    obviously did not use it. */
775                 DEBUG(0,("_netr_LogonSamLogoff: client %s not using schannel for netlogon\n",
776                         get_remote_machine_name() ));
777                 return NT_STATUS_ACCESS_DENIED;
778         }
779
780
781         /* Using the remote machine name for the creds store: */
782         /* r->in.computer_name */
783
784         if (!p->dc) {
785                 /* Restore the saved state of the netlogon creds. */
786                 bool ret;
787
788                 become_root();
789                 ret = secrets_restore_schannel_session_info(
790                         p, r->in.computer_name, &p->dc);
791                 unbecome_root();
792                 if (!ret) {
793                         return NT_STATUS_INVALID_HANDLE;
794                 }
795         }
796
797         if (!p->dc || !p->dc->authenticated) {
798                 return NT_STATUS_INVALID_HANDLE;
799         }
800
801         /* checks and updates credentials.  creates reply credentials */
802         if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) {
803                 DEBUG(2,("_netr_LogonSamLogoff: netlogon_creds_server_step failed. Rejecting auth "
804                         "request from client %s machine account %s\n",
805                         r->in.computer_name, p->dc->mach_acct ));
806                 return NT_STATUS_INVALID_PARAMETER;
807         }
808
809         /* We must store the creds state after an update. */
810         become_root();
811         secrets_store_schannel_session_info(p, r->in.computer_name, p->dc);
812         unbecome_root();
813
814         return NT_STATUS_OK;
815 }
816
817 /*************************************************************************
818  _netr_LogonSamLogon
819  *************************************************************************/
820
821 NTSTATUS _netr_LogonSamLogon(pipes_struct *p,
822                              struct netr_LogonSamLogon *r)
823 {
824         NTSTATUS status = NT_STATUS_OK;
825         union netr_LogonLevel *logon = r->in.logon;
826         const char *nt_username, *nt_domain, *nt_workstation;
827         auth_usersupplied_info *user_info = NULL;
828         auth_serversupplied_info *server_info = NULL;
829         struct auth_context *auth_context = NULL;
830         uint8_t pipe_session_key[16];
831         bool process_creds = true;
832         const char *fn;
833
834         switch (p->hdr_req.opnum) {
835                 case NDR_NETR_LOGONSAMLOGON:
836                         process_creds = true;
837                         fn = "_netr_LogonSamLogon";
838                         break;
839                 case NDR_NETR_LOGONSAMLOGONEX:
840                         fn = "_netr_LogonSamLogonEx";
841                 default:
842                         fn = "";
843                         process_creds = false;
844         }
845
846         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
847                 /* 'server schannel = yes' should enforce use of
848                    schannel, the client did offer it in auth2, but
849                    obviously did not use it. */
850                 DEBUG(0,("%s: client %s not using schannel for netlogon\n",
851                         fn, get_remote_machine_name() ));
852                 return NT_STATUS_ACCESS_DENIED;
853         }
854
855         *r->out.authoritative = true; /* authoritative response */
856
857         switch (r->in.validation_level) {
858         case 2:
859                 r->out.validation->sam2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo2);
860                 if (!r->out.validation->sam2) {
861                         return NT_STATUS_NO_MEMORY;
862                 }
863                 break;
864         case 3:
865                 r->out.validation->sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3);
866                 if (!r->out.validation->sam3) {
867                         return NT_STATUS_NO_MEMORY;
868                 }
869                 break;
870         default:
871                 DEBUG(0,("%s: bad validation_level value %d.\n",
872                         fn, (int)r->in.validation_level));
873                 return NT_STATUS_INVALID_INFO_CLASS;
874         }
875
876         if (process_creds) {
877
878                 /* Get the remote machine name for the creds store. */
879                 /* Note this is the remote machine this request is coming from (member server),
880                    not neccessarily the workstation name the user is logging onto.
881                 */
882
883                 if (!p->dc) {
884                         /* Restore the saved state of the netlogon creds. */
885                         bool ret;
886
887                         become_root();
888                         ret = secrets_restore_schannel_session_info(
889                                 p, r->in.computer_name, &p->dc);
890                         unbecome_root();
891                         if (!ret) {
892                                 return NT_STATUS_INVALID_HANDLE;
893                         }
894                 }
895
896                 if (!p->dc || !p->dc->authenticated) {
897                         return NT_STATUS_INVALID_HANDLE;
898                 }
899
900                 /* checks and updates credentials.  creates reply credentials */
901                 if (!netlogon_creds_server_step(p->dc, r->in.credential,  r->out.return_authenticator)) {
902                         DEBUG(2,("%s: creds_server_step failed. Rejecting auth "
903                                 "request from client %s machine account %s\n",
904                                 fn, r->in.computer_name, p->dc->mach_acct ));
905                         return NT_STATUS_INVALID_PARAMETER;
906                 }
907
908                 /* We must store the creds state after an update. */
909                 become_root();
910                 secrets_store_schannel_session_info(p, r->in.computer_name, p->dc);
911                 unbecome_root();
912         }
913
914         switch (r->in.logon_level) {
915         case NetlogonInteractiveInformation:
916                 nt_username     = logon->password->identity_info.account_name.string;
917                 nt_domain       = logon->password->identity_info.domain_name.string;
918                 nt_workstation  = logon->password->identity_info.workstation.string;
919
920                 DEBUG(3,("SAM Logon (Interactive). Domain:[%s].  ", lp_workgroup()));
921                 break;
922         case NetlogonNetworkInformation:
923                 nt_username     = logon->network->identity_info.account_name.string;
924                 nt_domain       = logon->network->identity_info.domain_name.string;
925                 nt_workstation  = logon->network->identity_info.workstation.string;
926
927                 DEBUG(3,("SAM Logon (Network). Domain:[%s].  ", lp_workgroup()));
928                 break;
929         default:
930                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
931                 return NT_STATUS_INVALID_INFO_CLASS;
932         } /* end switch */
933
934         DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain));
935         fstrcpy(current_user_info.smb_name, nt_username);
936         sub_set_smb_name(nt_username);
937
938         DEBUG(5,("Attempting validation level %d for unmapped username %s.\n",
939                 r->in.validation_level, nt_username));
940
941         status = NT_STATUS_OK;
942
943         switch (r->in.logon_level) {
944         case NetlogonNetworkInformation:
945         {
946                 const char *wksname = nt_workstation;
947
948                 status = make_auth_context_fixed(&auth_context,
949                                                  logon->network->challenge);
950                 if (!NT_STATUS_IS_OK(status)) {
951                         return status;
952                 }
953
954                 /* For a network logon, the workstation name comes in with two
955                  * backslashes in the front. Strip them if they are there. */
956
957                 if (*wksname == '\\') wksname++;
958                 if (*wksname == '\\') wksname++;
959
960                 /* Standard challenge/response authenticaion */
961                 if (!make_user_info_netlogon_network(&user_info,
962                                                      nt_username, nt_domain,
963                                                      wksname,
964                                                      logon->network->identity_info.parameter_control,
965                                                      logon->network->lm.data,
966                                                      logon->network->lm.length,
967                                                      logon->network->nt.data,
968                                                      logon->network->nt.length)) {
969                         status = NT_STATUS_NO_MEMORY;
970                 }
971                 break;
972         }
973         case NetlogonInteractiveInformation:
974                 /* 'Interactive' authentication, supplies the password in its
975                    MD4 form, encrypted with the session key.  We will convert
976                    this to challenge/response for the auth subsystem to chew
977                    on */
978         {
979                 uint8_t chal[8];
980
981                 if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) {
982                         return status;
983                 }
984
985                 auth_context->get_ntlm_challenge(auth_context, chal);
986
987                 if (!make_user_info_netlogon_interactive(&user_info,
988                                                          nt_username, nt_domain,
989                                                          nt_workstation,
990                                                          logon->password->identity_info.parameter_control,
991                                                          chal,
992                                                          logon->password->lmpassword.hash,
993                                                          logon->password->ntpassword.hash,
994                                                          p->dc->sess_key)) {
995                         status = NT_STATUS_NO_MEMORY;
996                 }
997                 break;
998         }
999         default:
1000                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
1001                 return NT_STATUS_INVALID_INFO_CLASS;
1002         } /* end switch */
1003
1004         if ( NT_STATUS_IS_OK(status) ) {
1005                 status = auth_context->check_ntlm_password(auth_context,
1006                         user_info, &server_info);
1007         }
1008
1009         (auth_context->free)(&auth_context);
1010         free_user_info(&user_info);
1011
1012         DEBUG(5,("%s: check_password returned status %s\n",
1013                   fn, nt_errstr(status)));
1014
1015         /* Check account and password */
1016
1017         if (!NT_STATUS_IS_OK(status)) {
1018                 /* If we don't know what this domain is, we need to
1019                    indicate that we are not authoritative.  This
1020                    allows the client to decide if it needs to try
1021                    a local user.  Fix by jpjanosi@us.ibm.com, #2976 */
1022                 if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)
1023                      && !strequal(nt_domain, get_global_sam_name())
1024                      && !is_trusted_domain(nt_domain) )
1025                         *r->out.authoritative = false; /* We are not authoritative */
1026
1027                 TALLOC_FREE(server_info);
1028                 return status;
1029         }
1030
1031         if (server_info->guest) {
1032                 /* We don't like guest domain logons... */
1033                 DEBUG(5,("%s: Attempted domain logon as GUEST "
1034                          "denied.\n", fn));
1035                 TALLOC_FREE(server_info);
1036                 return NT_STATUS_LOGON_FAILURE;
1037         }
1038
1039         /* This is the point at which, if the login was successful, that
1040            the SAM Local Security Authority should record that the user is
1041            logged in to the domain.  */
1042
1043         if (process_creds) {
1044                 /* Get the pipe session key from the creds. */
1045                 memcpy(pipe_session_key, p->dc->sess_key, 16);
1046         } else {
1047                 /* Get the pipe session key from the schannel. */
1048                 if ((p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL)
1049                     || (p->auth.a_u.schannel_auth == NULL)) {
1050                         return NT_STATUS_INVALID_HANDLE;
1051                 }
1052                 memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
1053         }
1054
1055         switch (r->in.validation_level) {
1056         case 2:
1057                 status = serverinfo_to_SamInfo2(server_info, pipe_session_key, 16,
1058                                                 r->out.validation->sam2);
1059                 break;
1060         case 3:
1061                 status = serverinfo_to_SamInfo3(server_info, pipe_session_key, 16,
1062                                                 r->out.validation->sam3);
1063                 break;
1064         }
1065
1066         TALLOC_FREE(server_info);
1067
1068         return status;
1069 }
1070
1071 /*************************************************************************
1072  _netr_LogonSamLogonEx
1073  - no credential chaining. Map into net sam logon.
1074  *************************************************************************/
1075
1076 NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p,
1077                                struct netr_LogonSamLogonEx *r)
1078 {
1079         struct netr_LogonSamLogon q;
1080
1081         /* Only allow this if the pipe is protected. */
1082         if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1083                 DEBUG(0,("_netr_LogonSamLogonEx: client %s not using schannel for netlogon\n",
1084                         get_remote_machine_name() ));
1085                 return NT_STATUS_INVALID_PARAMETER;
1086         }
1087
1088         q.in.server_name        = r->in.server_name;
1089         q.in.computer_name      = r->in.computer_name;
1090         q.in.logon_level        = r->in.logon_level;
1091         q.in.logon              = r->in.logon;
1092         q.in.validation_level   = r->in.validation_level;
1093         /* we do not handle the flags */
1094         /*                      = r->in.flags; */
1095
1096         q.out.validation        = r->out.validation;
1097         q.out.authoritative     = r->out.authoritative;
1098         /* we do not handle the flags */
1099         /*                      = r->out.flags; */
1100
1101         return _netr_LogonSamLogon(p, &q);
1102 }
1103
1104 /*************************************************************************
1105  _ds_enum_dom_trusts
1106  *************************************************************************/
1107 #if 0   /* JERRY -- not correct */
1108  NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u,
1109                              DS_R_ENUM_DOM_TRUSTS *r_u)
1110 {
1111         NTSTATUS status = NT_STATUS_OK;
1112
1113         /* TODO: According to MSDN, the can only be executed against a
1114            DC or domain member running Windows 2000 or later.  Need
1115            to test against a standalone 2k server and see what it
1116            does.  A windows 2000 DC includes its own domain in the
1117            list.  --jerry */
1118
1119         return status;
1120 }
1121 #endif  /* JERRY */
1122
1123
1124 /****************************************************************
1125 ****************************************************************/
1126
1127 WERROR _netr_LogonUasLogon(pipes_struct *p,
1128                            struct netr_LogonUasLogon *r)
1129 {
1130         p->rng_fault_state = true;
1131         return WERR_NOT_SUPPORTED;
1132 }
1133
1134 /****************************************************************
1135 ****************************************************************/
1136
1137 WERROR _netr_LogonUasLogoff(pipes_struct *p,
1138                             struct netr_LogonUasLogoff *r)
1139 {
1140         p->rng_fault_state = true;
1141         return WERR_NOT_SUPPORTED;
1142 }
1143
1144 /****************************************************************
1145 ****************************************************************/
1146
1147 NTSTATUS _netr_DatabaseDeltas(pipes_struct *p,
1148                               struct netr_DatabaseDeltas *r)
1149 {
1150         p->rng_fault_state = true;
1151         return NT_STATUS_NOT_IMPLEMENTED;
1152 }
1153
1154 /****************************************************************
1155 ****************************************************************/
1156
1157 NTSTATUS _netr_DatabaseSync(pipes_struct *p,
1158                             struct netr_DatabaseSync *r)
1159 {
1160         p->rng_fault_state = true;
1161         return NT_STATUS_NOT_IMPLEMENTED;
1162 }
1163
1164 /****************************************************************
1165 ****************************************************************/
1166
1167 NTSTATUS _netr_AccountDeltas(pipes_struct *p,
1168                              struct netr_AccountDeltas *r)
1169 {
1170         p->rng_fault_state = true;
1171         return NT_STATUS_NOT_IMPLEMENTED;
1172 }
1173
1174 /****************************************************************
1175 ****************************************************************/
1176
1177 NTSTATUS _netr_AccountSync(pipes_struct *p,
1178                            struct netr_AccountSync *r)
1179 {
1180         p->rng_fault_state = true;
1181         return NT_STATUS_NOT_IMPLEMENTED;
1182 }
1183
1184 /****************************************************************
1185 ****************************************************************/
1186
1187 WERROR _netr_GetDcName(pipes_struct *p,
1188                        struct netr_GetDcName *r)
1189 {
1190         p->rng_fault_state = true;
1191         return WERR_NOT_SUPPORTED;
1192 }
1193
1194 /****************************************************************
1195 ****************************************************************/
1196
1197 WERROR _netr_GetAnyDCName(pipes_struct *p,
1198                           struct netr_GetAnyDCName *r)
1199 {
1200         p->rng_fault_state = true;
1201         return WERR_NOT_SUPPORTED;
1202 }
1203
1204 /****************************************************************
1205 ****************************************************************/
1206
1207 NTSTATUS _netr_DatabaseSync2(pipes_struct *p,
1208                              struct netr_DatabaseSync2 *r)
1209 {
1210         p->rng_fault_state = true;
1211         return NT_STATUS_NOT_IMPLEMENTED;
1212 }
1213
1214 /****************************************************************
1215 ****************************************************************/
1216
1217 NTSTATUS _netr_DatabaseRedo(pipes_struct *p,
1218                             struct netr_DatabaseRedo *r)
1219 {
1220         p->rng_fault_state = true;
1221         return NT_STATUS_NOT_IMPLEMENTED;
1222 }
1223
1224 /****************************************************************
1225 ****************************************************************/
1226
1227 WERROR _netr_DsRGetDCName(pipes_struct *p,
1228                           struct netr_DsRGetDCName *r)
1229 {
1230         p->rng_fault_state = true;
1231         return WERR_NOT_SUPPORTED;
1232 }
1233
1234 /****************************************************************
1235 ****************************************************************/
1236
1237 NTSTATUS _netr_LogonGetCapabilities(pipes_struct *p,
1238                                     struct netr_LogonGetCapabilities *r)
1239 {
1240         return NT_STATUS_NOT_IMPLEMENTED;
1241 }
1242
1243 /****************************************************************
1244 ****************************************************************/
1245
1246 WERROR _netr_NETRLOGONSETSERVICEBITS(pipes_struct *p,
1247                                      struct netr_NETRLOGONSETSERVICEBITS *r)
1248 {
1249         p->rng_fault_state = true;
1250         return WERR_NOT_SUPPORTED;
1251 }
1252
1253 /****************************************************************
1254 ****************************************************************/
1255
1256 WERROR _netr_LogonGetTrustRid(pipes_struct *p,
1257                               struct netr_LogonGetTrustRid *r)
1258 {
1259         p->rng_fault_state = true;
1260         return WERR_NOT_SUPPORTED;
1261 }
1262
1263 /****************************************************************
1264 ****************************************************************/
1265
1266 WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p,
1267                                           struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
1268 {
1269         p->rng_fault_state = true;
1270         return WERR_NOT_SUPPORTED;
1271 }
1272
1273 /****************************************************************
1274 ****************************************************************/
1275
1276 WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p,
1277                                           struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
1278 {
1279         p->rng_fault_state = true;
1280         return WERR_NOT_SUPPORTED;
1281 }
1282
1283 /****************************************************************
1284 ****************************************************************/
1285
1286 WERROR _netr_DsRGetDCNameEx(pipes_struct *p,
1287                             struct netr_DsRGetDCNameEx *r)
1288 {
1289         p->rng_fault_state = true;
1290         return WERR_NOT_SUPPORTED;
1291 }
1292
1293 /****************************************************************
1294 ****************************************************************/
1295
1296 WERROR _netr_DsRGetSiteName(pipes_struct *p,
1297                             struct netr_DsRGetSiteName *r)
1298 {
1299         p->rng_fault_state = true;
1300         return WERR_NOT_SUPPORTED;
1301 }
1302
1303 /****************************************************************
1304 ****************************************************************/
1305
1306 NTSTATUS _netr_LogonGetDomainInfo(pipes_struct *p,
1307                                   struct netr_LogonGetDomainInfo *r)
1308 {
1309         p->rng_fault_state = true;
1310         return NT_STATUS_NOT_IMPLEMENTED;
1311 }
1312
1313 /****************************************************************
1314 ****************************************************************/
1315
1316 NTSTATUS _netr_ServerPasswordSet2(pipes_struct *p,
1317                                   struct netr_ServerPasswordSet2 *r)
1318 {
1319         p->rng_fault_state = true;
1320         return NT_STATUS_NOT_IMPLEMENTED;
1321 }
1322
1323 /****************************************************************
1324 ****************************************************************/
1325
1326 WERROR _netr_ServerPasswordGet(pipes_struct *p,
1327                                struct netr_ServerPasswordGet *r)
1328 {
1329         p->rng_fault_state = true;
1330         return WERR_NOT_SUPPORTED;
1331 }
1332
1333 /****************************************************************
1334 ****************************************************************/
1335
1336 WERROR _netr_NETRLOGONSENDTOSAM(pipes_struct *p,
1337                                 struct netr_NETRLOGONSENDTOSAM *r)
1338 {
1339         p->rng_fault_state = true;
1340         return WERR_NOT_SUPPORTED;
1341 }
1342
1343 /****************************************************************
1344 ****************************************************************/
1345
1346 WERROR _netr_DsRAddressToSitenamesW(pipes_struct *p,
1347                                     struct netr_DsRAddressToSitenamesW *r)
1348 {
1349         p->rng_fault_state = true;
1350         return WERR_NOT_SUPPORTED;
1351 }
1352
1353 /****************************************************************
1354 ****************************************************************/
1355
1356 WERROR _netr_DsRGetDCNameEx2(pipes_struct *p,
1357                              struct netr_DsRGetDCNameEx2 *r)
1358 {
1359         p->rng_fault_state = true;
1360         return WERR_NOT_SUPPORTED;
1361 }
1362
1363 /****************************************************************
1364 ****************************************************************/
1365
1366 WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p,
1367                                                  struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1368 {
1369         p->rng_fault_state = true;
1370         return WERR_NOT_SUPPORTED;
1371 }
1372
1373 /****************************************************************
1374 ****************************************************************/
1375
1376 WERROR _netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p,
1377                                            struct netr_NetrEnumerateTrustedDomainsEx *r)
1378 {
1379         p->rng_fault_state = true;
1380         return WERR_NOT_SUPPORTED;
1381 }
1382
1383 /****************************************************************
1384 ****************************************************************/
1385
1386 WERROR _netr_DsRAddressToSitenamesExW(pipes_struct *p,
1387                                       struct netr_DsRAddressToSitenamesExW *r)
1388 {
1389         p->rng_fault_state = true;
1390         return WERR_NOT_SUPPORTED;
1391 }
1392
1393 /****************************************************************
1394 ****************************************************************/
1395
1396 WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p,
1397                                    struct netr_DsrGetDcSiteCoverageW *r)
1398 {
1399         p->rng_fault_state = true;
1400         return WERR_NOT_SUPPORTED;
1401 }
1402
1403 /****************************************************************
1404 ****************************************************************/
1405
1406 WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p,
1407                                       struct netr_DsrEnumerateDomainTrusts *r)
1408 {
1409         p->rng_fault_state = true;
1410         return WERR_NOT_SUPPORTED;
1411 }
1412
1413 /****************************************************************
1414 ****************************************************************/
1415
1416 WERROR _netr_DsrDeregisterDNSHostRecords(pipes_struct *p,
1417                                          struct netr_DsrDeregisterDNSHostRecords *r)
1418 {
1419         p->rng_fault_state = true;
1420         return WERR_NOT_SUPPORTED;
1421 }
1422
1423 /****************************************************************
1424 ****************************************************************/
1425
1426 NTSTATUS _netr_ServerTrustPasswordsGet(pipes_struct *p,
1427                                        struct netr_ServerTrustPasswordsGet *r)
1428 {
1429         p->rng_fault_state = true;
1430         return NT_STATUS_NOT_IMPLEMENTED;
1431 }
1432
1433 /****************************************************************
1434 ****************************************************************/
1435
1436 WERROR _netr_DsRGetForestTrustInformation(pipes_struct *p,
1437                                           struct netr_DsRGetForestTrustInformation *r)
1438 {
1439         p->rng_fault_state = true;
1440         return WERR_NOT_SUPPORTED;
1441 }
1442
1443 /****************************************************************
1444 ****************************************************************/
1445
1446 WERROR _netr_GetForestTrustInformation(pipes_struct *p,
1447                                        struct netr_GetForestTrustInformation *r)
1448 {
1449         p->rng_fault_state = true;
1450         return WERR_NOT_SUPPORTED;
1451 }
1452
1453 /****************************************************************
1454 ****************************************************************/
1455
1456 NTSTATUS _netr_LogonSamLogonWithFlags(pipes_struct *p,
1457                                       struct netr_LogonSamLogonWithFlags *r)
1458 {
1459         p->rng_fault_state = true;
1460         return NT_STATUS_NOT_IMPLEMENTED;
1461 }
1462
1463 /****************************************************************
1464 ****************************************************************/
1465
1466 NTSTATUS _netr_ServerGetTrustInfo(pipes_struct *p,
1467                                   struct netr_ServerGetTrustInfo *r)
1468 {
1469         p->rng_fault_state = true;
1470         return NT_STATUS_NOT_IMPLEMENTED;
1471 }
1472