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