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-2009.
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.
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.
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/>.
25 /* This is the implementation of the netlogon pipe. */
28 #include "../libcli/auth/schannel.h"
29 #include "../librpc/gen_ndr/srv_netlogon.h"
30 #include "../librpc/gen_ndr/srv_samr.h"
31 #include "../librpc/gen_ndr/srv_lsa.h"
32 #include "../librpc/gen_ndr/cli_samr.h"
33 #include "../librpc/gen_ndr/cli_lsa.h"
34 #include "rpc_client/cli_lsarpc.h"
35 #include "librpc/gen_ndr/messaging.h"
36 #include "../lib/crypto/md4.h"
37 #include "rpc_client/init_lsa.h"
38 #include "rpc_server/rpc_ncacn_np.h"
39 #include "../libcli/security/security.h"
41 extern userdom_struct current_user_info;
44 #define DBGC_CLASS DBGC_RPC_SRV
46 struct netlogon_server_pipe_state {
47 struct netr_Credential client_challenge;
48 struct netr_Credential server_challenge;
51 /*************************************************************************
53 *************************************************************************/
55 WERROR _netr_LogonControl(struct pipes_struct *p,
56 struct netr_LogonControl *r)
58 struct netr_LogonControl2Ex l;
60 switch (r->in.level) {
64 return WERR_NOT_SUPPORTED;
66 return WERR_UNKNOWN_LEVEL;
69 l.in.logon_server = r->in.logon_server;
70 l.in.function_code = r->in.function_code;
71 l.in.level = r->in.level;
73 l.out.query = r->out.query;
75 return _netr_LogonControl2Ex(p, &l);
78 /****************************************************************************
79 Send a message to smbd to do a sam synchronisation
80 **************************************************************************/
82 static void send_sync_message(struct messaging_context *msg_ctx)
84 DEBUG(3, ("sending sam synchronisation message\n"));
85 message_send_all(msg_ctx, MSG_SMB_SAM_SYNC, NULL, 0, NULL);
88 /*************************************************************************
90 *************************************************************************/
92 WERROR _netr_LogonControl2(struct pipes_struct *p,
93 struct netr_LogonControl2 *r)
95 struct netr_LogonControl2Ex l;
97 l.in.logon_server = r->in.logon_server;
98 l.in.function_code = r->in.function_code;
99 l.in.level = r->in.level;
100 l.in.data = r->in.data;
101 l.out.query = r->out.query;
103 return _netr_LogonControl2Ex(p, &l);
106 /*************************************************************************
107 *************************************************************************/
109 static bool wb_change_trust_creds(const char *domain, WERROR *tc_status)
112 struct wbcAuthErrorInfo *error = NULL;
114 result = wbcChangeTrustCredentials(domain, &error);
116 case WBC_ERR_WINBIND_NOT_AVAILABLE:
118 case WBC_ERR_DOMAIN_NOT_FOUND:
119 *tc_status = WERR_NO_SUCH_DOMAIN;
121 case WBC_ERR_SUCCESS:
122 *tc_status = WERR_OK;
128 if (error && error->nt_status != 0) {
129 *tc_status = ntstatus_to_werror(NT_STATUS(error->nt_status));
131 *tc_status = WERR_TRUST_FAILURE;
133 wbcFreeMemory(error);
137 /*************************************************************************
138 *************************************************************************/
140 static bool wb_check_trust_creds(const char *domain, WERROR *tc_status)
143 struct wbcAuthErrorInfo *error = NULL;
145 result = wbcCheckTrustCredentials(domain, &error);
147 case WBC_ERR_WINBIND_NOT_AVAILABLE:
149 case WBC_ERR_DOMAIN_NOT_FOUND:
150 *tc_status = WERR_NO_SUCH_DOMAIN;
152 case WBC_ERR_SUCCESS:
153 *tc_status = WERR_OK;
159 if (error && error->nt_status != 0) {
160 *tc_status = ntstatus_to_werror(NT_STATUS(error->nt_status));
162 *tc_status = WERR_TRUST_FAILURE;
164 wbcFreeMemory(error);
168 /****************************************************************
169 _netr_LogonControl2Ex
170 ****************************************************************/
172 WERROR _netr_LogonControl2Ex(struct pipes_struct *p,
173 struct netr_LogonControl2Ex *r)
175 uint32_t flags = 0x0;
176 WERROR pdc_connection_status = WERR_OK;
177 uint32_t logon_attempts = 0x0;
180 const char *dc_name = NULL;
181 struct sockaddr_storage dc_ss;
182 const char *domain = NULL;
183 struct netr_NETLOGON_INFO_1 *info1;
184 struct netr_NETLOGON_INFO_2 *info2;
185 struct netr_NETLOGON_INFO_3 *info3;
186 struct netr_NETLOGON_INFO_4 *info4;
191 case NDR_NETR_LOGONCONTROL:
192 fn = "_netr_LogonControl";
194 case NDR_NETR_LOGONCONTROL2:
195 fn = "_netr_LogonControl2";
197 case NDR_NETR_LOGONCONTROL2EX:
198 fn = "_netr_LogonControl2Ex";
201 return WERR_INVALID_PARAM;
204 acct_ctrl = p->server_info->info3->base.acct_flags;
206 switch (r->in.function_code) {
207 case NETLOGON_CONTROL_TC_VERIFY:
208 case NETLOGON_CONTROL_CHANGE_PASSWORD:
209 case NETLOGON_CONTROL_REDISCOVER:
210 if ((geteuid() != sec_initial_uid()) &&
211 !nt_token_check_domain_rid(p->server_info->ptok, DOMAIN_RID_ADMINS) &&
212 !nt_token_check_sid(&global_sid_Builtin_Administrators, p->server_info->ptok) &&
213 !(acct_ctrl & (ACB_WSTRUST | ACB_SVRTRUST))) {
214 return WERR_ACCESS_DENIED;
221 tc_status = WERR_NO_SUCH_DOMAIN;
223 switch (r->in.function_code) {
224 case NETLOGON_CONTROL_QUERY:
227 case NETLOGON_CONTROL_REPLICATE:
228 case NETLOGON_CONTROL_SYNCHRONIZE:
229 case NETLOGON_CONTROL_PDC_REPLICATE:
230 case NETLOGON_CONTROL_BACKUP_CHANGE_LOG:
231 case NETLOGON_CONTROL_BREAKPOINT:
232 if (acct_ctrl & ACB_NORMAL) {
233 return WERR_NOT_SUPPORTED;
234 } else if (acct_ctrl & (ACB_WSTRUST | ACB_SVRTRUST)) {
235 return WERR_ACCESS_DENIED;
237 return WERR_ACCESS_DENIED;
239 case NETLOGON_CONTROL_TRUNCATE_LOG:
240 if (acct_ctrl & ACB_NORMAL) {
242 } else if (acct_ctrl & (ACB_WSTRUST | ACB_SVRTRUST)) {
243 return WERR_ACCESS_DENIED;
245 return WERR_ACCESS_DENIED;
248 case NETLOGON_CONTROL_TRANSPORT_NOTIFY:
249 case NETLOGON_CONTROL_FORCE_DNS_REG:
250 case NETLOGON_CONTROL_QUERY_DNS_REG:
251 return WERR_NOT_SUPPORTED;
252 case NETLOGON_CONTROL_FIND_USER:
253 if (!r->in.data || !r->in.data->user) {
254 return WERR_NOT_SUPPORTED;
257 case NETLOGON_CONTROL_SET_DBFLAG:
259 return WERR_NOT_SUPPORTED;
262 case NETLOGON_CONTROL_TC_VERIFY:
263 if (!r->in.data || !r->in.data->domain) {
264 return WERR_NOT_SUPPORTED;
267 if (!wb_check_trust_creds(r->in.data->domain, &tc_status)) {
268 return WERR_NOT_SUPPORTED;
271 case NETLOGON_CONTROL_TC_QUERY:
272 if (!r->in.data || !r->in.data->domain) {
273 return WERR_NOT_SUPPORTED;
276 domain = r->in.data->domain;
278 if (!is_trusted_domain(domain)) {
282 if (!get_dc_name(domain, NULL, dc_name2, &dc_ss)) {
283 tc_status = WERR_NO_LOGON_SERVERS;
287 dc_name = talloc_asprintf(p->mem_ctx, "\\\\%s", dc_name2);
296 case NETLOGON_CONTROL_REDISCOVER:
297 if (!r->in.data || !r->in.data->domain) {
298 return WERR_NOT_SUPPORTED;
301 domain = r->in.data->domain;
303 if (!is_trusted_domain(domain)) {
307 if (!get_dc_name(domain, NULL, dc_name2, &dc_ss)) {
308 tc_status = WERR_NO_LOGON_SERVERS;
312 dc_name = talloc_asprintf(p->mem_ctx, "\\\\%s", dc_name2);
321 case NETLOGON_CONTROL_CHANGE_PASSWORD:
322 if (!r->in.data || !r->in.data->domain) {
323 return WERR_NOT_SUPPORTED;
326 if (!wb_change_trust_creds(r->in.data->domain, &tc_status)) {
327 return WERR_NOT_SUPPORTED;
332 /* no idea what this should be */
333 DEBUG(0,("%s: unimplemented function level [%d]\n",
334 fn, r->in.function_code));
335 return WERR_UNKNOWN_LEVEL;
338 /* prepare the response */
340 switch (r->in.level) {
342 info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1);
343 W_ERROR_HAVE_NO_MEMORY(info1);
345 info1->flags = flags;
346 info1->pdc_connection_status = pdc_connection_status;
348 r->out.query->info1 = info1;
351 info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2);
352 W_ERROR_HAVE_NO_MEMORY(info2);
354 info2->flags = flags;
355 info2->pdc_connection_status = pdc_connection_status;
356 info2->trusted_dc_name = dc_name;
357 info2->tc_connection_status = tc_status;
359 r->out.query->info2 = info2;
362 info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3);
363 W_ERROR_HAVE_NO_MEMORY(info3);
365 info3->flags = flags;
366 info3->logon_attempts = logon_attempts;
368 r->out.query->info3 = info3;
371 info4 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_4);
372 W_ERROR_HAVE_NO_MEMORY(info4);
374 info4->trusted_dc_name = dc_name;
375 info4->trusted_domain_name = r->in.data->domain;
377 r->out.query->info4 = info4;
380 return WERR_UNKNOWN_LEVEL;
383 if (lp_server_role() == ROLE_DOMAIN_BDC) {
384 send_sync_message(p->msg_ctx);
390 /*************************************************************************
391 _netr_NetrEnumerateTrustedDomains
392 *************************************************************************/
394 NTSTATUS _netr_NetrEnumerateTrustedDomains(struct pipes_struct *p,
395 struct netr_NetrEnumerateTrustedDomains *r)
398 NTSTATUS result = NT_STATUS_OK;
401 const char **trusted_domains = NULL;
402 struct lsa_DomainList domain_list;
403 struct dcerpc_binding_handle *h = NULL;
404 struct policy_handle pol;
405 uint32_t enum_ctx = 0;
407 uint32_t max_size = (uint32_t)-1;
409 DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
411 status = rpcint_binding_handle(p->mem_ctx,
417 if (!NT_STATUS_IS_OK(status)) {
421 status = dcerpc_lsa_open_policy2(h,
425 LSA_POLICY_VIEW_LOCAL_INFORMATION,
428 if (!NT_STATUS_IS_OK(status)) {
431 if (!NT_STATUS_IS_OK(result)) {
437 /* Lookup list of trusted domains */
438 status = dcerpc_lsa_EnumTrustDom(h,
445 if (!NT_STATUS_IS_OK(status)) {
448 if (!NT_STATUS_IS_OK(result) &&
449 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
450 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
455 for (i = 0; i < domain_list.count; i++) {
456 if (!add_string_to_array(p->mem_ctx, domain_list.domains[i].name.string,
457 &trusted_domains, &num_domains)) {
458 status = NT_STATUS_NO_MEMORY;
462 } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
464 if (num_domains > 0) {
465 /* multi sz terminate */
466 trusted_domains = talloc_realloc(p->mem_ctx, trusted_domains, const char *, num_domains + 1);
467 if (trusted_domains == NULL) {
468 status = NT_STATUS_NO_MEMORY;
472 trusted_domains[num_domains] = NULL;
475 if (!push_reg_multi_sz(trusted_domains, &blob, trusted_domains)) {
476 TALLOC_FREE(trusted_domains);
477 status = NT_STATUS_NO_MEMORY;
481 r->out.trusted_domains_blob->data = blob.data;
482 r->out.trusted_domains_blob->length = blob.length;
484 DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
486 status = NT_STATUS_OK;
489 if (h && is_valid_policy_hnd(&pol)) {
490 dcerpc_lsa_Close(h, p->mem_ctx, &pol, &result);
496 /*************************************************************************
497 *************************************************************************/
499 static NTSTATUS samr_find_machine_account(TALLOC_CTX *mem_ctx,
500 struct dcerpc_binding_handle *b,
501 const char *account_name,
502 uint32_t access_mask,
503 struct dom_sid2 **domain_sid_p,
504 uint32_t *user_rid_p,
505 struct policy_handle *user_handle)
508 NTSTATUS result = NT_STATUS_OK;
509 struct policy_handle connect_handle, domain_handle;
510 struct lsa_String domain_name;
511 struct dom_sid2 *domain_sid;
512 struct lsa_String names;
513 struct samr_Ids rids;
514 struct samr_Ids types;
517 status = dcerpc_samr_Connect2(b, mem_ctx,
519 SAMR_ACCESS_CONNECT_TO_SERVER |
520 SAMR_ACCESS_ENUM_DOMAINS |
521 SAMR_ACCESS_LOOKUP_DOMAIN,
524 if (!NT_STATUS_IS_OK(status)) {
527 if (!NT_STATUS_IS_OK(result)) {
532 init_lsa_String(&domain_name, get_global_sam_name());
534 status = dcerpc_samr_LookupDomain(b, mem_ctx,
539 if (!NT_STATUS_IS_OK(status)) {
542 if (!NT_STATUS_IS_OK(result)) {
547 status = dcerpc_samr_OpenDomain(b, mem_ctx,
549 SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
553 if (!NT_STATUS_IS_OK(status)) {
556 if (!NT_STATUS_IS_OK(result)) {
561 init_lsa_String(&names, account_name);
563 status = dcerpc_samr_LookupNames(b, mem_ctx,
570 if (!NT_STATUS_IS_OK(status)) {
573 if (!NT_STATUS_IS_OK(result)) {
578 if (rids.count != 1) {
579 status = NT_STATUS_NO_SUCH_USER;
582 if (rids.count != types.count) {
583 status = NT_STATUS_INVALID_PARAMETER;
586 if (types.ids[0] != SID_NAME_USER) {
587 status = NT_STATUS_NO_SUCH_USER;
593 status = dcerpc_samr_OpenUser(b, mem_ctx,
599 if (!NT_STATUS_IS_OK(status)) {
602 if (!NT_STATUS_IS_OK(result)) {
612 *domain_sid_p = domain_sid;
616 if (b && is_valid_policy_hnd(&domain_handle)) {
617 dcerpc_samr_Close(b, mem_ctx, &domain_handle, &result);
619 if (b && is_valid_policy_hnd(&connect_handle)) {
620 dcerpc_samr_Close(b, mem_ctx, &connect_handle, &result);
626 /******************************************************************
627 gets a machine password entry. checks access rights of the host.
628 ******************************************************************/
630 static NTSTATUS get_md4pw(struct samr_Password *md4pw, const char *mach_acct,
631 enum netr_SchannelType sec_chan_type,
633 struct messaging_context *msg_ctx)
636 NTSTATUS result = NT_STATUS_OK;
638 struct dcerpc_binding_handle *h = NULL;
639 static struct client_address client_id;
640 struct policy_handle user_handle;
642 struct dom_sid *domain_sid;
644 union samr_UserInfo *info;
645 struct auth_serversupplied_info *server_info;
649 * Currently this code is redundent as we already have a filter
650 * by hostname list. What this code really needs to do is to
651 * get a hosts allowed/hosts denied list from the SAM database
652 * on a per user basis, and make the access decision there.
653 * I will leave this code here for now as a reminder to implement
654 * this at a later date. JRA.
657 if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(),
659 p->client_id.addr)) {
660 DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct));
665 mem_ctx = talloc_stackframe();
666 if (mem_ctx == NULL) {
667 status = NT_STATUS_NO_MEMORY;
671 status = make_server_info_system(mem_ctx, &server_info);
672 if (!NT_STATUS_IS_OK(status)) {
676 ZERO_STRUCT(user_handle);
678 strlcpy(client_id.addr, "127.0.0.1", sizeof(client_id.addr));
679 client_id.name = "127.0.0.1";
681 status = rpcint_binding_handle(mem_ctx,
687 if (!NT_STATUS_IS_OK(status)) {
692 status = samr_find_machine_account(mem_ctx, h, mach_acct,
693 SEC_FLAG_MAXIMUM_ALLOWED,
694 &domain_sid, &user_rid,
697 if (!NT_STATUS_IS_OK(status)) {
701 status = dcerpc_samr_QueryUserInfo2(h,
704 UserControlInformation,
707 if (!NT_STATUS_IS_OK(status)) {
710 if (!NT_STATUS_IS_OK(result)) {
715 acct_ctrl = info->info16.acct_flags;
717 if (acct_ctrl & ACB_DISABLED) {
718 DEBUG(0,("get_md4pw: Workstation %s: account is disabled\n", mach_acct));
719 status = NT_STATUS_ACCOUNT_DISABLED;
723 if (!(acct_ctrl & ACB_SVRTRUST) &&
724 !(acct_ctrl & ACB_WSTRUST) &&
725 !(acct_ctrl & ACB_DOMTRUST))
727 DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct));
728 status = NT_STATUS_NO_TRUST_SAM_ACCOUNT;
732 switch (sec_chan_type) {
734 if (!(acct_ctrl & ACB_SVRTRUST)) {
735 DEBUG(0,("get_md4pw: Workstation %s: BDC secure channel requested "
736 "but not a server trust account\n", mach_acct));
737 status = NT_STATUS_NO_TRUST_SAM_ACCOUNT;
742 if (!(acct_ctrl & ACB_WSTRUST)) {
743 DEBUG(0,("get_md4pw: Workstation %s: WORKSTATION secure channel requested "
744 "but not a workstation trust account\n", mach_acct));
745 status = NT_STATUS_NO_TRUST_SAM_ACCOUNT;
749 case SEC_CHAN_DOMAIN:
750 if (!(acct_ctrl & ACB_DOMTRUST)) {
751 DEBUG(0,("get_md4pw: Workstation %s: DOMAIN secure channel requested "
752 "but not a interdomain trust account\n", mach_acct));
753 status = NT_STATUS_NO_TRUST_SAM_ACCOUNT;
762 status = dcerpc_samr_QueryUserInfo2(h,
765 UserInternal1Information,
769 if (!NT_STATUS_IS_OK(status)) {
772 if (!NT_STATUS_IS_OK(result)) {
777 if (info->info18.nt_pwd_active == 0) {
778 DEBUG(0,("get_md4pw: Workstation %s: account does not have a password\n", mach_acct));
779 status = NT_STATUS_LOGON_FAILURE;
783 /* samr gives out nthash unencrypted (!) */
784 memcpy(md4pw->hash, info->info18.nt_pwd.hash, 16);
786 sid_compose(sid, domain_sid, user_rid);
789 if (h && is_valid_policy_hnd(&user_handle)) {
790 dcerpc_samr_Close(h, mem_ctx, &user_handle, &result);
793 talloc_free(mem_ctx);
798 /*************************************************************************
799 _netr_ServerReqChallenge
800 *************************************************************************/
802 NTSTATUS _netr_ServerReqChallenge(struct pipes_struct *p,
803 struct netr_ServerReqChallenge *r)
805 struct netlogon_server_pipe_state *pipe_state =
806 talloc_get_type(p->private_data, struct netlogon_server_pipe_state);
809 DEBUG(10,("_netr_ServerReqChallenge: new challenge requested. Clearing old state.\n"));
810 talloc_free(pipe_state);
811 p->private_data = NULL;
814 pipe_state = talloc(p, struct netlogon_server_pipe_state);
815 NT_STATUS_HAVE_NO_MEMORY(pipe_state);
817 pipe_state->client_challenge = *r->in.credentials;
819 generate_random_buffer(pipe_state->server_challenge.data,
820 sizeof(pipe_state->server_challenge.data));
822 *r->out.return_credentials = pipe_state->server_challenge;
824 p->private_data = pipe_state;
829 /*************************************************************************
830 _netr_ServerAuthenticate
831 Create the initial credentials.
832 *************************************************************************/
834 NTSTATUS _netr_ServerAuthenticate(struct pipes_struct *p,
835 struct netr_ServerAuthenticate *r)
837 struct netr_ServerAuthenticate3 a;
838 uint32_t negotiate_flags = 0;
841 a.in.server_name = r->in.server_name;
842 a.in.account_name = r->in.account_name;
843 a.in.secure_channel_type = r->in.secure_channel_type;
844 a.in.computer_name = r->in.computer_name;
845 a.in.credentials = r->in.credentials;
846 a.in.negotiate_flags = &negotiate_flags;
848 a.out.return_credentials = r->out.return_credentials;
850 a.out.negotiate_flags = &negotiate_flags;
852 return _netr_ServerAuthenticate3(p, &a);
856 /*************************************************************************
857 _netr_ServerAuthenticate3
858 *************************************************************************/
860 NTSTATUS _netr_ServerAuthenticate3(struct pipes_struct *p,
861 struct netr_ServerAuthenticate3 *r)
865 /* r->in.negotiate_flags is an aliased pointer to r->out.negotiate_flags,
866 * so use a copy to avoid destroying the client values. */
867 uint32_t in_neg_flags = *r->in.negotiate_flags;
870 struct samr_Password mach_pwd;
871 struct netlogon_creds_CredentialState *creds;
872 struct netlogon_server_pipe_state *pipe_state =
873 talloc_get_type(p->private_data, struct netlogon_server_pipe_state);
875 /* According to Microsoft (see bugid #6099)
876 * Windows 7 looks at the negotiate_flags
877 * returned in this structure *even if the
878 * call fails with access denied* ! So in order
879 * to allow Win7 to connect to a Samba NT style
880 * PDC we set the flags before we know if it's
885 srv_flgs = NETLOGON_NEG_ACCOUNT_LOCKOUT |
886 NETLOGON_NEG_PERSISTENT_SAMREPL |
887 NETLOGON_NEG_ARCFOUR |
888 NETLOGON_NEG_PROMOTION_COUNT |
889 NETLOGON_NEG_CHANGELOG_BDC |
890 NETLOGON_NEG_FULL_SYNC_REPL |
891 NETLOGON_NEG_MULTIPLE_SIDS |
893 NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL |
894 NETLOGON_NEG_PASSWORD_SET2;
896 /* Ensure we support strong (128-bit) keys. */
897 if (in_neg_flags & NETLOGON_NEG_STRONG_KEYS) {
898 srv_flgs |= NETLOGON_NEG_STRONG_KEYS;
901 if (lp_server_schannel() != false) {
902 srv_flgs |= NETLOGON_NEG_SCHANNEL;
906 case NDR_NETR_SERVERAUTHENTICATE:
907 fn = "_netr_ServerAuthenticate";
909 case NDR_NETR_SERVERAUTHENTICATE2:
910 fn = "_netr_ServerAuthenticate2";
912 case NDR_NETR_SERVERAUTHENTICATE3:
913 fn = "_netr_ServerAuthenticate3";
916 return NT_STATUS_INTERNAL_ERROR;
919 /* We use this as the key to store the creds: */
920 /* r->in.computer_name */
923 DEBUG(0,("%s: no challenge sent to client %s\n", fn,
924 r->in.computer_name));
925 status = NT_STATUS_ACCESS_DENIED;
929 if ( (lp_server_schannel() == true) &&
930 ((in_neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) {
932 /* schannel must be used, but client did not offer it. */
933 DEBUG(0,("%s: schannel required but client failed "
934 "to offer it. Client was %s\n",
935 fn, r->in.account_name));
936 status = NT_STATUS_ACCESS_DENIED;
940 status = get_md4pw(&mach_pwd,
942 r->in.secure_channel_type,
944 if (!NT_STATUS_IS_OK(status)) {
945 DEBUG(0,("%s: failed to get machine password for "
947 fn, r->in.account_name, nt_errstr(status) ));
948 /* always return NT_STATUS_ACCESS_DENIED */
949 status = NT_STATUS_ACCESS_DENIED;
953 /* From the client / server challenges and md4 password, generate sess key */
954 /* Check client credentials are valid. */
955 creds = netlogon_creds_server_init(p->mem_ctx,
958 r->in.secure_channel_type,
959 &pipe_state->client_challenge,
960 &pipe_state->server_challenge,
963 r->out.return_credentials,
964 *r->in.negotiate_flags);
966 DEBUG(0,("%s: netlogon_creds_server_check failed. Rejecting auth "
967 "request from client %s machine account %s\n",
968 fn, r->in.computer_name,
969 r->in.account_name));
970 status = NT_STATUS_ACCESS_DENIED;
974 creds->sid = dom_sid_dup(creds, &sid);
976 status = NT_STATUS_NO_MEMORY;
980 /* Store off the state so we can continue after client disconnect. */
982 status = schannel_save_creds_state(p->mem_ctx, lp_private_dir(), creds);
985 if (!NT_STATUS_IS_OK(status)) {
989 sid_peek_rid(&sid, r->out.rid);
991 status = NT_STATUS_OK;
995 *r->out.negotiate_flags = srv_flgs;
999 /*************************************************************************
1000 _netr_ServerAuthenticate2
1001 *************************************************************************/
1003 NTSTATUS _netr_ServerAuthenticate2(struct pipes_struct *p,
1004 struct netr_ServerAuthenticate2 *r)
1006 struct netr_ServerAuthenticate3 a;
1009 a.in.server_name = r->in.server_name;
1010 a.in.account_name = r->in.account_name;
1011 a.in.secure_channel_type = r->in.secure_channel_type;
1012 a.in.computer_name = r->in.computer_name;
1013 a.in.credentials = r->in.credentials;
1014 a.in.negotiate_flags = r->in.negotiate_flags;
1016 a.out.return_credentials = r->out.return_credentials;
1018 a.out.negotiate_flags = r->out.negotiate_flags;
1020 return _netr_ServerAuthenticate3(p, &a);
1023 /*************************************************************************
1024 * If schannel is required for this call test that it actually is available.
1025 *************************************************************************/
1026 static NTSTATUS schannel_check_required(struct pipe_auth_data *auth_info,
1027 const char *computer_name,
1028 bool integrity, bool privacy)
1030 if (auth_info && auth_info->auth_type == DCERPC_AUTH_TYPE_SCHANNEL) {
1031 if (!privacy && !integrity) {
1032 return NT_STATUS_OK;
1035 if ((!privacy && integrity) &&
1036 auth_info->auth_level == DCERPC_AUTH_LEVEL_INTEGRITY) {
1037 return NT_STATUS_OK;
1040 if ((privacy || integrity) &&
1041 auth_info->auth_level == DCERPC_AUTH_LEVEL_PRIVACY) {
1042 return NT_STATUS_OK;
1046 /* test didn't pass */
1047 DEBUG(0, ("schannel_check_required: [%s] is not using schannel\n",
1050 return NT_STATUS_ACCESS_DENIED;
1053 /*************************************************************************
1054 *************************************************************************/
1056 static NTSTATUS netr_creds_server_step_check(struct pipes_struct *p,
1057 TALLOC_CTX *mem_ctx,
1058 const char *computer_name,
1059 struct netr_Authenticator *received_authenticator,
1060 struct netr_Authenticator *return_authenticator,
1061 struct netlogon_creds_CredentialState **creds_out)
1064 bool schannel_global_required = (lp_server_schannel() == true) ? true:false;
1066 if (schannel_global_required) {
1067 status = schannel_check_required(&p->auth,
1070 if (!NT_STATUS_IS_OK(status)) {
1075 status = schannel_check_creds_state(mem_ctx, lp_private_dir(),
1076 computer_name, received_authenticator,
1077 return_authenticator, creds_out);
1082 /*************************************************************************
1083 *************************************************************************/
1085 static NTSTATUS netr_set_machine_account_password(TALLOC_CTX *mem_ctx,
1086 struct auth_serversupplied_info *server_info,
1087 struct messaging_context *msg_ctx,
1088 const char *account_name,
1089 struct samr_Password *nt_hash)
1092 NTSTATUS result = NT_STATUS_OK;
1093 struct dcerpc_binding_handle *h = NULL;
1094 static struct client_address client_id;
1095 struct policy_handle user_handle;
1097 union samr_UserInfo *info;
1098 struct samr_UserInfo18 info18;
1101 ZERO_STRUCT(user_handle);
1103 strlcpy(client_id.addr, "127.0.0.1", sizeof(client_id.addr));
1104 client_id.name = "127.0.0.1";
1106 status = rpcint_binding_handle(mem_ctx,
1112 if (!NT_STATUS_IS_OK(status)) {
1116 status = samr_find_machine_account(mem_ctx,
1119 SEC_FLAG_MAXIMUM_ALLOWED,
1123 if (!NT_STATUS_IS_OK(status)) {
1127 status = dcerpc_samr_QueryUserInfo2(h,
1130 UserControlInformation,
1133 if (!NT_STATUS_IS_OK(status)) {
1136 if (!NT_STATUS_IS_OK(result)) {
1141 acct_ctrl = info->info16.acct_flags;
1143 if (!(acct_ctrl & ACB_WSTRUST ||
1144 acct_ctrl & ACB_SVRTRUST ||
1145 acct_ctrl & ACB_DOMTRUST)) {
1146 status = NT_STATUS_NO_SUCH_USER;
1150 if (acct_ctrl & ACB_DISABLED) {
1151 status = NT_STATUS_ACCOUNT_DISABLED;
1155 ZERO_STRUCT(info18);
1157 in = data_blob_const(nt_hash->hash, 16);
1158 out = data_blob_talloc_zero(mem_ctx, 16);
1159 sess_crypt_blob(&out, &in, &server_info->user_session_key, true);
1160 memcpy(info18.nt_pwd.hash, out.data, out.length);
1162 info18.nt_pwd_active = true;
1164 info->info18 = info18;
1166 status = dcerpc_samr_SetUserInfo2(h,
1169 UserInternal1Information,
1172 if (!NT_STATUS_IS_OK(status)) {
1175 if (!NT_STATUS_IS_OK(result)) {
1181 if (h && is_valid_policy_hnd(&user_handle)) {
1182 dcerpc_samr_Close(h, mem_ctx, &user_handle, &result);
1188 /*************************************************************************
1189 _netr_ServerPasswordSet
1190 *************************************************************************/
1192 NTSTATUS _netr_ServerPasswordSet(struct pipes_struct *p,
1193 struct netr_ServerPasswordSet *r)
1195 NTSTATUS status = NT_STATUS_OK;
1197 struct netlogon_creds_CredentialState *creds;
1199 DEBUG(5,("_netr_ServerPasswordSet: %d\n", __LINE__));
1202 status = netr_creds_server_step_check(p, p->mem_ctx,
1203 r->in.computer_name,
1205 r->out.return_authenticator,
1209 if (!NT_STATUS_IS_OK(status)) {
1210 DEBUG(2,("_netr_ServerPasswordSet: netlogon_creds_server_step failed. Rejecting auth "
1211 "request from client %s machine account %s\n",
1212 r->in.computer_name, creds->computer_name));
1217 DEBUG(3,("_netr_ServerPasswordSet: Server Password Set by remote machine:[%s] on account [%s]\n",
1218 r->in.computer_name, creds->computer_name));
1220 netlogon_creds_des_decrypt(creds, r->in.new_password);
1222 DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n"));
1223 for(i = 0; i < sizeof(r->in.new_password->hash); i++)
1224 DEBUG(100,("%02X ", r->in.new_password->hash[i]));
1227 status = netr_set_machine_account_password(p->mem_ctx,
1230 creds->account_name,
1231 r->in.new_password);
1235 /****************************************************************
1236 _netr_ServerPasswordSet2
1237 ****************************************************************/
1239 NTSTATUS _netr_ServerPasswordSet2(struct pipes_struct *p,
1240 struct netr_ServerPasswordSet2 *r)
1243 struct netlogon_creds_CredentialState *creds;
1244 DATA_BLOB plaintext;
1245 struct samr_CryptPassword password_buf;
1246 struct samr_Password nt_hash;
1249 status = netr_creds_server_step_check(p, p->mem_ctx,
1250 r->in.computer_name,
1252 r->out.return_authenticator,
1256 if (!NT_STATUS_IS_OK(status)) {
1257 DEBUG(2,("_netr_ServerPasswordSet2: netlogon_creds_server_step "
1258 "failed. Rejecting auth request from client %s machine account %s\n",
1259 r->in.computer_name, creds->computer_name));
1264 memcpy(password_buf.data, r->in.new_password->data, 512);
1265 SIVAL(password_buf.data, 512, r->in.new_password->length);
1266 netlogon_creds_arcfour_crypt(creds, password_buf.data, 516);
1268 if (!extract_pw_from_buffer(p->mem_ctx, password_buf.data, &plaintext)) {
1269 return NT_STATUS_WRONG_PASSWORD;
1272 mdfour(nt_hash.hash, plaintext.data, plaintext.length);
1274 status = netr_set_machine_account_password(p->mem_ctx,
1277 creds->account_name,
1282 /*************************************************************************
1283 _netr_LogonSamLogoff
1284 *************************************************************************/
1286 NTSTATUS _netr_LogonSamLogoff(struct pipes_struct *p,
1287 struct netr_LogonSamLogoff *r)
1290 struct netlogon_creds_CredentialState *creds;
1293 status = netr_creds_server_step_check(p, p->mem_ctx,
1294 r->in.computer_name,
1296 r->out.return_authenticator,
1303 /*************************************************************************
1304 _netr_LogonSamLogon_base
1305 *************************************************************************/
1307 static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
1308 struct netr_LogonSamLogonEx *r,
1309 struct netlogon_creds_CredentialState *creds)
1311 NTSTATUS status = NT_STATUS_OK;
1312 union netr_LogonLevel *logon = r->in.logon;
1313 const char *nt_username, *nt_domain, *nt_workstation;
1314 struct auth_usersupplied_info *user_info = NULL;
1315 struct auth_serversupplied_info *server_info = NULL;
1316 struct auth_context *auth_context = NULL;
1317 uint8_t pipe_session_key[16];
1318 bool process_creds = true;
1322 case NDR_NETR_LOGONSAMLOGON:
1323 process_creds = true;
1324 fn = "_netr_LogonSamLogon";
1326 case NDR_NETR_LOGONSAMLOGONWITHFLAGS:
1327 process_creds = true;
1328 fn = "_netr_LogonSamLogonWithFlags";
1330 case NDR_NETR_LOGONSAMLOGONEX:
1331 process_creds = false;
1332 fn = "_netr_LogonSamLogonEx";
1335 return NT_STATUS_INTERNAL_ERROR;
1338 *r->out.authoritative = true; /* authoritative response */
1340 switch (r->in.validation_level) {
1342 r->out.validation->sam2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo2);
1343 if (!r->out.validation->sam2) {
1344 return NT_STATUS_NO_MEMORY;
1348 r->out.validation->sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3);
1349 if (!r->out.validation->sam3) {
1350 return NT_STATUS_NO_MEMORY;
1354 r->out.validation->sam6 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo6);
1355 if (!r->out.validation->sam6) {
1356 return NT_STATUS_NO_MEMORY;
1360 DEBUG(0,("%s: bad validation_level value %d.\n",
1361 fn, (int)r->in.validation_level));
1362 return NT_STATUS_INVALID_INFO_CLASS;
1365 switch (r->in.logon_level) {
1366 case NetlogonInteractiveInformation:
1367 case NetlogonServiceInformation:
1368 case NetlogonInteractiveTransitiveInformation:
1369 case NetlogonServiceTransitiveInformation:
1370 nt_username = logon->password->identity_info.account_name.string ?
1371 logon->password->identity_info.account_name.string : "";
1372 nt_domain = logon->password->identity_info.domain_name.string ?
1373 logon->password->identity_info.domain_name.string : "";
1374 nt_workstation = logon->password->identity_info.workstation.string ?
1375 logon->password->identity_info.workstation.string : "";
1377 DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup()));
1379 case NetlogonNetworkInformation:
1380 case NetlogonNetworkTransitiveInformation:
1381 nt_username = logon->network->identity_info.account_name.string ?
1382 logon->network->identity_info.account_name.string : "";
1383 nt_domain = logon->network->identity_info.domain_name.string ?
1384 logon->network->identity_info.domain_name.string : "";
1385 nt_workstation = logon->network->identity_info.workstation.string ?
1386 logon->network->identity_info.workstation.string : "";
1388 DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup()));
1391 DEBUG(2,("SAM Logon: unsupported switch value\n"));
1392 return NT_STATUS_INVALID_INFO_CLASS;
1395 DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain));
1396 fstrcpy(current_user_info.smb_name, nt_username);
1397 sub_set_smb_name(nt_username);
1399 DEBUG(5,("Attempting validation level %d for unmapped username %s.\n",
1400 r->in.validation_level, nt_username));
1402 status = NT_STATUS_OK;
1404 switch (r->in.logon_level) {
1405 case NetlogonNetworkInformation:
1406 case NetlogonNetworkTransitiveInformation:
1408 const char *wksname = nt_workstation;
1410 status = make_auth_context_fixed(talloc_tos(), &auth_context,
1411 logon->network->challenge);
1412 if (!NT_STATUS_IS_OK(status)) {
1416 /* For a network logon, the workstation name comes in with two
1417 * backslashes in the front. Strip them if they are there. */
1419 if (*wksname == '\\') wksname++;
1420 if (*wksname == '\\') wksname++;
1422 /* Standard challenge/response authenticaion */
1423 if (!make_user_info_netlogon_network(&user_info,
1424 nt_username, nt_domain,
1426 logon->network->identity_info.parameter_control,
1427 logon->network->lm.data,
1428 logon->network->lm.length,
1429 logon->network->nt.data,
1430 logon->network->nt.length)) {
1431 status = NT_STATUS_NO_MEMORY;
1435 case NetlogonInteractiveInformation:
1436 case NetlogonServiceInformation:
1437 case NetlogonInteractiveTransitiveInformation:
1438 case NetlogonServiceTransitiveInformation:
1440 /* 'Interactive' authentication, supplies the password in its
1441 MD4 form, encrypted with the session key. We will convert
1442 this to challenge/response for the auth subsystem to chew
1447 status = make_auth_context_subsystem(talloc_tos(),
1449 if (!NT_STATUS_IS_OK(status)) {
1453 auth_context->get_ntlm_challenge(auth_context, chal);
1455 if (!make_user_info_netlogon_interactive(&user_info,
1456 nt_username, nt_domain,
1458 logon->password->identity_info.parameter_control,
1460 logon->password->lmpassword.hash,
1461 logon->password->ntpassword.hash,
1462 creds->session_key)) {
1463 status = NT_STATUS_NO_MEMORY;
1468 DEBUG(2,("SAM Logon: unsupported switch value\n"));
1469 return NT_STATUS_INVALID_INFO_CLASS;
1472 if ( NT_STATUS_IS_OK(status) ) {
1473 status = auth_context->check_ntlm_password(auth_context,
1474 user_info, &server_info);
1477 TALLOC_FREE(auth_context);
1478 free_user_info(&user_info);
1480 DEBUG(5,("%s: check_password returned status %s\n",
1481 fn, nt_errstr(status)));
1483 /* Check account and password */
1485 if (!NT_STATUS_IS_OK(status)) {
1486 /* If we don't know what this domain is, we need to
1487 indicate that we are not authoritative. This
1488 allows the client to decide if it needs to try
1489 a local user. Fix by jpjanosi@us.ibm.com, #2976 */
1490 if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)
1491 && !strequal(nt_domain, get_global_sam_name())
1492 && !is_trusted_domain(nt_domain) )
1493 *r->out.authoritative = false; /* We are not authoritative */
1495 TALLOC_FREE(server_info);
1499 if (server_info->guest) {
1500 /* We don't like guest domain logons... */
1501 DEBUG(5,("%s: Attempted domain logon as GUEST "
1503 TALLOC_FREE(server_info);
1504 return NT_STATUS_LOGON_FAILURE;
1507 /* This is the point at which, if the login was successful, that
1508 the SAM Local Security Authority should record that the user is
1509 logged in to the domain. */
1511 if (process_creds) {
1512 /* Get the pipe session key from the creds. */
1513 memcpy(pipe_session_key, creds->session_key, 16);
1515 struct schannel_state *schannel_auth;
1516 /* Get the pipe session key from the schannel. */
1517 if ((p->auth.auth_type != DCERPC_AUTH_TYPE_SCHANNEL)
1518 || (p->auth.auth_ctx == NULL)) {
1519 return NT_STATUS_INVALID_HANDLE;
1522 schannel_auth = talloc_get_type_abort(p->auth.auth_ctx,
1523 struct schannel_state);
1524 memcpy(pipe_session_key, schannel_auth->creds->session_key, 16);
1527 switch (r->in.validation_level) {
1529 status = serverinfo_to_SamInfo2(server_info, pipe_session_key, 16,
1530 r->out.validation->sam2);
1533 status = serverinfo_to_SamInfo3(server_info, pipe_session_key, 16,
1534 r->out.validation->sam3);
1537 status = serverinfo_to_SamInfo6(server_info, pipe_session_key, 16,
1538 r->out.validation->sam6);
1542 TALLOC_FREE(server_info);
1547 /****************************************************************
1548 _netr_LogonSamLogonWithFlags
1549 ****************************************************************/
1551 NTSTATUS _netr_LogonSamLogonWithFlags(struct pipes_struct *p,
1552 struct netr_LogonSamLogonWithFlags *r)
1555 struct netlogon_creds_CredentialState *creds;
1556 struct netr_LogonSamLogonEx r2;
1557 struct netr_Authenticator return_authenticator;
1560 status = netr_creds_server_step_check(p, p->mem_ctx,
1561 r->in.computer_name,
1563 &return_authenticator,
1566 if (!NT_STATUS_IS_OK(status)) {
1570 r2.in.server_name = r->in.server_name;
1571 r2.in.computer_name = r->in.computer_name;
1572 r2.in.logon_level = r->in.logon_level;
1573 r2.in.logon = r->in.logon;
1574 r2.in.validation_level = r->in.validation_level;
1575 r2.in.flags = r->in.flags;
1576 r2.out.validation = r->out.validation;
1577 r2.out.authoritative = r->out.authoritative;
1578 r2.out.flags = r->out.flags;
1580 status = _netr_LogonSamLogon_base(p, &r2, creds);
1582 *r->out.return_authenticator = return_authenticator;
1587 /*************************************************************************
1589 *************************************************************************/
1591 NTSTATUS _netr_LogonSamLogon(struct pipes_struct *p,
1592 struct netr_LogonSamLogon *r)
1595 struct netr_LogonSamLogonWithFlags r2;
1598 r2.in.server_name = r->in.server_name;
1599 r2.in.computer_name = r->in.computer_name;
1600 r2.in.credential = r->in.credential;
1601 r2.in.logon_level = r->in.logon_level;
1602 r2.in.logon = r->in.logon;
1603 r2.in.validation_level = r->in.validation_level;
1604 r2.in.return_authenticator = r->in.return_authenticator;
1605 r2.in.flags = &flags;
1606 r2.out.validation = r->out.validation;
1607 r2.out.authoritative = r->out.authoritative;
1608 r2.out.flags = &flags;
1609 r2.out.return_authenticator = r->out.return_authenticator;
1611 status = _netr_LogonSamLogonWithFlags(p, &r2);
1616 /*************************************************************************
1617 _netr_LogonSamLogonEx
1618 - no credential chaining. Map into net sam logon.
1619 *************************************************************************/
1621 NTSTATUS _netr_LogonSamLogonEx(struct pipes_struct *p,
1622 struct netr_LogonSamLogonEx *r)
1625 struct netlogon_creds_CredentialState *creds = NULL;
1628 status = schannel_get_creds_state(p->mem_ctx, lp_private_dir(),
1629 r->in.computer_name, &creds);
1631 if (!NT_STATUS_IS_OK(status)) {
1635 /* Only allow this if the pipe is protected. */
1636 if (p->auth.auth_type != DCERPC_AUTH_TYPE_SCHANNEL) {
1637 DEBUG(0,("_netr_LogonSamLogonEx: client %s not using schannel for netlogon\n",
1638 get_remote_machine_name() ));
1639 return NT_STATUS_INVALID_PARAMETER;
1642 status = _netr_LogonSamLogon_base(p, r, creds);
1648 /*************************************************************************
1650 *************************************************************************/
1651 #if 0 /* JERRY -- not correct */
1652 NTSTATUS _ds_enum_dom_trusts(struct pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u,
1653 DS_R_ENUM_DOM_TRUSTS *r_u)
1655 NTSTATUS status = NT_STATUS_OK;
1657 /* TODO: According to MSDN, the can only be executed against a
1658 DC or domain member running Windows 2000 or later. Need
1659 to test against a standalone 2k server and see what it
1660 does. A windows 2000 DC includes its own domain in the
1668 /****************************************************************
1669 ****************************************************************/
1671 WERROR _netr_LogonUasLogon(struct pipes_struct *p,
1672 struct netr_LogonUasLogon *r)
1674 p->rng_fault_state = true;
1675 return WERR_NOT_SUPPORTED;
1678 /****************************************************************
1679 ****************************************************************/
1681 WERROR _netr_LogonUasLogoff(struct pipes_struct *p,
1682 struct netr_LogonUasLogoff *r)
1684 p->rng_fault_state = true;
1685 return WERR_NOT_SUPPORTED;
1688 /****************************************************************
1689 ****************************************************************/
1691 NTSTATUS _netr_DatabaseDeltas(struct pipes_struct *p,
1692 struct netr_DatabaseDeltas *r)
1694 p->rng_fault_state = true;
1695 return NT_STATUS_NOT_IMPLEMENTED;
1698 /****************************************************************
1699 ****************************************************************/
1701 NTSTATUS _netr_DatabaseSync(struct pipes_struct *p,
1702 struct netr_DatabaseSync *r)
1704 p->rng_fault_state = true;
1705 return NT_STATUS_NOT_IMPLEMENTED;
1708 /****************************************************************
1709 ****************************************************************/
1711 NTSTATUS _netr_AccountDeltas(struct pipes_struct *p,
1712 struct netr_AccountDeltas *r)
1714 p->rng_fault_state = true;
1715 return NT_STATUS_NOT_IMPLEMENTED;
1718 /****************************************************************
1719 ****************************************************************/
1721 NTSTATUS _netr_AccountSync(struct pipes_struct *p,
1722 struct netr_AccountSync *r)
1724 p->rng_fault_state = true;
1725 return NT_STATUS_NOT_IMPLEMENTED;
1728 /****************************************************************
1729 ****************************************************************/
1731 static bool wb_getdcname(TALLOC_CTX *mem_ctx,
1733 const char **dcname,
1738 struct wbcDomainControllerInfo *dc_info = NULL;
1740 result = wbcLookupDomainController(domain,
1744 case WBC_ERR_SUCCESS:
1746 case WBC_ERR_WINBIND_NOT_AVAILABLE:
1748 case WBC_ERR_DOMAIN_NOT_FOUND:
1749 *werr = WERR_NO_SUCH_DOMAIN;
1752 *werr = WERR_DOMAIN_CONTROLLER_NOT_FOUND;
1756 *dcname = talloc_strdup(mem_ctx, dc_info->dc_name);
1757 wbcFreeMemory(dc_info);
1768 /****************************************************************
1770 ****************************************************************/
1772 WERROR _netr_GetDcName(struct pipes_struct *p,
1773 struct netr_GetDcName *r)
1778 struct netr_DsRGetDCNameInfo *info;
1781 ret = wb_getdcname(p->mem_ctx,
1784 WBC_LOOKUP_DC_IS_FLAT_NAME |
1785 WBC_LOOKUP_DC_RETURN_FLAT_NAME |
1786 WBC_LOOKUP_DC_PDC_REQUIRED,
1792 flags = DS_PDC_REQUIRED | DS_IS_FLAT_NAME | DS_RETURN_FLAT_NAME;
1794 status = dsgetdcname(p->mem_ctx,
1801 if (!NT_STATUS_IS_OK(status)) {
1802 return ntstatus_to_werror(status);
1805 *r->out.dcname = talloc_strdup(p->mem_ctx, info->dc_unc);
1807 if (!*r->out.dcname) {
1814 /****************************************************************
1816 ****************************************************************/
1818 WERROR _netr_GetAnyDCName(struct pipes_struct *p,
1819 struct netr_GetAnyDCName *r)
1824 struct netr_DsRGetDCNameInfo *info;
1827 ret = wb_getdcname(p->mem_ctx,
1830 WBC_LOOKUP_DC_IS_FLAT_NAME |
1831 WBC_LOOKUP_DC_RETURN_FLAT_NAME,
1837 flags = DS_IS_FLAT_NAME | DS_RETURN_FLAT_NAME;
1839 status = dsgetdcname(p->mem_ctx,
1846 if (!NT_STATUS_IS_OK(status)) {
1847 return ntstatus_to_werror(status);
1850 *r->out.dcname = talloc_strdup(p->mem_ctx, info->dc_unc);
1852 if (!*r->out.dcname) {
1859 /****************************************************************
1860 ****************************************************************/
1862 NTSTATUS _netr_DatabaseSync2(struct pipes_struct *p,
1863 struct netr_DatabaseSync2 *r)
1865 p->rng_fault_state = true;
1866 return NT_STATUS_NOT_IMPLEMENTED;
1869 /****************************************************************
1870 ****************************************************************/
1872 NTSTATUS _netr_DatabaseRedo(struct pipes_struct *p,
1873 struct netr_DatabaseRedo *r)
1875 p->rng_fault_state = true;
1876 return NT_STATUS_NOT_IMPLEMENTED;
1879 /****************************************************************
1880 ****************************************************************/
1882 WERROR _netr_DsRGetDCName(struct pipes_struct *p,
1883 struct netr_DsRGetDCName *r)
1885 p->rng_fault_state = true;
1886 return WERR_NOT_SUPPORTED;
1889 /****************************************************************
1890 ****************************************************************/
1892 NTSTATUS _netr_LogonGetCapabilities(struct pipes_struct *p,
1893 struct netr_LogonGetCapabilities *r)
1895 return NT_STATUS_NOT_IMPLEMENTED;
1898 /****************************************************************
1899 ****************************************************************/
1901 WERROR _netr_NETRLOGONSETSERVICEBITS(struct pipes_struct *p,
1902 struct netr_NETRLOGONSETSERVICEBITS *r)
1904 p->rng_fault_state = true;
1905 return WERR_NOT_SUPPORTED;
1908 /****************************************************************
1909 ****************************************************************/
1911 WERROR _netr_LogonGetTrustRid(struct pipes_struct *p,
1912 struct netr_LogonGetTrustRid *r)
1914 p->rng_fault_state = true;
1915 return WERR_NOT_SUPPORTED;
1918 /****************************************************************
1919 ****************************************************************/
1921 WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(struct pipes_struct *p,
1922 struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
1924 p->rng_fault_state = true;
1925 return WERR_NOT_SUPPORTED;
1928 /****************************************************************
1929 ****************************************************************/
1931 WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(struct pipes_struct *p,
1932 struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
1934 p->rng_fault_state = true;
1935 return WERR_NOT_SUPPORTED;
1938 /****************************************************************
1939 ****************************************************************/
1941 WERROR _netr_DsRGetDCNameEx(struct pipes_struct *p,
1942 struct netr_DsRGetDCNameEx *r)
1944 p->rng_fault_state = true;
1945 return WERR_NOT_SUPPORTED;
1948 /****************************************************************
1949 ****************************************************************/
1951 WERROR _netr_DsRGetSiteName(struct pipes_struct *p,
1952 struct netr_DsRGetSiteName *r)
1954 p->rng_fault_state = true;
1955 return WERR_NOT_SUPPORTED;
1958 /****************************************************************
1959 ****************************************************************/
1961 NTSTATUS _netr_LogonGetDomainInfo(struct pipes_struct *p,
1962 struct netr_LogonGetDomainInfo *r)
1964 p->rng_fault_state = true;
1965 return NT_STATUS_NOT_IMPLEMENTED;
1968 /****************************************************************
1969 ****************************************************************/
1971 WERROR _netr_ServerPasswordGet(struct pipes_struct *p,
1972 struct netr_ServerPasswordGet *r)
1974 p->rng_fault_state = true;
1975 return WERR_NOT_SUPPORTED;
1978 /****************************************************************
1979 ****************************************************************/
1981 WERROR _netr_NETRLOGONSENDTOSAM(struct pipes_struct *p,
1982 struct netr_NETRLOGONSENDTOSAM *r)
1984 p->rng_fault_state = true;
1985 return WERR_NOT_SUPPORTED;
1988 /****************************************************************
1989 ****************************************************************/
1991 WERROR _netr_DsRAddressToSitenamesW(struct pipes_struct *p,
1992 struct netr_DsRAddressToSitenamesW *r)
1994 p->rng_fault_state = true;
1995 return WERR_NOT_SUPPORTED;
1998 /****************************************************************
1999 ****************************************************************/
2001 WERROR _netr_DsRGetDCNameEx2(struct pipes_struct *p,
2002 struct netr_DsRGetDCNameEx2 *r)
2004 p->rng_fault_state = true;
2005 return WERR_NOT_SUPPORTED;
2008 /****************************************************************
2009 ****************************************************************/
2011 WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(struct pipes_struct *p,
2012 struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
2014 p->rng_fault_state = true;
2015 return WERR_NOT_SUPPORTED;
2018 /****************************************************************
2019 ****************************************************************/
2021 WERROR _netr_NetrEnumerateTrustedDomainsEx(struct pipes_struct *p,
2022 struct netr_NetrEnumerateTrustedDomainsEx *r)
2024 p->rng_fault_state = true;
2025 return WERR_NOT_SUPPORTED;
2028 /****************************************************************
2029 ****************************************************************/
2031 WERROR _netr_DsRAddressToSitenamesExW(struct pipes_struct *p,
2032 struct netr_DsRAddressToSitenamesExW *r)
2034 p->rng_fault_state = true;
2035 return WERR_NOT_SUPPORTED;
2038 /****************************************************************
2039 ****************************************************************/
2041 WERROR _netr_DsrGetDcSiteCoverageW(struct pipes_struct *p,
2042 struct netr_DsrGetDcSiteCoverageW *r)
2044 p->rng_fault_state = true;
2045 return WERR_NOT_SUPPORTED;
2048 /****************************************************************
2049 ****************************************************************/
2051 WERROR _netr_DsrEnumerateDomainTrusts(struct pipes_struct *p,
2052 struct netr_DsrEnumerateDomainTrusts *r)
2054 p->rng_fault_state = true;
2055 return WERR_NOT_SUPPORTED;
2058 /****************************************************************
2059 ****************************************************************/
2061 WERROR _netr_DsrDeregisterDNSHostRecords(struct pipes_struct *p,
2062 struct netr_DsrDeregisterDNSHostRecords *r)
2064 p->rng_fault_state = true;
2065 return WERR_NOT_SUPPORTED;
2068 /****************************************************************
2069 ****************************************************************/
2071 NTSTATUS _netr_ServerTrustPasswordsGet(struct pipes_struct *p,
2072 struct netr_ServerTrustPasswordsGet *r)
2074 p->rng_fault_state = true;
2075 return NT_STATUS_NOT_IMPLEMENTED;
2078 /****************************************************************
2079 ****************************************************************/
2081 WERROR _netr_DsRGetForestTrustInformation(struct pipes_struct *p,
2082 struct netr_DsRGetForestTrustInformation *r)
2084 p->rng_fault_state = true;
2085 return WERR_NOT_SUPPORTED;
2088 /****************************************************************
2089 ****************************************************************/
2091 NTSTATUS _netr_GetForestTrustInformation(struct pipes_struct *p,
2092 struct netr_GetForestTrustInformation *r)
2094 p->rng_fault_state = true;
2095 return NT_STATUS_NOT_IMPLEMENTED;
2098 /****************************************************************
2099 ****************************************************************/
2101 NTSTATUS _netr_ServerGetTrustInfo(struct pipes_struct *p,
2102 struct netr_ServerGetTrustInfo *r)
2104 p->rng_fault_state = true;
2105 return NT_STATUS_NOT_IMPLEMENTED;
2108 /****************************************************************
2109 ****************************************************************/
2111 NTSTATUS _netr_Unused47(struct pipes_struct *p,
2112 struct netr_Unused47 *r)
2114 p->rng_fault_state = true;
2115 return NT_STATUS_NOT_IMPLEMENTED;
2118 /****************************************************************
2119 ****************************************************************/
2121 NTSTATUS _netr_DsrUpdateReadOnlyServerDnsRecords(struct pipes_struct *p,
2122 struct netr_DsrUpdateReadOnlyServerDnsRecords *r)
2124 p->rng_fault_state = true;
2125 return NT_STATUS_NOT_IMPLEMENTED;