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 2001, 2006.
8 * Copyright (C) Rafal Szczesniak 2002,
9 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002,
10 * Copyright (C) Simo Sorce 2003.
11 * Copyright (C) Gerald (Jerry) Carter 2005.
12 * Copyright (C) Volker Lendecke 2005.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /* This is the implementation of the lsa server code. */
34 #define DBGC_CLASS DBGC_RPC_SRV
43 struct generic_mapping lsa_generic_mapping = {
50 /*******************************************************************
51 Function to free the per handle data.
52 ********************************************************************/
54 static void free_lsa_info(void *ptr)
56 struct lsa_info *lsa = (struct lsa_info *)ptr;
61 /***************************************************************************
63 ***************************************************************************/
65 static void init_dom_query_3(DOM_QUERY_3 *d_q, const char *dom_name, DOM_SID *dom_sid)
67 d_q->buffer_dom_name = (dom_name != NULL) ? 1 : 0; /* domain buffer pointer */
68 d_q->buffer_dom_sid = (dom_sid != NULL) ? 1 : 0; /* domain sid pointer */
70 /* this string is supposed to be non-null terminated. */
71 /* But the maxlen in this UNISTR2 must include the terminating null. */
72 init_unistr2(&d_q->uni_domain_name, dom_name, UNI_BROKEN_NON_NULL);
75 * I'm not sure why this really odd combination of length
76 * values works, but it does appear to. I need to look at
77 * this *much* more closely - but at the moment leave alone
78 * until it's understood. This allows a W2k client to join
79 * a domain with both odd and even length names... JRA.
84 * The two fields below probably are reversed in meaning, ie.
85 * the first field is probably the str_len, the second the max
86 * len. Both are measured in bytes anyway.
89 d_q->uni_dom_str_len = d_q->uni_domain_name.uni_max_len * 2;
90 d_q->uni_dom_max_len = d_q->uni_domain_name.uni_str_len * 2;
93 init_dom_sid2(&d_q->dom_sid, dom_sid);
96 /***************************************************************************
98 ***************************************************************************/
100 static void init_dom_query_5(DOM_QUERY_5 *d_q, const char *dom_name, DOM_SID *dom_sid)
102 init_dom_query_3(d_q, dom_name, dom_sid);
105 /***************************************************************************
106 init_dom_ref - adds a domain if it's not already in, returns the index.
107 ***************************************************************************/
109 static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid)
113 if (dom_name != NULL) {
114 for (num = 0; num < ref->num_ref_doms_1; num++) {
115 if (sid_equal(dom_sid, &ref->ref_dom[num].ref_dom.sid))
119 num = ref->num_ref_doms_1;
122 if (num >= MAX_REF_DOMAINS) {
123 /* index not found, already at maximum domain limit */
127 ref->num_ref_doms_1 = num+1;
128 ref->ptr_ref_dom = 1;
129 ref->max_entries = MAX_REF_DOMAINS;
130 ref->num_ref_doms_2 = num+1;
132 ref->hdr_ref_dom[num].ptr_dom_sid = 1; /* dom sid cannot be NULL. */
134 init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE);
135 init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name);
137 init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid );
142 /***************************************************************************
143 lookup_lsa_rids. Must be called as root for lookup_name to work.
144 ***************************************************************************/
146 static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx,
152 uint32 *pmapped_count)
154 uint32 mapped_count, i;
156 SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
161 for (i = 0; i < num_entries; i++) {
167 enum lsa_SidType type = SID_NAME_UNKNOWN;
169 /* Split name into domain and user component */
171 full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]);
172 if (full_name == NULL) {
173 DEBUG(0, ("pull_ucs2_talloc failed\n"));
174 return NT_STATUS_NO_MEMORY;
177 DEBUG(5, ("lookup_lsa_rids: looking up name %s\n", full_name));
179 /* We can ignore the result of lookup_name, it will not touch
180 "type" if it's not successful */
182 lookup_name(mem_ctx, full_name, flags, &domain, NULL,
187 case SID_NAME_DOM_GRP:
188 case SID_NAME_DOMAIN:
190 case SID_NAME_WKN_GRP:
191 DEBUG(5, ("init_lsa_rids: %s found\n", full_name));
192 /* Leave these unchanged */
195 /* Don't hand out anything but the list above */
196 DEBUG(5, ("init_lsa_rids: %s not found\n", full_name));
197 type = SID_NAME_UNKNOWN;
204 if (type != SID_NAME_UNKNOWN) {
205 sid_split_rid(&sid, &rid);
206 dom_idx = init_dom_ref(ref, domain, &sid);
210 init_dom_rid(&prid[i], rid, type, dom_idx);
213 *pmapped_count = mapped_count;
217 /***************************************************************************
218 lookup_lsa_sids. Must be called as root for lookup_name to work.
219 ***************************************************************************/
221 static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx,
223 LSA_TRANSLATED_SID3 *trans_sids,
227 uint32 *pmapped_count)
229 uint32 mapped_count, i;
231 SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
236 for (i = 0; i < num_entries; i++) {
242 enum lsa_SidType type = SID_NAME_UNKNOWN;
244 /* Split name into domain and user component */
246 full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]);
247 if (full_name == NULL) {
248 DEBUG(0, ("pull_ucs2_talloc failed\n"));
249 return NT_STATUS_NO_MEMORY;
252 DEBUG(5, ("init_lsa_sids: looking up name %s\n", full_name));
254 /* We can ignore the result of lookup_name, it will not touch
255 "type" if it's not successful */
257 lookup_name(mem_ctx, full_name, flags, &domain, NULL,
262 case SID_NAME_DOM_GRP:
263 case SID_NAME_DOMAIN:
265 case SID_NAME_WKN_GRP:
266 DEBUG(5, ("init_lsa_sids: %s found\n", full_name));
267 /* Leave these unchanged */
270 /* Don't hand out anything but the list above */
271 DEBUG(5, ("init_lsa_sids: %s not found\n", full_name));
272 type = SID_NAME_UNKNOWN;
279 if (type != SID_NAME_UNKNOWN) {
281 sid_copy(&domain_sid, &sid);
282 sid_split_rid(&domain_sid, &rid);
283 dom_idx = init_dom_ref(ref, domain, &domain_sid);
287 /* Initialize the LSA_TRANSLATED_SID3 return. */
288 trans_sids[i].sid_type = type;
289 trans_sids[i].sid2 = TALLOC_P(mem_ctx, DOM_SID2);
290 if (trans_sids[i].sid2 == NULL) {
291 return NT_STATUS_NO_MEMORY;
293 init_dom_sid2(trans_sids[i].sid2, &sid);
294 trans_sids[i].sid_idx = dom_idx;
297 *pmapped_count = mapped_count;
301 /***************************************************************************
302 init_reply_lookup_names
303 ***************************************************************************/
305 static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
306 DOM_R_REF *ref, uint32 num_entries,
307 DOM_RID *rid, uint32 mapped_count)
309 r_l->ptr_dom_ref = 1;
312 r_l->num_entries = num_entries;
313 r_l->ptr_entries = 1;
314 r_l->num_entries2 = num_entries;
317 r_l->mapped_count = mapped_count;
320 /***************************************************************************
321 init_reply_lookup_names2
322 ***************************************************************************/
324 static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l,
325 DOM_R_REF *ref, uint32 num_entries,
326 DOM_RID2 *rid, uint32 mapped_count)
328 r_l->ptr_dom_ref = 1;
331 r_l->num_entries = num_entries;
332 r_l->ptr_entries = 1;
333 r_l->num_entries2 = num_entries;
336 r_l->mapped_count = mapped_count;
339 /***************************************************************************
340 init_reply_lookup_names3
341 ***************************************************************************/
343 static void init_reply_lookup_names3(LSA_R_LOOKUP_NAMES3 *r_l,
344 DOM_R_REF *ref, uint32 num_entries,
345 LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count)
347 r_l->ptr_dom_ref = 1;
350 r_l->num_entries = num_entries;
351 r_l->ptr_entries = 1;
352 r_l->num_entries2 = num_entries;
353 r_l->trans_sids = trans_sids;
355 r_l->mapped_count = mapped_count;
358 /***************************************************************************
359 init_reply_lookup_names4
360 ***************************************************************************/
362 static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l,
363 DOM_R_REF *ref, uint32 num_entries,
364 LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count)
366 r_l->ptr_dom_ref = 1;
369 r_l->num_entries = num_entries;
370 r_l->ptr_entries = 1;
371 r_l->num_entries2 = num_entries;
372 r_l->trans_sids = trans_sids;
374 r_l->mapped_count = mapped_count;
377 /***************************************************************************
378 Init_reply_lookup_sids.
379 ***************************************************************************/
381 static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l,
385 r_l->ptr_dom_ref = ref ? 1 : 0;
387 r_l->mapped_count = mapped_count;
390 /***************************************************************************
391 Init_reply_lookup_sids.
392 ***************************************************************************/
394 static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l,
398 r_l->ptr_dom_ref = ref ? 1 : 0;
400 r_l->mapped_count = mapped_count;
403 /***************************************************************************
404 Init_reply_lookup_sids.
405 ***************************************************************************/
407 static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx,
408 LSA_R_LOOKUP_SIDS *r_l,
410 LSA_TRANS_NAME_ENUM2 *names,
413 LSA_TRANS_NAME_ENUM *oldnames = &r_l->names;
415 oldnames->num_entries = names->num_entries;
416 oldnames->ptr_trans_names = names->ptr_trans_names;
417 oldnames->num_entries2 = names->num_entries2;
418 oldnames->uni_name = names->uni_name;
420 if (names->num_entries) {
423 oldnames->name = TALLOC_ARRAY(mem_ctx, LSA_TRANS_NAME, names->num_entries);
425 if (!oldnames->name) {
426 return NT_STATUS_NO_MEMORY;
428 for (i = 0; i < names->num_entries; i++) {
429 oldnames->name[i].sid_name_use = names->name[i].sid_name_use;
430 oldnames->name[i].hdr_name = names->name[i].hdr_name;
431 oldnames->name[i].domain_idx = names->name[i].domain_idx;
435 r_l->ptr_dom_ref = ref ? 1 : 0;
437 r_l->mapped_count = mapped_count;
441 static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size)
443 DOM_SID local_adm_sid;
451 init_sec_access(&mask, POLICY_EXECUTE);
452 init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
454 sid_copy(&adm_sid, get_global_sam_sid());
455 sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS);
456 init_sec_access(&mask, POLICY_ALL_ACCESS);
457 init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
459 sid_copy(&local_adm_sid, &global_sid_Builtin);
460 sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS);
461 init_sec_access(&mask, POLICY_ALL_ACCESS);
462 init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
464 if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL)
465 return NT_STATUS_NO_MEMORY;
467 if((*sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL, psa, sd_size)) == NULL)
468 return NT_STATUS_NO_MEMORY;
473 #if 0 /* AD DC work in ongoing in Samba 4 */
475 /***************************************************************************
477 ***************************************************************************/
479 static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name,
480 const char *dns_name, const char *forest_name,
481 struct GUID *dom_guid, DOM_SID *dom_sid)
483 if (nb_name && *nb_name) {
484 init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE);
485 init_uni_hdr(&r_l->hdr_nb_dom_name, &r_l->uni_nb_dom_name);
486 r_l->hdr_nb_dom_name.uni_max_len += 2;
487 r_l->uni_nb_dom_name.uni_max_len += 1;
490 if (dns_name && *dns_name) {
491 init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE);
492 init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name);
493 r_l->hdr_dns_dom_name.uni_max_len += 2;
494 r_l->uni_dns_dom_name.uni_max_len += 1;
497 if (forest_name && *forest_name) {
498 init_unistr2(&r_l->uni_forest_name, forest_name, UNI_FLAGS_NONE);
499 init_uni_hdr(&r_l->hdr_forest_name, &r_l->uni_forest_name);
500 r_l->hdr_forest_name.uni_max_len += 2;
501 r_l->uni_forest_name.uni_max_len += 1;
504 /* how do we init the guid ? probably should write an init fn */
506 memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID));
510 r_l->ptr_dom_sid = 1;
511 init_dom_sid2(&r_l->dom_sid, dom_sid);
514 #endif /* AD DC work in ongoing in Samba 4 */
517 /***************************************************************************
519 ***************************************************************************/
521 NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u)
523 struct lsa_info *info;
524 SEC_DESC *psd = NULL;
526 uint32 des_access=q_u->des_access;
531 /* map the generic bits to the lsa policy ones */
532 se_map_generic(&des_access, &lsa_generic_mapping);
534 /* get the generic lsa policy SD until we store it */
535 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
537 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
538 if (p->pipe_user.ut.uid != sec_initial_uid()) {
541 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
542 acc_granted, des_access));
543 DEBUGADD(4,("but overwritten by euid == 0\n"));
546 /* This is needed for lsa_open_account and rpcclient .... :-) */
548 if (p->pipe_user.ut.uid == sec_initial_uid())
549 acc_granted = POLICY_ALL_ACCESS;
551 /* associate the domain SID with the (unique) handle. */
552 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
553 return NT_STATUS_NO_MEMORY;
556 sid_copy(&info->sid,get_global_sam_sid());
557 info->access = acc_granted;
559 /* set up the LSA QUERY INFO response */
560 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
561 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
566 /***************************************************************************
568 ***************************************************************************/
570 NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u)
572 struct lsa_info *info;
573 SEC_DESC *psd = NULL;
575 uint32 des_access=q_u->des_access;
580 /* map the generic bits to the lsa policy ones */
581 se_map_generic(&des_access, &lsa_generic_mapping);
583 /* get the generic lsa policy SD until we store it */
584 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
586 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
587 if (geteuid() != 0) {
590 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
591 acc_granted, des_access));
592 DEBUGADD(4,("but overwritten by euid == 0\n"));
593 acc_granted = des_access;
596 /* associate the domain SID with the (unique) handle. */
597 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
598 return NT_STATUS_NO_MEMORY;
601 sid_copy(&info->sid,get_global_sam_sid());
602 info->access = acc_granted;
604 /* set up the LSA QUERY INFO response */
605 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
606 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
611 /***************************************************************************
612 _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA.
614 ***************************************************************************/
616 NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u,
617 LSA_R_ENUM_TRUST_DOM *r_u)
619 struct lsa_info *info;
621 struct trustdom_info **domains;
624 * preferred length is set to 5 as a "our" preferred length
625 * nt sets this parameter to 2
626 * update (20.08.2002): it's not preferred length, but preferred size!
627 * it needs further investigation how to optimally choose this value
629 uint32 max_num_domains =
630 q_u->preferred_len < 5 ? q_u->preferred_len : 10;
635 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
636 return NT_STATUS_INVALID_HANDLE;
638 /* check if the user have enough rights */
639 if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION))
640 return NT_STATUS_ACCESS_DENIED;
642 nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains);
644 if (!NT_STATUS_IS_OK(nt_status)) {
648 if (q_u->enum_context < num_domains) {
649 num_thistime = MIN(num_domains, max_num_domains);
651 r_u->status = STATUS_MORE_ENTRIES;
653 if (q_u->enum_context + num_thistime > num_domains) {
654 num_thistime = num_domains - q_u->enum_context;
655 r_u->status = NT_STATUS_OK;
658 next_idx = q_u->enum_context + num_thistime;
661 next_idx = 0xffffffff;
662 r_u->status = NT_STATUS_NO_MORE_ENTRIES;
665 /* set up the lsa_enum_trust_dom response */
667 init_r_enum_trust_dom(p->mem_ctx, r_u, next_idx,
668 num_thistime, domains+q_u->enum_context);
673 /***************************************************************************
674 _lsa_query_info. See the POLICY_INFOMATION_CLASS docs at msdn.
675 ***************************************************************************/
677 NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u)
679 struct lsa_info *handle;
680 LSA_INFO_CTR *ctr = &r_u->ctr;
685 r_u->status = NT_STATUS_OK;
687 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
688 return NT_STATUS_INVALID_HANDLE;
690 switch (q_u->info_class) {
694 uint32 policy_def = LSA_AUDIT_POLICY_ALL;
696 /* check if the user have enough rights */
697 if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) {
698 DEBUG(10,("_lsa_query_info: insufficient access rights\n"));
699 return NT_STATUS_ACCESS_DENIED;
702 /* fake info: We audit everything. ;) */
703 ctr->info.id2.ptr = 1;
704 ctr->info.id2.auditing_enabled = True;
705 ctr->info.id2.count1 = ctr->info.id2.count2 = LSA_AUDIT_NUM_CATEGORIES;
707 if ((ctr->info.id2.auditsettings = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, LSA_AUDIT_NUM_CATEGORIES)) == NULL)
708 return NT_STATUS_NO_MEMORY;
710 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def;
711 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def;
712 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_LOGON] = policy_def;
713 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def;
714 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def;
715 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def;
716 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def;
721 /* check if the user have enough rights */
722 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
723 return NT_STATUS_ACCESS_DENIED;
725 /* Request PolicyPrimaryDomainInformation. */
726 switch (lp_server_role()) {
727 case ROLE_DOMAIN_PDC:
728 case ROLE_DOMAIN_BDC:
729 name = get_global_sam_name();
730 sid = get_global_sam_sid();
732 case ROLE_DOMAIN_MEMBER:
733 name = lp_workgroup();
734 /* We need to return the Domain SID here. */
735 if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid))
738 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
740 case ROLE_STANDALONE:
741 name = lp_workgroup();
745 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
747 init_dom_query_3(&r_u->ctr.info.id3, name, sid);
750 /* check if the user have enough rights */
751 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
752 return NT_STATUS_ACCESS_DENIED;
754 /* Request PolicyAccountDomainInformation. */
755 name = get_global_sam_name();
756 sid = get_global_sam_sid();
757 init_dom_query_5(&r_u->ctr.info.id5, name, sid);
760 /* check if the user have enough rights */
761 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
762 return NT_STATUS_ACCESS_DENIED;
764 switch (lp_server_role()) {
765 case ROLE_DOMAIN_BDC:
767 * only a BDC is a backup controller
768 * of the domain, it controls.
770 ctr->info.id6.server_role = 2;
774 * any other role is a primary
775 * of the domain, it controls.
777 ctr->info.id6.server_role = 3;
782 DEBUG(0,("_lsa_query_info: unknown info level in Lsa Query: %d\n", q_u->info_class));
783 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
787 if (NT_STATUS_IS_OK(r_u->status)) {
788 r_u->dom_ptr = 0x22000000; /* bizarre */
789 ctr->info_class = q_u->info_class;
795 /***************************************************************************
796 _lsa_lookup_sids_internal
797 ***************************************************************************/
799 static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p,
800 uint16 level, /* input */
801 int num_sids, /* input */
802 const DOM_SID2 *sid, /* input */
803 DOM_R_REF **pp_ref, /* output */
804 LSA_TRANS_NAME_ENUM2 *names, /* input/output */
805 uint32 *pp_mapped_count)
809 const DOM_SID **sids = NULL;
810 DOM_R_REF *ref = NULL;
811 uint32 mapped_count = 0;
812 struct lsa_dom_info *dom_infos = NULL;
813 struct lsa_name_info *name_infos = NULL;
815 *pp_mapped_count = 0;
823 sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids);
824 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
826 if (sids == NULL || ref == NULL) {
827 return NT_STATUS_NO_MEMORY;
830 for (i=0; i<num_sids; i++) {
831 sids[i] = &sid[i].sid;
834 status = lookup_sids(p->mem_ctx, num_sids, sids, level,
835 &dom_infos, &name_infos);
837 if (!NT_STATUS_IS_OK(status)) {
841 names->name = TALLOC_ARRAY(p->mem_ctx, LSA_TRANS_NAME2, num_sids);
842 names->uni_name = TALLOC_ARRAY(p->mem_ctx, UNISTR2, num_sids);
843 if ((names->name == NULL) || (names->uni_name == NULL)) {
844 return NT_STATUS_NO_MEMORY;
847 for (i=0; i<MAX_REF_DOMAINS; i++) {
849 if (!dom_infos[i].valid) {
853 if (init_dom_ref(ref, dom_infos[i].name,
854 &dom_infos[i].sid) != i) {
855 DEBUG(0, ("Domain %s mentioned twice??\n",
857 return NT_STATUS_INTERNAL_ERROR;
861 for (i=0; i<num_sids; i++) {
862 struct lsa_name_info *name = &name_infos[i];
864 if (name->type == SID_NAME_UNKNOWN) {
866 /* Unknown sids should return the string
867 * representation of the SID. Windows 2003 behaves
868 * rather erratic here, in many cases it returns the
869 * RID as 8 bytes hex, in others it returns the full
870 * SID. We (Jerry/VL) could not figure out which the
871 * hard cases are, so leave it with the SID. */
872 name->name = talloc_asprintf(p->mem_ctx, "%s",
873 sid_string_static(sids[i]));
874 if (name->name == NULL) {
875 return NT_STATUS_NO_MEMORY;
880 init_lsa_trans_name2(&names->name[i], &names->uni_name[i],
881 name->type, name->name, name->dom_idx);
884 names->num_entries = num_sids;
885 names->ptr_trans_names = 1;
886 names->num_entries2 = num_sids;
888 status = NT_STATUS_NONE_MAPPED;
889 if (mapped_count > 0) {
890 status = (mapped_count < num_sids) ?
891 STATUS_SOME_UNMAPPED : NT_STATUS_OK;
894 DEBUG(10, ("num_sids %d, mapped_count %d, status %s\n",
895 num_sids, mapped_count, nt_errstr(status)));
897 *pp_mapped_count = mapped_count;
903 /***************************************************************************
905 ***************************************************************************/
907 NTSTATUS _lsa_lookup_sids(pipes_struct *p,
908 LSA_Q_LOOKUP_SIDS *q_u,
909 LSA_R_LOOKUP_SIDS *r_u)
911 struct lsa_info *handle;
912 int num_sids = q_u->sids.num_entries;
913 uint32 mapped_count = 0;
914 DOM_R_REF *ref = NULL;
915 LSA_TRANS_NAME_ENUM2 names;
918 if ((q_u->level < 1) || (q_u->level > 6)) {
919 return NT_STATUS_INVALID_PARAMETER;
922 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
923 return NT_STATUS_INVALID_HANDLE;
926 /* check if the user has enough rights */
927 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
928 return NT_STATUS_ACCESS_DENIED;
931 if (num_sids > MAX_LOOKUP_SIDS) {
932 DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n",
933 MAX_LOOKUP_SIDS, num_sids));
934 return NT_STATUS_NONE_MAPPED;
937 r_u->status = _lsa_lookup_sids_internal(p,
945 /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */
947 status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, &names, mapped_count);
948 if (!NT_STATUS_IS_OK(status)) {
954 /***************************************************************************
956 ***************************************************************************/
958 NTSTATUS _lsa_lookup_sids2(pipes_struct *p,
959 LSA_Q_LOOKUP_SIDS2 *q_u,
960 LSA_R_LOOKUP_SIDS2 *r_u)
962 struct lsa_info *handle;
963 int num_sids = q_u->sids.num_entries;
964 uint32 mapped_count = 0;
965 DOM_R_REF *ref = NULL;
967 if ((q_u->level < 1) || (q_u->level > 6)) {
968 return NT_STATUS_INVALID_PARAMETER;
971 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
972 return NT_STATUS_INVALID_HANDLE;
975 /* check if the user have enough rights */
976 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
977 return NT_STATUS_ACCESS_DENIED;
980 if (num_sids > MAX_LOOKUP_SIDS) {
981 DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n",
982 MAX_LOOKUP_SIDS, num_sids));
983 return NT_STATUS_NONE_MAPPED;
986 r_u->status = _lsa_lookup_sids_internal(p,
994 init_reply_lookup_sids2(r_u, ref, mapped_count);
998 /***************************************************************************
1001 Before someone actually re-activates this, please present a sniff showing
1002 this call against some Windows server. I (vl) could not make it work against
1004 ***************************************************************************/
1006 NTSTATUS _lsa_lookup_sids3(pipes_struct *p,
1007 LSA_Q_LOOKUP_SIDS3 *q_u,
1008 LSA_R_LOOKUP_SIDS3 *r_u)
1010 uint32 mapped_count = 0;
1013 if ((q_u->level < 1) || (q_u->level > 6)) {
1014 return NT_STATUS_INVALID_PARAMETER;
1017 r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED;
1019 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1022 /* We would segfault later on in lsa_io_r_lookup_sids3 anyway,
1023 * so do a planned exit here. We NEEEED pidl! */
1024 smb_panic("talloc failed");
1027 init_reply_lookup_sids3(r_u, ref, mapped_count);
1031 /***************************************************************************
1032 lsa_reply_lookup_names
1033 ***************************************************************************/
1035 NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u)
1037 struct lsa_info *handle;
1038 UNISTR2 *names = q_u->uni_name;
1039 uint32 num_entries = q_u->num_entries;
1042 uint32 mapped_count = 0;
1045 if (num_entries > MAX_LOOKUP_SIDS) {
1046 num_entries = MAX_LOOKUP_SIDS;
1047 DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries));
1050 /* Probably the lookup_level is some sort of bitmask. */
1051 if (q_u->lookup_level == 1) {
1052 flags = LOOKUP_NAME_ALL;
1055 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1057 return NT_STATUS_NO_MEMORY;
1061 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
1063 return NT_STATUS_NO_MEMORY;
1069 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1070 r_u->status = NT_STATUS_INVALID_HANDLE;
1074 /* check if the user have enough rights */
1075 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1076 r_u->status = NT_STATUS_ACCESS_DENIED;
1080 /* set up the LSA Lookup RIDs response */
1081 become_root(); /* lookup_name can require root privs */
1082 r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
1083 names, flags, &mapped_count);
1088 if (NT_STATUS_IS_OK(r_u->status) && (num_entries != 0) ) {
1089 if (mapped_count == 0)
1090 r_u->status = NT_STATUS_NONE_MAPPED;
1091 else if (mapped_count != num_entries)
1092 r_u->status = STATUS_SOME_UNMAPPED;
1095 init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count);
1099 /***************************************************************************
1100 lsa_reply_lookup_names2
1101 ***************************************************************************/
1103 NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOOKUP_NAMES2 *r_u)
1105 struct lsa_info *handle;
1106 UNISTR2 *names = q_u->uni_name;
1107 uint32 num_entries = q_u->num_entries;
1112 uint32 mapped_count = 0;
1115 if (num_entries > MAX_LOOKUP_SIDS) {
1116 num_entries = MAX_LOOKUP_SIDS;
1117 DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries));
1120 /* Probably the lookup_level is some sort of bitmask. */
1121 if (q_u->lookup_level == 1) {
1122 flags = LOOKUP_NAME_ALL;
1125 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1127 r_u->status = NT_STATUS_NO_MEMORY;
1128 return NT_STATUS_NO_MEMORY;
1132 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
1133 rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries);
1134 if ((rids == NULL) || (rids2 == NULL)) {
1135 r_u->status = NT_STATUS_NO_MEMORY;
1136 return NT_STATUS_NO_MEMORY;
1143 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1144 r_u->status = NT_STATUS_INVALID_HANDLE;
1148 /* check if the user have enough rights */
1149 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1150 r_u->status = NT_STATUS_ACCESS_DENIED;
1154 /* set up the LSA Lookup RIDs response */
1155 become_root(); /* lookup_name can require root privs */
1156 r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
1157 names, flags, &mapped_count);
1162 if (NT_STATUS_IS_OK(r_u->status)) {
1163 if (mapped_count == 0) {
1164 r_u->status = NT_STATUS_NONE_MAPPED;
1165 } else if (mapped_count != num_entries) {
1166 r_u->status = STATUS_SOME_UNMAPPED;
1170 /* Convert the rids array to rids2. */
1171 for (i = 0; i < num_entries; i++) {
1172 rids2[i].type = rids[i].type;
1173 rids2[i].rid = rids[i].rid;
1174 rids2[i].rid_idx = rids[i].rid_idx;
1175 rids2[i].unknown = 0;
1178 init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count);
1182 /***************************************************************************
1183 lsa_reply_lookup_names3.
1184 ***************************************************************************/
1186 NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u)
1188 struct lsa_info *handle;
1189 UNISTR2 *names = q_u->uni_name;
1190 uint32 num_entries = q_u->num_entries;
1191 DOM_R_REF *ref = NULL;
1192 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1193 uint32 mapped_count = 0;
1196 if (num_entries > MAX_LOOKUP_SIDS) {
1197 num_entries = MAX_LOOKUP_SIDS;
1198 DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries));
1201 /* Probably the lookup_level is some sort of bitmask. */
1202 if (q_u->lookup_level == 1) {
1203 flags = LOOKUP_NAME_ALL;
1206 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1208 return NT_STATUS_NO_MEMORY;
1211 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1213 return NT_STATUS_NO_MEMORY;
1219 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1220 r_u->status = NT_STATUS_INVALID_HANDLE;
1224 /* check if the user have enough rights */
1225 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1226 r_u->status = NT_STATUS_ACCESS_DENIED;
1230 /* set up the LSA Lookup SIDs response */
1231 become_root(); /* lookup_name can require root privs */
1232 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1233 names, flags, &mapped_count);
1238 if (NT_STATUS_IS_OK(r_u->status)) {
1239 if (mapped_count == 0) {
1240 r_u->status = NT_STATUS_NONE_MAPPED;
1241 } else if (mapped_count != num_entries) {
1242 r_u->status = STATUS_SOME_UNMAPPED;
1246 init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count);
1250 /***************************************************************************
1251 lsa_reply_lookup_names4.
1252 ***************************************************************************/
1254 NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u)
1256 UNISTR2 *names = q_u->uni_name;
1257 uint32 num_entries = q_u->num_entries;
1258 DOM_R_REF *ref = NULL;
1259 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1260 uint32 mapped_count = 0;
1263 if (num_entries > MAX_LOOKUP_SIDS) {
1264 num_entries = MAX_LOOKUP_SIDS;
1265 DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries));
1268 /* Probably the lookup_level is some sort of bitmask. */
1269 if (q_u->lookup_level == 1) {
1270 flags = LOOKUP_NAME_ALL;
1273 /* No policy handle on this call. Restrict to crypto connections. */
1274 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1275 DEBUG(0,("_lsa_lookup_names4: client %s not using schannel for netlogon\n",
1276 get_remote_machine_name() ));
1277 return NT_STATUS_INVALID_PARAMETER;
1280 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1282 return NT_STATUS_NO_MEMORY;
1286 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1288 return NT_STATUS_NO_MEMORY;
1294 /* set up the LSA Lookup SIDs response */
1295 become_root(); /* lookup_name can require root privs */
1296 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1297 names, flags, &mapped_count);
1300 if (NT_STATUS_IS_OK(r_u->status)) {
1301 if (mapped_count == 0) {
1302 r_u->status = NT_STATUS_NONE_MAPPED;
1303 } else if (mapped_count != num_entries) {
1304 r_u->status = STATUS_SOME_UNMAPPED;
1308 init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count);
1312 /***************************************************************************
1313 _lsa_close. Also weird - needs to check if lsa handle is correct. JRA.
1314 ***************************************************************************/
1316 NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r)
1318 if (!find_policy_by_hnd(p, r->in.handle, NULL)) {
1319 return NT_STATUS_INVALID_HANDLE;
1322 close_policy_hnd(p, r->in.handle);
1323 return NT_STATUS_OK;
1326 /***************************************************************************
1327 ***************************************************************************/
1329 NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct lsa_OpenSecret *r)
1331 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1334 /***************************************************************************
1335 ***************************************************************************/
1337 NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct lsa_OpenTrustedDomain *r)
1339 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1342 /***************************************************************************
1343 ***************************************************************************/
1345 NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, struct lsa_CreateTrustedDomain *r)
1347 return NT_STATUS_ACCESS_DENIED;
1350 /***************************************************************************
1351 ***************************************************************************/
1353 NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct lsa_CreateSecret *r)
1355 return NT_STATUS_ACCESS_DENIED;
1358 /***************************************************************************
1359 ***************************************************************************/
1361 NTSTATUS _lsa_SetSecret(pipes_struct *p, struct lsa_SetSecret *r)
1363 return NT_STATUS_ACCESS_DENIED;
1366 /***************************************************************************
1367 ***************************************************************************/
1369 NTSTATUS _lsa_delete_object(pipes_struct *p, LSA_Q_DELETE_OBJECT *q_u, LSA_R_DELETE_OBJECT *r_u)
1371 return NT_STATUS_ACCESS_DENIED;
1374 /***************************************************************************
1376 ***************************************************************************/
1378 NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u)
1380 struct lsa_info *handle;
1382 uint32 enum_context = q_u->enum_context;
1383 int num_privs = count_all_privileges();
1384 LSA_PRIV_ENTRY *entries = NULL;
1387 /* remember that the enum_context starts at 0 and not 1 */
1389 if ( enum_context >= num_privs )
1390 return NT_STATUS_NO_MORE_ENTRIES;
1392 DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n",
1393 enum_context, num_privs));
1395 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1396 return NT_STATUS_INVALID_HANDLE;
1398 /* check if the user have enough rights
1399 I don't know if it's the right one. not documented. */
1401 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1402 return NT_STATUS_ACCESS_DENIED;
1405 if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) )
1406 return NT_STATUS_NO_MEMORY;
1411 for (i = 0; i < num_privs; i++) {
1412 if( i < enum_context) {
1413 init_unistr2(&entries[i].name, NULL, UNI_FLAGS_NONE);
1414 init_uni_hdr(&entries[i].hdr_name, &entries[i].name);
1416 entries[i].luid_low = 0;
1417 entries[i].luid_high = 0;
1419 init_unistr2(&entries[i].name, privs[i].name, UNI_FLAGS_NONE);
1420 init_uni_hdr(&entries[i].hdr_name, &entries[i].name);
1422 luid = get_privilege_luid( &privs[i].se_priv );
1424 entries[i].luid_low = luid.luid.low;
1425 entries[i].luid_high = luid.luid.high;
1429 enum_context = num_privs;
1431 init_lsa_r_enum_privs(r_u, enum_context, num_privs, entries);
1433 return NT_STATUS_OK;
1436 /***************************************************************************
1437 _lsa_priv_get_dispname.
1438 ***************************************************************************/
1440 NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u)
1442 struct lsa_info *handle;
1444 const char *description;
1446 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1447 return NT_STATUS_INVALID_HANDLE;
1449 /* check if the user have enough rights */
1452 * I don't know if it's the right one. not documented.
1454 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1455 return NT_STATUS_ACCESS_DENIED;
1457 unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc));
1459 DEBUG(10,("_lsa_priv_get_dispname: name = %s\n", name_asc));
1461 description = get_privilege_dispname( name_asc );
1463 if ( description ) {
1464 DEBUG(10,("_lsa_priv_get_dispname: display name = %s\n", description));
1466 init_unistr2(&r_u->desc, description, UNI_FLAGS_NONE);
1467 init_uni_hdr(&r_u->hdr_desc, &r_u->desc);
1469 r_u->ptr_info = 0xdeadbeef;
1470 r_u->lang_id = q_u->lang_id;
1472 return NT_STATUS_OK;
1474 DEBUG(10,("_lsa_priv_get_dispname: doesn't exist\n"));
1478 return NT_STATUS_NO_SUCH_PRIVILEGE;
1482 /***************************************************************************
1484 ***************************************************************************/
1486 NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u)
1488 struct lsa_info *handle;
1490 int i, j, num_entries;
1491 LSA_SID_ENUM *sids=&r_u->sids;
1494 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1495 return NT_STATUS_INVALID_HANDLE;
1497 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1498 return NT_STATUS_ACCESS_DENIED;
1503 /* The only way we can currently find out all the SIDs that have been
1504 privileged is to scan all privileges */
1506 if (!NT_STATUS_IS_OK(ret = privilege_enumerate_accounts(&sid_list, &num_entries))) {
1510 if (q_u->enum_context >= num_entries)
1511 return NT_STATUS_NO_MORE_ENTRIES;
1513 if (num_entries-q_u->enum_context) {
1514 sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context);
1515 sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context);
1517 if (sids->ptr_sid==NULL || sids->sid==NULL) {
1518 SAFE_FREE(sid_list);
1519 return NT_STATUS_NO_MEMORY;
1522 sids->ptr_sid = NULL;
1526 for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) {
1527 init_dom_sid2(&(*sids).sid[j], &sid_list[i]);
1528 (*sids).ptr_sid[j] = 1;
1531 talloc_free(sid_list);
1533 init_lsa_r_enum_accounts(r_u, num_entries);
1535 return NT_STATUS_OK;
1539 NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u)
1541 const char *username, *domname;
1542 user_struct *vuser = get_valid_user_struct(p->vuid);
1545 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1549 * I'm 99% sure this is not the right place to do this,
1550 * global_sid_Anonymous should probably be put into the token
1551 * instead of the guest id -- vl
1553 if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous,
1554 &domname, &username, NULL)) {
1555 return NT_STATUS_NO_MEMORY;
1558 username = vuser->user.smb_name;
1559 domname = vuser->user.domain;
1562 r_u->ptr_user_name = 1;
1563 init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE);
1564 init_uni_hdr(&r_u->hdr_user_name, &r_u->uni2_user_name);
1568 r_u->ptr_dom_name = 1;
1569 init_unistr2(&r_u->uni2_dom_name, domname, UNI_STR_TERMINATE);
1570 init_uni_hdr(&r_u->hdr_dom_name, &r_u->uni2_dom_name);
1572 r_u->status = NT_STATUS_OK;
1577 /***************************************************************************
1579 ***************************************************************************/
1581 NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CREATEACCOUNT *r_u)
1583 struct lsa_info *handle;
1584 struct lsa_info *info;
1586 /* find the connection policy handle. */
1587 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1588 return NT_STATUS_INVALID_HANDLE;
1590 /* check if the user have enough rights */
1593 * I don't know if it's the right one. not documented.
1594 * but guessed with rpcclient.
1596 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) {
1597 DEBUG(10, ("_lsa_create_account: No POLICY_GET_PRIVATE_INFORMATION access right!\n"));
1598 return NT_STATUS_ACCESS_DENIED;
1601 /* check to see if the pipe_user is a Domain Admin since
1602 account_pol.tdb was already opened as root, this is all we have */
1604 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) {
1605 DEBUG(10, ("_lsa_create_account: The use is not a Domain Admin, deny access!\n"));
1606 return NT_STATUS_ACCESS_DENIED;
1609 if ( is_privileged_sid( &q_u->sid.sid ) ) {
1610 DEBUG(10, ("_lsa_create_account: Policy account already exists!\n"));
1611 return NT_STATUS_OBJECT_NAME_COLLISION;
1614 /* associate the user/group SID with the (unique) handle. */
1616 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1617 return NT_STATUS_NO_MEMORY;
1620 info->sid = q_u->sid.sid;
1621 info->access = q_u->access;
1623 /* get a (unique) handle. open a policy on it. */
1624 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
1625 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1627 DEBUG(10, ("_lsa_create_account: call privileges code to create an account\n"));
1628 return privilege_create_account( &info->sid );
1632 /***************************************************************************
1634 ***************************************************************************/
1636 NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u)
1638 struct lsa_info *handle;
1639 struct lsa_info *info;
1641 /* find the connection policy handle. */
1642 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1643 return NT_STATUS_INVALID_HANDLE;
1645 /* check if the user have enough rights */
1648 * I don't know if it's the right one. not documented.
1649 * but guessed with rpcclient.
1651 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
1652 return NT_STATUS_ACCESS_DENIED;
1654 /* TODO: Fis the parsing routine before reenabling this check! */
1656 if (!lookup_sid(&handle->sid, dom_name, name, &type))
1657 return NT_STATUS_ACCESS_DENIED;
1659 /* associate the user/group SID with the (unique) handle. */
1660 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1661 return NT_STATUS_NO_MEMORY;
1664 info->sid = q_u->sid.sid;
1665 info->access = q_u->access;
1667 /* get a (unique) handle. open a policy on it. */
1668 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
1669 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1671 return NT_STATUS_OK;
1674 /***************************************************************************
1675 For a given SID, enumerate all the privilege this account has.
1676 ***************************************************************************/
1678 NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u)
1680 struct lsa_info *info=NULL;
1682 PRIVILEGE_SET privileges;
1684 /* find the connection policy handle. */
1685 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1686 return NT_STATUS_INVALID_HANDLE;
1688 if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) )
1689 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1691 privilege_set_init( &privileges );
1693 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
1695 DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n",
1696 sid_string_static(&info->sid), privileges.count));
1698 r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0);
1701 r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE;
1703 privilege_set_free( &privileges );
1708 /***************************************************************************
1710 ***************************************************************************/
1712 NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u)
1714 struct lsa_info *info=NULL;
1716 /* find the connection policy handle. */
1718 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1719 return NT_STATUS_INVALID_HANDLE;
1721 if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL))
1722 return NT_STATUS_OK;
1725 0x01 -> Log on locally
1726 0x02 -> Access this computer from network
1727 0x04 -> Log on as a batch job
1728 0x10 -> Log on as a service
1730 they can be ORed together
1733 r_u->access = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK;
1735 return NT_STATUS_OK;
1738 /***************************************************************************
1739 update the systemaccount information
1740 ***************************************************************************/
1742 NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA_R_SETSYSTEMACCOUNT *r_u)
1744 struct lsa_info *info=NULL;
1746 r_u->status = NT_STATUS_OK;
1748 /* find the connection policy handle. */
1749 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1750 return NT_STATUS_INVALID_HANDLE;
1752 /* check to see if the pipe_user is a Domain Admin since
1753 account_pol.tdb was already opened as root, this is all we have */
1755 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1756 return NT_STATUS_ACCESS_DENIED;
1758 if (!pdb_getgrsid(&map, info->sid))
1759 return NT_STATUS_NO_SUCH_GROUP;
1761 return pdb_update_group_mapping_entry(&map);
1764 /***************************************************************************
1765 For a given SID, add some privileges.
1766 ***************************************************************************/
1768 NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u)
1770 struct lsa_info *info = NULL;
1772 PRIVILEGE_SET *set = NULL;
1774 /* find the connection policy handle. */
1775 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1776 return NT_STATUS_INVALID_HANDLE;
1778 /* check to see if the pipe_user is root or a Domain Admin since
1779 account_pol.tdb was already opened as root, this is all we have */
1781 if ( p->pipe_user.ut.uid != sec_initial_uid()
1782 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1784 return NT_STATUS_ACCESS_DENIED;
1789 if ( !privilege_set_to_se_priv( &mask, set ) )
1790 return NT_STATUS_NO_SUCH_PRIVILEGE;
1792 if ( !grant_privilege( &info->sid, &mask ) ) {
1793 DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n",
1794 sid_string_static(&info->sid) ));
1795 DEBUG(3,("Privilege mask:\n"));
1796 dump_se_priv( DBGC_ALL, 3, &mask );
1797 return NT_STATUS_NO_SUCH_PRIVILEGE;
1800 return NT_STATUS_OK;
1803 /***************************************************************************
1804 For a given SID, remove some privileges.
1805 ***************************************************************************/
1807 NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u)
1809 struct lsa_info *info = NULL;
1811 PRIVILEGE_SET *set = NULL;
1813 /* find the connection policy handle. */
1814 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1815 return NT_STATUS_INVALID_HANDLE;
1817 /* check to see if the pipe_user is root or a Domain Admin since
1818 account_pol.tdb was already opened as root, this is all we have */
1820 if ( p->pipe_user.ut.uid != sec_initial_uid()
1821 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1823 return NT_STATUS_ACCESS_DENIED;
1828 if ( !privilege_set_to_se_priv( &mask, set ) )
1829 return NT_STATUS_NO_SUCH_PRIVILEGE;
1831 if ( !revoke_privilege( &info->sid, &mask ) ) {
1832 DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n",
1833 sid_string_static(&info->sid) ));
1834 DEBUG(3,("Privilege mask:\n"));
1835 dump_se_priv( DBGC_ALL, 3, &mask );
1836 return NT_STATUS_NO_SUCH_PRIVILEGE;
1839 return NT_STATUS_OK;
1842 /***************************************************************************
1843 For a given SID, remove some privileges.
1844 ***************************************************************************/
1846 NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUERY_SEC_OBJ *r_u)
1848 struct lsa_info *handle=NULL;
1849 SEC_DESC *psd = NULL;
1853 r_u->status = NT_STATUS_OK;
1855 /* find the connection policy handle. */
1856 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1857 return NT_STATUS_INVALID_HANDLE;
1859 /* check if the user have enough rights */
1860 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1861 return NT_STATUS_ACCESS_DENIED;
1864 switch (q_u->sec_info) {
1866 /* SD contains only the owner */
1868 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1869 if(!NT_STATUS_IS_OK(status))
1870 return NT_STATUS_NO_MEMORY;
1873 if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1874 return NT_STATUS_NO_MEMORY;
1877 /* SD contains only the ACL */
1879 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1880 if(!NT_STATUS_IS_OK(status))
1881 return NT_STATUS_NO_MEMORY;
1883 if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1884 return NT_STATUS_NO_MEMORY;
1887 return NT_STATUS_INVALID_LEVEL;
1895 #if 0 /* AD DC work in ongoing in Samba 4 */
1897 /***************************************************************************
1898 ***************************************************************************/
1900 NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u)
1902 struct lsa_info *handle;
1903 const char *nb_name;
1904 char *dns_name = NULL;
1905 char *forest_name = NULL;
1906 DOM_SID *sid = NULL;
1911 r_u->status = NT_STATUS_OK;
1913 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1914 return NT_STATUS_INVALID_HANDLE;
1916 switch (q_u->info_class) {
1918 /* check if the user have enough rights */
1919 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1920 return NT_STATUS_ACCESS_DENIED;
1922 /* Request PolicyPrimaryDomainInformation. */
1923 switch (lp_server_role()) {
1924 case ROLE_DOMAIN_PDC:
1925 case ROLE_DOMAIN_BDC:
1926 nb_name = get_global_sam_name();
1927 /* ugly temp hack for these next two */
1929 /* This should be a 'netbios domain -> DNS domain' mapping */
1930 dnsdomname[0] = '\0';
1931 get_mydnsdomname(dnsdomname);
1932 strlower_m(dnsdomname);
1934 dns_name = dnsdomname;
1935 forest_name = dnsdomname;
1937 sid = get_global_sam_sid();
1938 secrets_fetch_domain_guid(lp_workgroup(), &guid);
1941 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1943 init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name,
1944 forest_name,&guid,sid);
1947 DEBUG(0,("_lsa_query_info2: unknown info level in Lsa Query: %d\n", q_u->info_class));
1948 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1952 if (NT_STATUS_IS_OK(r_u->status)) {
1954 r_u->info_class = q_u->info_class;
1959 #endif /* AD DC work in ongoing in Samba 4 */
1961 /***************************************************************************
1962 ***************************************************************************/
1964 NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u)
1966 struct lsa_info *info = NULL;
1970 UNISTR4_ARRAY *uni_privnames = q_u->rights;
1973 /* find the connection policy handle. */
1974 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1975 return NT_STATUS_INVALID_HANDLE;
1977 /* check to see if the pipe_user is a Domain Admin since
1978 account_pol.tdb was already opened as root, this is all we have */
1980 if ( p->pipe_user.ut.uid != sec_initial_uid()
1981 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1983 return NT_STATUS_ACCESS_DENIED;
1986 /* according to an NT4 PDC, you can add privileges to SIDs even without
1987 call_lsa_create_account() first. And you can use any arbitrary SID. */
1989 sid_copy( &sid, &q_u->sid.sid );
1991 /* just a little sanity check */
1993 if ( q_u->count != uni_privnames->count ) {
1994 DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n"));
1995 return NT_STATUS_INVALID_HANDLE;
1998 for ( i=0; i<q_u->count; i++ ) {
1999 UNISTR4 *uni4_str = &uni_privnames->strings[i];
2001 /* only try to add non-null strings */
2003 if ( !uni4_str->string )
2006 rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE );
2008 if ( !grant_privilege_by_name( &sid, privname ) ) {
2009 DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname ));
2010 return NT_STATUS_NO_SUCH_PRIVILEGE;
2014 return NT_STATUS_OK;
2017 /***************************************************************************
2018 ***************************************************************************/
2020 NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u)
2022 struct lsa_info *info = NULL;
2026 UNISTR4_ARRAY *uni_privnames = q_u->rights;
2029 /* find the connection policy handle. */
2030 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2031 return NT_STATUS_INVALID_HANDLE;
2033 /* check to see if the pipe_user is a Domain Admin since
2034 account_pol.tdb was already opened as root, this is all we have */
2036 if ( p->pipe_user.ut.uid != sec_initial_uid()
2037 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
2039 return NT_STATUS_ACCESS_DENIED;
2042 sid_copy( &sid, &q_u->sid.sid );
2044 if ( q_u->removeall ) {
2045 if ( !revoke_all_privileges( &sid ) )
2046 return NT_STATUS_ACCESS_DENIED;
2048 return NT_STATUS_OK;
2051 /* just a little sanity check */
2053 if ( q_u->count != uni_privnames->count ) {
2054 DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n"));
2055 return NT_STATUS_INVALID_HANDLE;
2058 for ( i=0; i<q_u->count; i++ ) {
2059 UNISTR4 *uni4_str = &uni_privnames->strings[i];
2061 /* only try to add non-null strings */
2063 if ( !uni4_str->string )
2066 rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE );
2068 if ( !revoke_privilege_by_name( &sid, privname ) ) {
2069 DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname ));
2070 return NT_STATUS_NO_SUCH_PRIVILEGE;
2074 return NT_STATUS_OK;
2078 /***************************************************************************
2079 ***************************************************************************/
2081 NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u)
2083 struct lsa_info *info = NULL;
2085 PRIVILEGE_SET privileges;
2089 /* find the connection policy handle. */
2091 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2092 return NT_STATUS_INVALID_HANDLE;
2094 /* according to an NT4 PDC, you can add privileges to SIDs even without
2095 call_lsa_create_account() first. And you can use any arbitrary SID. */
2097 sid_copy( &sid, &q_u->sid.sid );
2099 if ( !get_privileges_for_sids( &mask, &sid, 1 ) )
2100 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
2102 privilege_set_init( &privileges );
2104 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
2106 DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n",
2107 sid_string_static(&sid), privileges.count));
2109 r_u->status = init_r_enum_acct_rights( r_u, &privileges );
2112 r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE;
2114 privilege_set_free( &privileges );
2120 /***************************************************************************
2121 ***************************************************************************/
2123 NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u)
2125 struct lsa_info *info = NULL;
2127 LUID_ATTR priv_luid;
2130 /* find the connection policy handle. */
2132 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2133 return NT_STATUS_INVALID_HANDLE;
2135 unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name));
2137 DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name));
2139 if ( !se_priv_from_name( name, &mask ) )
2140 return NT_STATUS_NO_SUCH_PRIVILEGE;
2142 priv_luid = get_privilege_luid( &mask );
2144 r_u->luid.low = priv_luid.luid.low;
2145 r_u->luid.high = priv_luid.luid.high;
2148 return NT_STATUS_OK;
2153 * From here on the server routines are just dummy ones to make smbd link with
2154 * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are
2155 * pulling the server stubs across one by one.
2158 NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r)
2160 p->rng_fault_state = True;
2161 return NT_STATUS_NOT_IMPLEMENTED;
2164 NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct lsa_EnumPrivs *r)
2166 p->rng_fault_state = True;
2167 return NT_STATUS_NOT_IMPLEMENTED;
2170 NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct lsa_QuerySecurity *r)
2172 p->rng_fault_state = True;
2173 return NT_STATUS_NOT_IMPLEMENTED;
2176 NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r)
2178 p->rng_fault_state = True;
2179 return NT_STATUS_NOT_IMPLEMENTED;
2182 NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r)
2184 p->rng_fault_state = True;
2185 return NT_STATUS_NOT_IMPLEMENTED;
2188 NTSTATUS _lsa_OpenPolicy(pipes_struct *p, struct lsa_OpenPolicy *r)
2190 p->rng_fault_state = True;
2191 return NT_STATUS_NOT_IMPLEMENTED;
2194 NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct lsa_QueryInfoPolicy *r)
2196 p->rng_fault_state = True;
2197 return NT_STATUS_NOT_IMPLEMENTED;
2200 NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p, struct lsa_SetInfoPolicy *r)
2202 p->rng_fault_state = True;
2203 return NT_STATUS_NOT_IMPLEMENTED;
2206 NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r)
2208 p->rng_fault_state = True;
2209 return NT_STATUS_NOT_IMPLEMENTED;
2212 NTSTATUS _lsa_CreateAccount(pipes_struct *p, struct lsa_CreateAccount *r)
2214 p->rng_fault_state = True;
2215 return NT_STATUS_NOT_IMPLEMENTED;
2218 NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r)
2220 p->rng_fault_state = True;
2221 return NT_STATUS_NOT_IMPLEMENTED;
2224 NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct lsa_EnumTrustDom *r)
2226 p->rng_fault_state = True;
2227 return NT_STATUS_NOT_IMPLEMENTED;
2230 NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r)
2232 p->rng_fault_state = True;
2233 return NT_STATUS_NOT_IMPLEMENTED;
2236 NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r)
2238 p->rng_fault_state = True;
2239 return NT_STATUS_NOT_IMPLEMENTED;
2242 NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct lsa_OpenAccount *r)
2244 p->rng_fault_state = True;
2245 return NT_STATUS_NOT_IMPLEMENTED;
2248 NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r)
2250 p->rng_fault_state = True;
2251 return NT_STATUS_NOT_IMPLEMENTED;
2254 NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r)
2256 p->rng_fault_state = True;
2257 return NT_STATUS_NOT_IMPLEMENTED;
2260 NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct lsa_RemovePrivilegesFromAccount *r)
2262 p->rng_fault_state = True;
2263 return NT_STATUS_NOT_IMPLEMENTED;
2266 NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r)
2268 p->rng_fault_state = True;
2269 return NT_STATUS_NOT_IMPLEMENTED;
2272 NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccount *r)
2274 p->rng_fault_state = True;
2275 return NT_STATUS_NOT_IMPLEMENTED;
2278 NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccessAccount *r)
2280 p->rng_fault_state = True;
2281 return NT_STATUS_NOT_IMPLEMENTED;
2284 NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, struct lsa_SetSystemAccessAccount *r)
2286 p->rng_fault_state = True;
2287 return NT_STATUS_NOT_IMPLEMENTED;
2290 NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r)
2292 p->rng_fault_state = True;
2293 return NT_STATUS_NOT_IMPLEMENTED;
2296 NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p, struct lsa_SetInformationTrustedDomain *r)
2298 p->rng_fault_state = True;
2299 return NT_STATUS_NOT_IMPLEMENTED;
2302 NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r)
2304 p->rng_fault_state = True;
2305 return NT_STATUS_NOT_IMPLEMENTED;
2308 NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct lsa_LookupPrivValue *r)
2310 p->rng_fault_state = True;
2311 return NT_STATUS_NOT_IMPLEMENTED;
2314 NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r)
2316 p->rng_fault_state = True;
2317 return NT_STATUS_NOT_IMPLEMENTED;
2320 NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct lsa_LookupPrivDisplayName *r)
2322 p->rng_fault_state = True;
2323 return NT_STATUS_NOT_IMPLEMENTED;
2326 NTSTATUS _lsa_DeleteObject(pipes_struct *p, struct lsa_DeleteObject *r)
2328 p->rng_fault_state = True;
2329 return NT_STATUS_NOT_IMPLEMENTED;
2332 NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r)
2334 p->rng_fault_state = True;
2335 return NT_STATUS_NOT_IMPLEMENTED;
2338 NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r)
2340 p->rng_fault_state = True;
2341 return NT_STATUS_NOT_IMPLEMENTED;
2344 NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct lsa_AddAccountRights *r)
2346 p->rng_fault_state = True;
2347 return NT_STATUS_NOT_IMPLEMENTED;
2350 NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r)
2352 p->rng_fault_state = True;
2353 return NT_STATUS_NOT_IMPLEMENTED;
2356 NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r)
2358 p->rng_fault_state = True;
2359 return NT_STATUS_NOT_IMPLEMENTED;
2362 NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p, struct lsa_SetTrustedDomainInfo *r)
2364 p->rng_fault_state = True;
2365 return NT_STATUS_NOT_IMPLEMENTED;
2368 NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct lsa_DeleteTrustedDomain *r)
2370 p->rng_fault_state = True;
2371 return NT_STATUS_NOT_IMPLEMENTED;
2374 NTSTATUS _lsa_StorePrivateData(pipes_struct *p, struct lsa_StorePrivateData *r)
2376 p->rng_fault_state = True;
2377 return NT_STATUS_NOT_IMPLEMENTED;
2380 NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateData *r)
2382 p->rng_fault_state = True;
2383 return NT_STATUS_NOT_IMPLEMENTED;
2386 NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, struct lsa_OpenPolicy2 *r)
2388 p->rng_fault_state = True;
2389 return NT_STATUS_NOT_IMPLEMENTED;
2392 NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r)
2394 p->rng_fault_state = True;
2395 return NT_STATUS_NOT_IMPLEMENTED;
2398 NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct lsa_QueryInfoPolicy2 *r)
2400 p->rng_fault_state = True;
2401 return NT_STATUS_NOT_IMPLEMENTED;
2404 NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p, struct lsa_SetInfoPolicy2 *r)
2406 p->rng_fault_state = True;
2407 return NT_STATUS_NOT_IMPLEMENTED;
2410 NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct lsa_QueryTrustedDomainInfoByName *r)
2412 p->rng_fault_state = True;
2413 return NT_STATUS_NOT_IMPLEMENTED;
2416 NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct lsa_SetTrustedDomainInfoByName *r)
2418 p->rng_fault_state = True;
2419 return NT_STATUS_NOT_IMPLEMENTED;
2422 NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct lsa_EnumTrustedDomainsEx *r)
2424 p->rng_fault_state = True;
2425 return NT_STATUS_NOT_IMPLEMENTED;
2428 NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p, struct lsa_CreateTrustedDomainEx *r)
2430 p->rng_fault_state = True;
2431 return NT_STATUS_NOT_IMPLEMENTED;
2434 NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct lsa_CloseTrustedDomainEx *r)
2436 p->rng_fault_state = True;
2437 return NT_STATUS_NOT_IMPLEMENTED;
2440 NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct lsa_QueryDomainInformationPolicy *r)
2442 p->rng_fault_state = True;
2443 return NT_STATUS_NOT_IMPLEMENTED;
2446 NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct lsa_SetDomainInformationPolicy *r)
2448 p->rng_fault_state = True;
2449 return NT_STATUS_NOT_IMPLEMENTED;
2452 NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct lsa_OpenTrustedDomainByName *r)
2454 p->rng_fault_state = True;
2455 return NT_STATUS_NOT_IMPLEMENTED;
2458 NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r)
2460 p->rng_fault_state = True;
2461 return NT_STATUS_NOT_IMPLEMENTED;
2464 NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r)
2466 p->rng_fault_state = True;
2467 return NT_STATUS_NOT_IMPLEMENTED;
2470 NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct lsa_LookupNames2 *r)
2472 p->rng_fault_state = True;
2473 return NT_STATUS_NOT_IMPLEMENTED;
2476 NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r)
2478 p->rng_fault_state = True;
2479 return NT_STATUS_NOT_IMPLEMENTED;
2482 NTSTATUS _lsa_CREDRWRITE(pipes_struct *p, struct lsa_CREDRWRITE *r)
2484 p->rng_fault_state = True;
2485 return NT_STATUS_NOT_IMPLEMENTED;
2488 NTSTATUS _lsa_CREDRREAD(pipes_struct *p, struct lsa_CREDRREAD *r)
2490 p->rng_fault_state = True;
2491 return NT_STATUS_NOT_IMPLEMENTED;
2494 NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p, struct lsa_CREDRENUMERATE *r)
2496 p->rng_fault_state = True;
2497 return NT_STATUS_NOT_IMPLEMENTED;
2500 NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRWRITEDOMAINCREDENTIALS *r)
2502 p->rng_fault_state = True;
2503 return NT_STATUS_NOT_IMPLEMENTED;
2506 NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRREADDOMAINCREDENTIALS *r)
2508 p->rng_fault_state = True;
2509 return NT_STATUS_NOT_IMPLEMENTED;
2512 NTSTATUS _lsa_CREDRDELETE(pipes_struct *p, struct lsa_CREDRDELETE *r)
2514 p->rng_fault_state = True;
2515 return NT_STATUS_NOT_IMPLEMENTED;
2518 NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p, struct lsa_CREDRGETTARGETINFO *r)
2520 p->rng_fault_state = True;
2521 return NT_STATUS_NOT_IMPLEMENTED;
2524 NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED *r)
2526 p->rng_fault_state = True;
2527 return NT_STATUS_NOT_IMPLEMENTED;
2530 NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r)
2532 p->rng_fault_state = True;
2533 return NT_STATUS_NOT_IMPLEMENTED;
2536 NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r)
2538 p->rng_fault_state = True;
2539 return NT_STATUS_NOT_IMPLEMENTED;
2542 NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARREGISTERAUDITEVENT *r)
2544 p->rng_fault_state = True;
2545 return NT_STATUS_NOT_IMPLEMENTED;
2548 NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p, struct lsa_LSARGENAUDITEVENT *r)
2550 p->rng_fault_state = True;
2551 return NT_STATUS_NOT_IMPLEMENTED;
2554 NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARUNREGISTERAUDITEVENT *r)
2556 p->rng_fault_state = True;
2557 return NT_STATUS_NOT_IMPLEMENTED;
2560 NTSTATUS _lsa_LSARQUERYFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARQUERYFORESTTRUSTINFORMATION *r)
2562 p->rng_fault_state = True;
2563 return NT_STATUS_NOT_IMPLEMENTED;
2566 NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARSETFORESTTRUSTINFORMATION *r)
2568 p->rng_fault_state = True;
2569 return NT_STATUS_NOT_IMPLEMENTED;
2572 NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r)
2574 p->rng_fault_state = True;
2575 return NT_STATUS_NOT_IMPLEMENTED;
2578 NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r)
2580 p->rng_fault_state = True;
2581 return NT_STATUS_NOT_IMPLEMENTED;
2584 NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r)
2586 p->rng_fault_state = True;
2587 return NT_STATUS_NOT_IMPLEMENTED;
2590 NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r)
2592 p->rng_fault_state = True;
2593 return NT_STATUS_NOT_IMPLEMENTED;
2596 NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r)
2598 p->rng_fault_state = True;
2599 return NT_STATUS_NOT_IMPLEMENTED;
2602 NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r)
2604 p->rng_fault_state = True;
2605 return NT_STATUS_NOT_IMPLEMENTED;
2608 NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p, struct lsa_LSARADTREPORTSECURITYEVENT *r)
2610 p->rng_fault_state = True;
2611 return NT_STATUS_NOT_IMPLEMENTED;