schannel: fully share schannel sign/seal between s3 and 4.
[metze/samba/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                 nt_username     = logon->password->identity_info.account_name.string;
922                 nt_domain       = logon->password->identity_info.domain_name.string;
923                 nt_workstation  = logon->password->identity_info.workstation.string;
924
925                 DEBUG(3,("SAM Logon (Interactive). Domain:[%s].  ", lp_workgroup()));
926                 break;
927         case NetlogonNetworkInformation:
928                 nt_username     = logon->network->identity_info.account_name.string;
929                 nt_domain       = logon->network->identity_info.domain_name.string;
930                 nt_workstation  = logon->network->identity_info.workstation.string;
931
932                 DEBUG(3,("SAM Logon (Network). Domain:[%s].  ", lp_workgroup()));
933                 break;
934         default:
935                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
936                 return NT_STATUS_INVALID_INFO_CLASS;
937         } /* end switch */
938
939         DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain));
940         fstrcpy(current_user_info.smb_name, nt_username);
941         sub_set_smb_name(nt_username);
942
943         DEBUG(5,("Attempting validation level %d for unmapped username %s.\n",
944                 r->in.validation_level, nt_username));
945
946         status = NT_STATUS_OK;
947
948         switch (r->in.logon_level) {
949         case NetlogonNetworkInformation:
950         {
951                 const char *wksname = nt_workstation;
952
953                 status = make_auth_context_fixed(&auth_context,
954                                                  logon->network->challenge);
955                 if (!NT_STATUS_IS_OK(status)) {
956                         return status;
957                 }
958
959                 /* For a network logon, the workstation name comes in with two
960                  * backslashes in the front. Strip them if they are there. */
961
962                 if (*wksname == '\\') wksname++;
963                 if (*wksname == '\\') wksname++;
964
965                 /* Standard challenge/response authenticaion */
966                 if (!make_user_info_netlogon_network(&user_info,
967                                                      nt_username, nt_domain,
968                                                      wksname,
969                                                      logon->network->identity_info.parameter_control,
970                                                      logon->network->lm.data,
971                                                      logon->network->lm.length,
972                                                      logon->network->nt.data,
973                                                      logon->network->nt.length)) {
974                         status = NT_STATUS_NO_MEMORY;
975                 }
976                 break;
977         }
978         case NetlogonInteractiveInformation:
979                 /* 'Interactive' authentication, supplies the password in its
980                    MD4 form, encrypted with the session key.  We will convert
981                    this to challenge/response for the auth subsystem to chew
982                    on */
983         {
984                 uint8_t chal[8];
985
986                 if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) {
987                         return status;
988                 }
989
990                 auth_context->get_ntlm_challenge(auth_context, chal);
991
992                 if (!make_user_info_netlogon_interactive(&user_info,
993                                                          nt_username, nt_domain,
994                                                          nt_workstation,
995                                                          logon->password->identity_info.parameter_control,
996                                                          chal,
997                                                          logon->password->lmpassword.hash,
998                                                          logon->password->ntpassword.hash,
999                                                          creds->session_key)) {
1000                         status = NT_STATUS_NO_MEMORY;
1001                 }
1002                 break;
1003         }
1004         default:
1005                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
1006                 return NT_STATUS_INVALID_INFO_CLASS;
1007         } /* end switch */
1008
1009         if ( NT_STATUS_IS_OK(status) ) {
1010                 status = auth_context->check_ntlm_password(auth_context,
1011                         user_info, &server_info);
1012         }
1013
1014         (auth_context->free)(&auth_context);
1015         free_user_info(&user_info);
1016
1017         DEBUG(5,("%s: check_password returned status %s\n",
1018                   fn, nt_errstr(status)));
1019
1020         /* Check account and password */
1021
1022         if (!NT_STATUS_IS_OK(status)) {
1023                 /* If we don't know what this domain is, we need to
1024                    indicate that we are not authoritative.  This
1025                    allows the client to decide if it needs to try
1026                    a local user.  Fix by jpjanosi@us.ibm.com, #2976 */
1027                 if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)
1028                      && !strequal(nt_domain, get_global_sam_name())
1029                      && !is_trusted_domain(nt_domain) )
1030                         *r->out.authoritative = false; /* We are not authoritative */
1031
1032                 TALLOC_FREE(server_info);
1033                 return status;
1034         }
1035
1036         if (server_info->guest) {
1037                 /* We don't like guest domain logons... */
1038                 DEBUG(5,("%s: Attempted domain logon as GUEST "
1039                          "denied.\n", fn));
1040                 TALLOC_FREE(server_info);
1041                 return NT_STATUS_LOGON_FAILURE;
1042         }
1043
1044         /* This is the point at which, if the login was successful, that
1045            the SAM Local Security Authority should record that the user is
1046            logged in to the domain.  */
1047
1048         if (process_creds) {
1049                 /* Get the pipe session key from the creds. */
1050                 memcpy(pipe_session_key, creds->session_key, 16);
1051         } else {
1052                 /* Get the pipe session key from the schannel. */
1053                 if ((p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL)
1054                     || (p->auth.a_u.schannel_auth == NULL)) {
1055                         return NT_STATUS_INVALID_HANDLE;
1056                 }
1057                 memcpy(pipe_session_key, p->auth.a_u.schannel_auth->creds->session_key, 16);
1058         }
1059
1060         switch (r->in.validation_level) {
1061         case 2:
1062                 status = serverinfo_to_SamInfo2(server_info, pipe_session_key, 16,
1063                                                 r->out.validation->sam2);
1064                 break;
1065         case 3:
1066                 status = serverinfo_to_SamInfo3(server_info, pipe_session_key, 16,
1067                                                 r->out.validation->sam3);
1068                 break;
1069         }
1070
1071         TALLOC_FREE(server_info);
1072
1073         return status;
1074 }
1075
1076 /****************************************************************
1077  _netr_LogonSamLogonWithFlags
1078 ****************************************************************/
1079
1080 NTSTATUS _netr_LogonSamLogonWithFlags(pipes_struct *p,
1081                                       struct netr_LogonSamLogonWithFlags *r)
1082 {
1083         NTSTATUS status;
1084         struct netlogon_creds_CredentialState *creds;
1085         struct netr_LogonSamLogonEx r2;
1086         struct netr_Authenticator return_authenticator;
1087
1088         become_root();
1089         status = netr_creds_server_step_check(p, p->mem_ctx,
1090                                               r->in.computer_name,
1091                                               r->in.credential,
1092                                               &return_authenticator,
1093                                               &creds);
1094         unbecome_root();
1095         if (!NT_STATUS_IS_OK(status)) {
1096                 return status;
1097         }
1098
1099         r2.in.server_name       = r->in.server_name;
1100         r2.in.computer_name     = r->in.computer_name;
1101         r2.in.logon_level       = r->in.logon_level;
1102         r2.in.logon             = r->in.logon;
1103         r2.in.validation_level  = r->in.validation_level;
1104         r2.in.flags             = r->in.flags;
1105         r2.out.validation       = r->out.validation;
1106         r2.out.authoritative    = r->out.authoritative;
1107         r2.out.flags            = r->out.flags;
1108
1109         status = _netr_LogonSamLogon_base(p, &r2, creds);
1110
1111         *r->out.return_authenticator = return_authenticator;
1112
1113         return status;
1114 }
1115
1116 /*************************************************************************
1117  _netr_LogonSamLogon
1118  *************************************************************************/
1119
1120 NTSTATUS _netr_LogonSamLogon(pipes_struct *p,
1121                              struct netr_LogonSamLogon *r)
1122 {
1123         NTSTATUS status;
1124         struct netr_LogonSamLogonWithFlags r2;
1125         uint32_t flags = 0;
1126
1127         r2.in.server_name               = r->in.server_name;
1128         r2.in.computer_name             = r->in.computer_name;
1129         r2.in.credential                = r->in.credential;
1130         r2.in.logon_level               = r->in.logon_level;
1131         r2.in.logon                     = r->in.logon;
1132         r2.in.validation_level          = r->in.validation_level;
1133         r2.in.return_authenticator      = r->in.return_authenticator;
1134         r2.in.flags                     = &flags;
1135         r2.out.validation               = r->out.validation;
1136         r2.out.authoritative            = r->out.authoritative;
1137         r2.out.flags                    = &flags;
1138         r2.out.return_authenticator     = r->out.return_authenticator;
1139
1140         status = _netr_LogonSamLogonWithFlags(p, &r2);
1141
1142         return status;
1143 }
1144
1145 /*************************************************************************
1146  _netr_LogonSamLogonEx
1147  - no credential chaining. Map into net sam logon.
1148  *************************************************************************/
1149
1150 NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p,
1151                                struct netr_LogonSamLogonEx *r)
1152 {
1153         NTSTATUS status;
1154         struct netlogon_creds_CredentialState *creds = NULL;
1155
1156         become_root();
1157         status = schannel_fetch_session_key(p->mem_ctx, r->in.computer_name, &creds);
1158         unbecome_root();
1159         if (!NT_STATUS_IS_OK(status)) {
1160                 return status;
1161         }
1162
1163         /* Only allow this if the pipe is protected. */
1164         if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1165                 DEBUG(0,("_netr_LogonSamLogonEx: client %s not using schannel for netlogon\n",
1166                         get_remote_machine_name() ));
1167                 return NT_STATUS_INVALID_PARAMETER;
1168         }
1169
1170         status = _netr_LogonSamLogon_base(p, r, creds);
1171         TALLOC_FREE(creds);
1172
1173         return status;
1174 }
1175
1176 /*************************************************************************
1177  _ds_enum_dom_trusts
1178  *************************************************************************/
1179 #if 0   /* JERRY -- not correct */
1180  NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u,
1181                              DS_R_ENUM_DOM_TRUSTS *r_u)
1182 {
1183         NTSTATUS status = NT_STATUS_OK;
1184
1185         /* TODO: According to MSDN, the can only be executed against a
1186            DC or domain member running Windows 2000 or later.  Need
1187            to test against a standalone 2k server and see what it
1188            does.  A windows 2000 DC includes its own domain in the
1189            list.  --jerry */
1190
1191         return status;
1192 }
1193 #endif  /* JERRY */
1194
1195
1196 /****************************************************************
1197 ****************************************************************/
1198
1199 WERROR _netr_LogonUasLogon(pipes_struct *p,
1200                            struct netr_LogonUasLogon *r)
1201 {
1202         p->rng_fault_state = true;
1203         return WERR_NOT_SUPPORTED;
1204 }
1205
1206 /****************************************************************
1207 ****************************************************************/
1208
1209 WERROR _netr_LogonUasLogoff(pipes_struct *p,
1210                             struct netr_LogonUasLogoff *r)
1211 {
1212         p->rng_fault_state = true;
1213         return WERR_NOT_SUPPORTED;
1214 }
1215
1216 /****************************************************************
1217 ****************************************************************/
1218
1219 NTSTATUS _netr_DatabaseDeltas(pipes_struct *p,
1220                               struct netr_DatabaseDeltas *r)
1221 {
1222         p->rng_fault_state = true;
1223         return NT_STATUS_NOT_IMPLEMENTED;
1224 }
1225
1226 /****************************************************************
1227 ****************************************************************/
1228
1229 NTSTATUS _netr_DatabaseSync(pipes_struct *p,
1230                             struct netr_DatabaseSync *r)
1231 {
1232         p->rng_fault_state = true;
1233         return NT_STATUS_NOT_IMPLEMENTED;
1234 }
1235
1236 /****************************************************************
1237 ****************************************************************/
1238
1239 NTSTATUS _netr_AccountDeltas(pipes_struct *p,
1240                              struct netr_AccountDeltas *r)
1241 {
1242         p->rng_fault_state = true;
1243         return NT_STATUS_NOT_IMPLEMENTED;
1244 }
1245
1246 /****************************************************************
1247 ****************************************************************/
1248
1249 NTSTATUS _netr_AccountSync(pipes_struct *p,
1250                            struct netr_AccountSync *r)
1251 {
1252         p->rng_fault_state = true;
1253         return NT_STATUS_NOT_IMPLEMENTED;
1254 }
1255
1256 /****************************************************************
1257 ****************************************************************/
1258
1259 WERROR _netr_GetDcName(pipes_struct *p,
1260                        struct netr_GetDcName *r)
1261 {
1262         p->rng_fault_state = true;
1263         return WERR_NOT_SUPPORTED;
1264 }
1265
1266 /****************************************************************
1267 ****************************************************************/
1268
1269 WERROR _netr_GetAnyDCName(pipes_struct *p,
1270                           struct netr_GetAnyDCName *r)
1271 {
1272         p->rng_fault_state = true;
1273         return WERR_NOT_SUPPORTED;
1274 }
1275
1276 /****************************************************************
1277 ****************************************************************/
1278
1279 NTSTATUS _netr_DatabaseSync2(pipes_struct *p,
1280                              struct netr_DatabaseSync2 *r)
1281 {
1282         p->rng_fault_state = true;
1283         return NT_STATUS_NOT_IMPLEMENTED;
1284 }
1285
1286 /****************************************************************
1287 ****************************************************************/
1288
1289 NTSTATUS _netr_DatabaseRedo(pipes_struct *p,
1290                             struct netr_DatabaseRedo *r)
1291 {
1292         p->rng_fault_state = true;
1293         return NT_STATUS_NOT_IMPLEMENTED;
1294 }
1295
1296 /****************************************************************
1297 ****************************************************************/
1298
1299 WERROR _netr_DsRGetDCName(pipes_struct *p,
1300                           struct netr_DsRGetDCName *r)
1301 {
1302         p->rng_fault_state = true;
1303         return WERR_NOT_SUPPORTED;
1304 }
1305
1306 /****************************************************************
1307 ****************************************************************/
1308
1309 NTSTATUS _netr_LogonGetCapabilities(pipes_struct *p,
1310                                     struct netr_LogonGetCapabilities *r)
1311 {
1312         return NT_STATUS_NOT_IMPLEMENTED;
1313 }
1314
1315 /****************************************************************
1316 ****************************************************************/
1317
1318 WERROR _netr_NETRLOGONSETSERVICEBITS(pipes_struct *p,
1319                                      struct netr_NETRLOGONSETSERVICEBITS *r)
1320 {
1321         p->rng_fault_state = true;
1322         return WERR_NOT_SUPPORTED;
1323 }
1324
1325 /****************************************************************
1326 ****************************************************************/
1327
1328 WERROR _netr_LogonGetTrustRid(pipes_struct *p,
1329                               struct netr_LogonGetTrustRid *r)
1330 {
1331         p->rng_fault_state = true;
1332         return WERR_NOT_SUPPORTED;
1333 }
1334
1335 /****************************************************************
1336 ****************************************************************/
1337
1338 WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p,
1339                                           struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
1340 {
1341         p->rng_fault_state = true;
1342         return WERR_NOT_SUPPORTED;
1343 }
1344
1345 /****************************************************************
1346 ****************************************************************/
1347
1348 WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p,
1349                                           struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
1350 {
1351         p->rng_fault_state = true;
1352         return WERR_NOT_SUPPORTED;
1353 }
1354
1355 /****************************************************************
1356 ****************************************************************/
1357
1358 WERROR _netr_DsRGetDCNameEx(pipes_struct *p,
1359                             struct netr_DsRGetDCNameEx *r)
1360 {
1361         p->rng_fault_state = true;
1362         return WERR_NOT_SUPPORTED;
1363 }
1364
1365 /****************************************************************
1366 ****************************************************************/
1367
1368 WERROR _netr_DsRGetSiteName(pipes_struct *p,
1369                             struct netr_DsRGetSiteName *r)
1370 {
1371         p->rng_fault_state = true;
1372         return WERR_NOT_SUPPORTED;
1373 }
1374
1375 /****************************************************************
1376 ****************************************************************/
1377
1378 NTSTATUS _netr_LogonGetDomainInfo(pipes_struct *p,
1379                                   struct netr_LogonGetDomainInfo *r)
1380 {
1381         p->rng_fault_state = true;
1382         return NT_STATUS_NOT_IMPLEMENTED;
1383 }
1384
1385 /****************************************************************
1386 ****************************************************************/
1387
1388 WERROR _netr_ServerPasswordGet(pipes_struct *p,
1389                                struct netr_ServerPasswordGet *r)
1390 {
1391         p->rng_fault_state = true;
1392         return WERR_NOT_SUPPORTED;
1393 }
1394
1395 /****************************************************************
1396 ****************************************************************/
1397
1398 WERROR _netr_NETRLOGONSENDTOSAM(pipes_struct *p,
1399                                 struct netr_NETRLOGONSENDTOSAM *r)
1400 {
1401         p->rng_fault_state = true;
1402         return WERR_NOT_SUPPORTED;
1403 }
1404
1405 /****************************************************************
1406 ****************************************************************/
1407
1408 WERROR _netr_DsRAddressToSitenamesW(pipes_struct *p,
1409                                     struct netr_DsRAddressToSitenamesW *r)
1410 {
1411         p->rng_fault_state = true;
1412         return WERR_NOT_SUPPORTED;
1413 }
1414
1415 /****************************************************************
1416 ****************************************************************/
1417
1418 WERROR _netr_DsRGetDCNameEx2(pipes_struct *p,
1419                              struct netr_DsRGetDCNameEx2 *r)
1420 {
1421         p->rng_fault_state = true;
1422         return WERR_NOT_SUPPORTED;
1423 }
1424
1425 /****************************************************************
1426 ****************************************************************/
1427
1428 WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p,
1429                                                  struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1430 {
1431         p->rng_fault_state = true;
1432         return WERR_NOT_SUPPORTED;
1433 }
1434
1435 /****************************************************************
1436 ****************************************************************/
1437
1438 WERROR _netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p,
1439                                            struct netr_NetrEnumerateTrustedDomainsEx *r)
1440 {
1441         p->rng_fault_state = true;
1442         return WERR_NOT_SUPPORTED;
1443 }
1444
1445 /****************************************************************
1446 ****************************************************************/
1447
1448 WERROR _netr_DsRAddressToSitenamesExW(pipes_struct *p,
1449                                       struct netr_DsRAddressToSitenamesExW *r)
1450 {
1451         p->rng_fault_state = true;
1452         return WERR_NOT_SUPPORTED;
1453 }
1454
1455 /****************************************************************
1456 ****************************************************************/
1457
1458 WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p,
1459                                    struct netr_DsrGetDcSiteCoverageW *r)
1460 {
1461         p->rng_fault_state = true;
1462         return WERR_NOT_SUPPORTED;
1463 }
1464
1465 /****************************************************************
1466 ****************************************************************/
1467
1468 WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p,
1469                                       struct netr_DsrEnumerateDomainTrusts *r)
1470 {
1471         p->rng_fault_state = true;
1472         return WERR_NOT_SUPPORTED;
1473 }
1474
1475 /****************************************************************
1476 ****************************************************************/
1477
1478 WERROR _netr_DsrDeregisterDNSHostRecords(pipes_struct *p,
1479                                          struct netr_DsrDeregisterDNSHostRecords *r)
1480 {
1481         p->rng_fault_state = true;
1482         return WERR_NOT_SUPPORTED;
1483 }
1484
1485 /****************************************************************
1486 ****************************************************************/
1487
1488 NTSTATUS _netr_ServerTrustPasswordsGet(pipes_struct *p,
1489                                        struct netr_ServerTrustPasswordsGet *r)
1490 {
1491         p->rng_fault_state = true;
1492         return NT_STATUS_NOT_IMPLEMENTED;
1493 }
1494
1495 /****************************************************************
1496 ****************************************************************/
1497
1498 WERROR _netr_DsRGetForestTrustInformation(pipes_struct *p,
1499                                           struct netr_DsRGetForestTrustInformation *r)
1500 {
1501         p->rng_fault_state = true;
1502         return WERR_NOT_SUPPORTED;
1503 }
1504
1505 /****************************************************************
1506 ****************************************************************/
1507
1508 WERROR _netr_GetForestTrustInformation(pipes_struct *p,
1509                                        struct netr_GetForestTrustInformation *r)
1510 {
1511         p->rng_fault_state = true;
1512         return WERR_NOT_SUPPORTED;
1513 }
1514
1515 /****************************************************************
1516 ****************************************************************/
1517
1518 NTSTATUS _netr_ServerGetTrustInfo(pipes_struct *p,
1519                                   struct netr_ServerGetTrustInfo *r)
1520 {
1521         p->rng_fault_state = true;
1522         return NT_STATUS_NOT_IMPLEMENTED;
1523 }
1524