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