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