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 2 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,
383 LSA_TRANS_NAME_ENUM2 *names,
386 r_l->ptr_dom_ref = ref ? 1 : 0;
389 r_l->mapped_count = mapped_count;
392 /***************************************************************************
393 Init_reply_lookup_sids.
394 ***************************************************************************/
396 static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l,
398 LSA_TRANS_NAME_ENUM2 *names,
401 r_l->ptr_dom_ref = ref ? 1 : 0;
404 r_l->mapped_count = mapped_count;
407 /***************************************************************************
408 Init_reply_lookup_sids.
409 ***************************************************************************/
411 static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx,
412 LSA_R_LOOKUP_SIDS *r_l,
414 LSA_TRANS_NAME_ENUM2 *names,
417 LSA_TRANS_NAME_ENUM *oldnames = TALLOC_ZERO_P(mem_ctx, LSA_TRANS_NAME_ENUM);
420 return NT_STATUS_NO_MEMORY;
423 oldnames->num_entries = names->num_entries;
424 oldnames->ptr_trans_names = names->ptr_trans_names;
425 oldnames->num_entries2 = names->num_entries2;
426 oldnames->uni_name = names->uni_name;
428 if (names->num_entries) {
431 oldnames->name = TALLOC_ARRAY(oldnames, LSA_TRANS_NAME, names->num_entries);
433 if (!oldnames->name) {
434 return NT_STATUS_NO_MEMORY;
436 for (i = 0; i < names->num_entries; i++) {
437 oldnames->name[i].sid_name_use = names->name[i].sid_name_use;
438 oldnames->name[i].hdr_name = names->name[i].hdr_name;
439 oldnames->name[i].domain_idx = names->name[i].domain_idx;
443 r_l->ptr_dom_ref = ref ? 1 : 0;
445 r_l->names = oldnames;
446 r_l->mapped_count = mapped_count;
450 static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size)
452 DOM_SID local_adm_sid;
460 init_sec_access(&mask, POLICY_EXECUTE);
461 init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
463 sid_copy(&adm_sid, get_global_sam_sid());
464 sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS);
465 init_sec_access(&mask, POLICY_ALL_ACCESS);
466 init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
468 sid_copy(&local_adm_sid, &global_sid_Builtin);
469 sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS);
470 init_sec_access(&mask, POLICY_ALL_ACCESS);
471 init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
473 if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL)
474 return NT_STATUS_NO_MEMORY;
476 if((*sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL, psa, sd_size)) == NULL)
477 return NT_STATUS_NO_MEMORY;
482 #if 0 /* AD DC work in ongoing in Samba 4 */
484 /***************************************************************************
486 ***************************************************************************/
488 static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name,
489 const char *dns_name, const char *forest_name,
490 struct GUID *dom_guid, DOM_SID *dom_sid)
492 if (nb_name && *nb_name) {
493 init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE);
494 init_uni_hdr(&r_l->hdr_nb_dom_name, &r_l->uni_nb_dom_name);
495 r_l->hdr_nb_dom_name.uni_max_len += 2;
496 r_l->uni_nb_dom_name.uni_max_len += 1;
499 if (dns_name && *dns_name) {
500 init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE);
501 init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name);
502 r_l->hdr_dns_dom_name.uni_max_len += 2;
503 r_l->uni_dns_dom_name.uni_max_len += 1;
506 if (forest_name && *forest_name) {
507 init_unistr2(&r_l->uni_forest_name, forest_name, UNI_FLAGS_NONE);
508 init_uni_hdr(&r_l->hdr_forest_name, &r_l->uni_forest_name);
509 r_l->hdr_forest_name.uni_max_len += 2;
510 r_l->uni_forest_name.uni_max_len += 1;
513 /* how do we init the guid ? probably should write an init fn */
515 memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID));
519 r_l->ptr_dom_sid = 1;
520 init_dom_sid2(&r_l->dom_sid, dom_sid);
523 #endif /* AD DC work in ongoing in Samba 4 */
526 /***************************************************************************
528 ***************************************************************************/
530 NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u)
532 struct lsa_info *info;
533 SEC_DESC *psd = NULL;
535 uint32 des_access=q_u->des_access;
540 /* map the generic bits to the lsa policy ones */
541 se_map_generic(&des_access, &lsa_generic_mapping);
543 /* get the generic lsa policy SD until we store it */
544 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
546 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
547 if (p->pipe_user.ut.uid != sec_initial_uid()) {
550 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
551 acc_granted, des_access));
552 DEBUGADD(4,("but overwritten by euid == 0\n"));
555 /* This is needed for lsa_open_account and rpcclient .... :-) */
557 if (p->pipe_user.ut.uid == sec_initial_uid())
558 acc_granted = POLICY_ALL_ACCESS;
560 /* associate the domain SID with the (unique) handle. */
561 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
562 return NT_STATUS_NO_MEMORY;
565 sid_copy(&info->sid,get_global_sam_sid());
566 info->access = acc_granted;
568 /* set up the LSA QUERY INFO response */
569 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
570 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
575 /***************************************************************************
577 ***************************************************************************/
579 NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u)
581 struct lsa_info *info;
582 SEC_DESC *psd = NULL;
584 uint32 des_access=q_u->des_access;
589 /* map the generic bits to the lsa policy ones */
590 se_map_generic(&des_access, &lsa_generic_mapping);
592 /* get the generic lsa policy SD until we store it */
593 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
595 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
596 if (geteuid() != 0) {
599 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
600 acc_granted, des_access));
601 DEBUGADD(4,("but overwritten by euid == 0\n"));
602 acc_granted = des_access;
605 /* associate the domain SID with the (unique) handle. */
606 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
607 return NT_STATUS_NO_MEMORY;
610 sid_copy(&info->sid,get_global_sam_sid());
611 info->access = acc_granted;
613 /* set up the LSA QUERY INFO response */
614 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
615 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
620 /***************************************************************************
621 _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA.
623 ***************************************************************************/
625 NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u,
626 LSA_R_ENUM_TRUST_DOM *r_u)
628 struct lsa_info *info;
630 struct trustdom_info **domains;
633 * preferred length is set to 5 as a "our" preferred length
634 * nt sets this parameter to 2
635 * update (20.08.2002): it's not preferred length, but preferred size!
636 * it needs further investigation how to optimally choose this value
638 uint32 max_num_domains =
639 q_u->preferred_len < 5 ? q_u->preferred_len : 10;
644 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
645 return NT_STATUS_INVALID_HANDLE;
647 /* check if the user have enough rights */
648 if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION))
649 return NT_STATUS_ACCESS_DENIED;
651 nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains);
653 if (!NT_STATUS_IS_OK(nt_status)) {
657 if (q_u->enum_context < num_domains) {
658 num_thistime = MIN(num_domains, max_num_domains);
660 r_u->status = STATUS_MORE_ENTRIES;
662 if (q_u->enum_context + num_thistime > num_domains) {
663 num_thistime = num_domains - q_u->enum_context;
664 r_u->status = NT_STATUS_OK;
667 next_idx = q_u->enum_context + num_thistime;
670 next_idx = 0xffffffff;
671 r_u->status = NT_STATUS_NO_MORE_ENTRIES;
674 /* set up the lsa_enum_trust_dom response */
676 init_r_enum_trust_dom(p->mem_ctx, r_u, next_idx,
677 num_thistime, domains+q_u->enum_context);
682 /***************************************************************************
683 _lsa_query_info. See the POLICY_INFOMATION_CLASS docs at msdn.
684 ***************************************************************************/
686 NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u)
688 struct lsa_info *handle;
689 LSA_INFO_CTR *ctr = &r_u->ctr;
694 r_u->status = NT_STATUS_OK;
696 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
697 return NT_STATUS_INVALID_HANDLE;
699 switch (q_u->info_class) {
703 uint32 policy_def = LSA_AUDIT_POLICY_ALL;
705 /* check if the user have enough rights */
706 if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) {
707 DEBUG(10,("_lsa_query_info: insufficient access rights\n"));
708 return NT_STATUS_ACCESS_DENIED;
711 /* fake info: We audit everything. ;) */
712 ctr->info.id2.ptr = 1;
713 ctr->info.id2.auditing_enabled = True;
714 ctr->info.id2.count1 = ctr->info.id2.count2 = LSA_AUDIT_NUM_CATEGORIES;
716 if ((ctr->info.id2.auditsettings = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, LSA_AUDIT_NUM_CATEGORIES)) == NULL)
717 return NT_STATUS_NO_MEMORY;
719 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def;
720 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def;
721 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_LOGON] = policy_def;
722 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def;
723 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def;
724 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def;
725 ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def;
730 /* check if the user have enough rights */
731 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
732 return NT_STATUS_ACCESS_DENIED;
734 /* Request PolicyPrimaryDomainInformation. */
735 switch (lp_server_role()) {
736 case ROLE_DOMAIN_PDC:
737 case ROLE_DOMAIN_BDC:
738 name = get_global_sam_name();
739 sid = get_global_sam_sid();
741 case ROLE_DOMAIN_MEMBER:
742 name = lp_workgroup();
743 /* We need to return the Domain SID here. */
744 if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid))
747 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
749 case ROLE_STANDALONE:
750 name = lp_workgroup();
754 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
756 init_dom_query_3(&r_u->ctr.info.id3, name, sid);
759 /* check if the user have enough rights */
760 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
761 return NT_STATUS_ACCESS_DENIED;
763 /* Request PolicyAccountDomainInformation. */
764 name = get_global_sam_name();
765 sid = get_global_sam_sid();
766 init_dom_query_5(&r_u->ctr.info.id5, name, sid);
769 /* check if the user have enough rights */
770 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
771 return NT_STATUS_ACCESS_DENIED;
773 switch (lp_server_role()) {
774 case ROLE_DOMAIN_BDC:
776 * only a BDC is a backup controller
777 * of the domain, it controls.
779 ctr->info.id6.server_role = 2;
783 * any other role is a primary
784 * of the domain, it controls.
786 ctr->info.id6.server_role = 3;
791 DEBUG(0,("_lsa_query_info: unknown info level in Lsa Query: %d\n", q_u->info_class));
792 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
796 if (NT_STATUS_IS_OK(r_u->status)) {
797 r_u->dom_ptr = 0x22000000; /* bizarre */
798 ctr->info_class = q_u->info_class;
804 /***************************************************************************
805 _lsa_lookup_sids_internal
806 ***************************************************************************/
808 static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p,
809 uint16 level, /* input */
810 int num_sids, /* input */
811 const DOM_SID2 *sid, /* input */
812 DOM_R_REF **pp_ref, /* output */
813 LSA_TRANS_NAME_ENUM2 **pp_names, /* output */
814 uint32 *pp_mapped_count)
818 const DOM_SID **sids = NULL;
819 LSA_TRANS_NAME_ENUM2 *names = NULL;
820 DOM_R_REF *ref = NULL;
821 uint32 mapped_count = 0;
822 struct lsa_dom_info *dom_infos = NULL;
823 struct lsa_name_info *name_infos = NULL;
825 *pp_mapped_count = 0;
829 names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2);
830 sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids);
831 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
833 if (sids == NULL || names == NULL || ref == NULL) {
834 return NT_STATUS_NO_MEMORY;
837 for (i=0; i<num_sids; i++) {
838 sids[i] = &sid[i].sid;
841 status = lookup_sids(p->mem_ctx, num_sids, sids, level,
842 &dom_infos, &name_infos);
844 if (!NT_STATUS_IS_OK(status)) {
849 names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME2, num_sids);
850 names->uni_name = TALLOC_ARRAY(names, UNISTR2, num_sids);
851 if ((names->name == NULL) || (names->uni_name == NULL)) {
852 return NT_STATUS_NO_MEMORY;
856 for (i=0; i<MAX_REF_DOMAINS; i++) {
858 if (!dom_infos[i].valid) {
862 if (init_dom_ref(ref, dom_infos[i].name,
863 &dom_infos[i].sid) != i) {
864 DEBUG(0, ("Domain %s mentioned twice??\n",
866 return NT_STATUS_INTERNAL_ERROR;
870 for (i=0; i<num_sids; i++) {
871 struct lsa_name_info *name = &name_infos[i];
873 if (name->type == SID_NAME_UNKNOWN) {
875 /* Unknown sids should return the string
876 * representation of the SID. Windows 2003 behaves
877 * rather erratic here, in many cases it returns the
878 * RID as 8 bytes hex, in others it returns the full
879 * SID. We (Jerry/VL) could not figure out which the
880 * hard cases are, so leave it with the SID. */
881 name->name = talloc_asprintf(p->mem_ctx, "%s",
882 sid_string_static(sids[i]));
883 if (name->name == NULL) {
884 return NT_STATUS_NO_MEMORY;
889 init_lsa_trans_name2(&names->name[i], &names->uni_name[i],
890 name->type, name->name, name->dom_idx);
893 names->num_entries = num_sids;
894 names->ptr_trans_names = 1;
895 names->num_entries2 = num_sids;
897 status = NT_STATUS_NONE_MAPPED;
898 if (mapped_count > 0) {
899 status = (mapped_count < num_sids) ?
900 STATUS_SOME_UNMAPPED : NT_STATUS_OK;
903 DEBUG(10, ("num_sids %d, mapped_count %d, status %s\n",
904 num_sids, mapped_count, nt_errstr(status)));
906 *pp_mapped_count = mapped_count;
913 /***************************************************************************
915 ***************************************************************************/
917 NTSTATUS _lsa_lookup_sids(pipes_struct *p,
918 LSA_Q_LOOKUP_SIDS *q_u,
919 LSA_R_LOOKUP_SIDS *r_u)
921 struct lsa_info *handle;
922 int num_sids = q_u->sids.num_entries;
923 uint32 mapped_count = 0;
924 DOM_R_REF *ref = NULL;
925 LSA_TRANS_NAME_ENUM2 *names = NULL;
928 if ((q_u->level < 1) || (q_u->level > 6)) {
929 return NT_STATUS_INVALID_PARAMETER;
932 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
933 return NT_STATUS_INVALID_HANDLE;
936 /* check if the user has enough rights */
937 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
938 return NT_STATUS_ACCESS_DENIED;
941 if (num_sids > MAX_LOOKUP_SIDS) {
942 DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n",
943 MAX_LOOKUP_SIDS, num_sids));
944 return NT_STATUS_NONE_MAPPED;
947 r_u->status = _lsa_lookup_sids_internal(p,
955 /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */
957 status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, names, mapped_count);
958 if (!NT_STATUS_IS_OK(status)) {
964 /***************************************************************************
966 ***************************************************************************/
968 NTSTATUS _lsa_lookup_sids2(pipes_struct *p,
969 LSA_Q_LOOKUP_SIDS2 *q_u,
970 LSA_R_LOOKUP_SIDS2 *r_u)
972 struct lsa_info *handle;
973 int num_sids = q_u->sids.num_entries;
974 uint32 mapped_count = 0;
975 DOM_R_REF *ref = NULL;
976 LSA_TRANS_NAME_ENUM2 *names = NULL;
978 if ((q_u->level < 1) || (q_u->level > 6)) {
979 return NT_STATUS_INVALID_PARAMETER;
982 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
983 return NT_STATUS_INVALID_HANDLE;
986 /* check if the user have enough rights */
987 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
988 return NT_STATUS_ACCESS_DENIED;
991 if (num_sids > MAX_LOOKUP_SIDS) {
992 DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n",
993 MAX_LOOKUP_SIDS, num_sids));
994 return NT_STATUS_NONE_MAPPED;
997 r_u->status = _lsa_lookup_sids_internal(p,
1005 init_reply_lookup_sids2(r_u, ref, names, mapped_count);
1009 /***************************************************************************
1012 Before someone actually re-activates this, please present a sniff showing
1013 this call against some Windows server. I (vl) could not make it work against
1015 ***************************************************************************/
1017 NTSTATUS _lsa_lookup_sids3(pipes_struct *p,
1018 LSA_Q_LOOKUP_SIDS3 *q_u,
1019 LSA_R_LOOKUP_SIDS3 *r_u)
1021 uint32 mapped_count = 0;
1023 LSA_TRANS_NAME_ENUM2 *names;
1025 if ((q_u->level < 1) || (q_u->level > 6)) {
1026 return NT_STATUS_INVALID_PARAMETER;
1029 r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED;
1031 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1032 names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2);
1034 if ((ref == NULL) || (names == NULL)) {
1035 /* We would segfault later on in lsa_io_r_lookup_sids3 anyway,
1036 * so do a planned exit here. We NEEEED pidl! */
1037 smb_panic("talloc failed");
1040 init_reply_lookup_sids3(r_u, ref, names, mapped_count);
1044 /***************************************************************************
1045 lsa_reply_lookup_names
1046 ***************************************************************************/
1048 NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u)
1050 struct lsa_info *handle;
1051 UNISTR2 *names = q_u->uni_name;
1052 uint32 num_entries = q_u->num_entries;
1055 uint32 mapped_count = 0;
1058 if (num_entries > MAX_LOOKUP_SIDS) {
1059 num_entries = MAX_LOOKUP_SIDS;
1060 DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries));
1063 /* Probably the lookup_level is some sort of bitmask. */
1064 if (q_u->lookup_level == 1) {
1065 flags = LOOKUP_NAME_ALL;
1068 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1069 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
1071 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1072 r_u->status = NT_STATUS_INVALID_HANDLE;
1076 /* check if the user have enough rights */
1077 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1078 r_u->status = NT_STATUS_ACCESS_DENIED;
1083 return NT_STATUS_NO_MEMORY;
1085 /* set up the LSA Lookup RIDs response */
1086 become_root(); /* lookup_name can require root privs */
1087 r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
1088 names, flags, &mapped_count);
1093 if (NT_STATUS_IS_OK(r_u->status) && (num_entries != 0) ) {
1094 if (mapped_count == 0)
1095 r_u->status = NT_STATUS_NONE_MAPPED;
1096 else if (mapped_count != num_entries)
1097 r_u->status = STATUS_SOME_UNMAPPED;
1100 init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count);
1104 /***************************************************************************
1105 lsa_reply_lookup_names2
1106 ***************************************************************************/
1108 NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOOKUP_NAMES2 *r_u)
1110 struct lsa_info *handle;
1111 UNISTR2 *names = q_u->uni_name;
1112 uint32 num_entries = q_u->num_entries;
1117 uint32 mapped_count = 0;
1120 if (num_entries > MAX_LOOKUP_SIDS) {
1121 num_entries = MAX_LOOKUP_SIDS;
1122 DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries));
1125 /* Probably the lookup_level is some sort of bitmask. */
1126 if (q_u->lookup_level == 1) {
1127 flags = LOOKUP_NAME_ALL;
1130 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1131 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
1132 rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries);
1134 if ((ref == NULL) || (rids == NULL) || (rids2 == NULL)) {
1135 r_u->status = NT_STATUS_NO_MEMORY;
1136 return NT_STATUS_NO_MEMORY;
1139 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1140 r_u->status = NT_STATUS_INVALID_HANDLE;
1144 /* check if the user have enough rights */
1145 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1146 r_u->status = NT_STATUS_ACCESS_DENIED;
1150 /* set up the LSA Lookup RIDs response */
1151 become_root(); /* lookup_name can require root privs */
1152 r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
1153 names, flags, &mapped_count);
1158 if (NT_STATUS_IS_OK(r_u->status)) {
1159 if (mapped_count == 0) {
1160 r_u->status = NT_STATUS_NONE_MAPPED;
1161 } else if (mapped_count != num_entries) {
1162 r_u->status = STATUS_SOME_UNMAPPED;
1166 /* Convert the rids array to rids2. */
1167 for (i = 0; i < num_entries; i++) {
1168 rids2[i].type = rids[i].type;
1169 rids2[i].rid = rids[i].rid;
1170 rids2[i].rid_idx = rids[i].rid_idx;
1171 rids2[i].unknown = 0;
1174 init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count);
1178 /***************************************************************************
1179 lsa_reply_lookup_names3.
1180 ***************************************************************************/
1182 NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u)
1184 struct lsa_info *handle;
1185 UNISTR2 *names = q_u->uni_name;
1186 uint32 num_entries = q_u->num_entries;
1187 DOM_R_REF *ref = NULL;
1188 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1189 uint32 mapped_count = 0;
1192 if (num_entries > MAX_LOOKUP_SIDS) {
1193 num_entries = MAX_LOOKUP_SIDS;
1194 DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries));
1197 /* Probably the lookup_level is some sort of bitmask. */
1198 if (q_u->lookup_level == 1) {
1199 flags = LOOKUP_NAME_ALL;
1202 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1203 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1205 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1206 r_u->status = NT_STATUS_INVALID_HANDLE;
1210 /* check if the user have enough rights */
1211 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1212 r_u->status = NT_STATUS_ACCESS_DENIED;
1216 if (!ref || !trans_sids) {
1217 return NT_STATUS_NO_MEMORY;
1220 /* set up the LSA Lookup SIDs response */
1221 become_root(); /* lookup_name can require root privs */
1222 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1223 names, flags, &mapped_count);
1228 if (NT_STATUS_IS_OK(r_u->status)) {
1229 if (mapped_count == 0) {
1230 r_u->status = NT_STATUS_NONE_MAPPED;
1231 } else if (mapped_count != num_entries) {
1232 r_u->status = STATUS_SOME_UNMAPPED;
1236 init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count);
1240 /***************************************************************************
1241 lsa_reply_lookup_names4.
1242 ***************************************************************************/
1244 NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u)
1246 UNISTR2 *names = q_u->uni_name;
1247 uint32 num_entries = q_u->num_entries;
1248 DOM_R_REF *ref = NULL;
1249 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1250 uint32 mapped_count = 0;
1253 if (num_entries > MAX_LOOKUP_SIDS) {
1254 num_entries = MAX_LOOKUP_SIDS;
1255 DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries));
1258 /* Probably the lookup_level is some sort of bitmask. */
1259 if (q_u->lookup_level == 1) {
1260 flags = LOOKUP_NAME_ALL;
1263 /* No policy handle on this call. Restrict to crypto connections. */
1264 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1265 DEBUG(0,("_lsa_lookup_names4: client %s not using schannel for netlogon\n",
1266 get_remote_machine_name() ));
1267 return NT_STATUS_INVALID_PARAMETER;
1270 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1271 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1273 if (!ref || !trans_sids) {
1274 return NT_STATUS_NO_MEMORY;
1277 /* set up the LSA Lookup SIDs response */
1278 become_root(); /* lookup_name can require root privs */
1279 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1280 names, flags, &mapped_count);
1283 if (NT_STATUS_IS_OK(r_u->status)) {
1284 if (mapped_count == 0) {
1285 r_u->status = NT_STATUS_NONE_MAPPED;
1286 } else if (mapped_count != num_entries) {
1287 r_u->status = STATUS_SOME_UNMAPPED;
1291 init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count);
1295 /***************************************************************************
1296 _lsa_close. Also weird - needs to check if lsa handle is correct. JRA.
1297 ***************************************************************************/
1299 NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r)
1301 if (!find_policy_by_hnd(p, r->in.handle, NULL)) {
1302 return NT_STATUS_INVALID_HANDLE;
1305 close_policy_hnd(p, r->in.handle);
1306 return NT_STATUS_OK;
1309 /***************************************************************************
1310 ***************************************************************************/
1312 NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct lsa_OpenSecret *r)
1314 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1317 /***************************************************************************
1318 ***************************************************************************/
1320 NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct lsa_OpenTrustedDomain *r)
1322 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1325 /***************************************************************************
1326 ***************************************************************************/
1328 NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, struct lsa_CreateTrustedDomain *r)
1330 return NT_STATUS_ACCESS_DENIED;
1333 /***************************************************************************
1334 ***************************************************************************/
1336 NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct lsa_CreateSecret *r)
1338 return NT_STATUS_ACCESS_DENIED;
1341 /***************************************************************************
1342 ***************************************************************************/
1344 NTSTATUS _lsa_SetSecret(pipes_struct *p, struct lsa_SetSecret *r)
1346 return NT_STATUS_ACCESS_DENIED;
1349 /***************************************************************************
1350 ***************************************************************************/
1352 NTSTATUS _lsa_delete_object(pipes_struct *p, LSA_Q_DELETE_OBJECT *q_u, LSA_R_DELETE_OBJECT *r_u)
1354 return NT_STATUS_ACCESS_DENIED;
1357 /***************************************************************************
1359 ***************************************************************************/
1361 NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u)
1363 struct lsa_info *handle;
1365 uint32 enum_context = q_u->enum_context;
1366 int num_privs = count_all_privileges();
1367 LSA_PRIV_ENTRY *entries = NULL;
1370 /* remember that the enum_context starts at 0 and not 1 */
1372 if ( enum_context >= num_privs )
1373 return NT_STATUS_NO_MORE_ENTRIES;
1375 DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n",
1376 enum_context, num_privs));
1378 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1379 return NT_STATUS_INVALID_HANDLE;
1381 /* check if the user have enough rights
1382 I don't know if it's the right one. not documented. */
1384 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1385 return NT_STATUS_ACCESS_DENIED;
1387 if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) )
1388 return NT_STATUS_NO_MEMORY;
1390 for (i = 0; i < num_privs; i++) {
1391 if( i < enum_context) {
1392 init_unistr2(&entries[i].name, NULL, UNI_FLAGS_NONE);
1393 init_uni_hdr(&entries[i].hdr_name, &entries[i].name);
1395 entries[i].luid_low = 0;
1396 entries[i].luid_high = 0;
1398 init_unistr2(&entries[i].name, privs[i].name, UNI_FLAGS_NONE);
1399 init_uni_hdr(&entries[i].hdr_name, &entries[i].name);
1401 luid = get_privilege_luid( &privs[i].se_priv );
1403 entries[i].luid_low = luid.luid.low;
1404 entries[i].luid_high = luid.luid.high;
1408 enum_context = num_privs;
1410 init_lsa_r_enum_privs(r_u, enum_context, num_privs, entries);
1412 return NT_STATUS_OK;
1415 /***************************************************************************
1416 _lsa_priv_get_dispname.
1417 ***************************************************************************/
1419 NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u)
1421 struct lsa_info *handle;
1423 const char *description;
1425 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1426 return NT_STATUS_INVALID_HANDLE;
1428 /* check if the user have enough rights */
1431 * I don't know if it's the right one. not documented.
1433 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1434 return NT_STATUS_ACCESS_DENIED;
1436 unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc));
1438 DEBUG(10,("_lsa_priv_get_dispname: name = %s\n", name_asc));
1440 description = get_privilege_dispname( name_asc );
1442 if ( description ) {
1443 DEBUG(10,("_lsa_priv_get_dispname: display name = %s\n", description));
1445 init_unistr2(&r_u->desc, description, UNI_FLAGS_NONE);
1446 init_uni_hdr(&r_u->hdr_desc, &r_u->desc);
1448 r_u->ptr_info = 0xdeadbeef;
1449 r_u->lang_id = q_u->lang_id;
1451 return NT_STATUS_OK;
1453 DEBUG(10,("_lsa_priv_get_dispname: doesn't exist\n"));
1457 return NT_STATUS_NO_SUCH_PRIVILEGE;
1461 /***************************************************************************
1463 ***************************************************************************/
1465 NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u)
1467 struct lsa_info *handle;
1469 int i, j, num_entries;
1470 LSA_SID_ENUM *sids=&r_u->sids;
1473 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1474 return NT_STATUS_INVALID_HANDLE;
1476 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1477 return NT_STATUS_ACCESS_DENIED;
1482 /* The only way we can currently find out all the SIDs that have been
1483 privileged is to scan all privileges */
1485 if (!NT_STATUS_IS_OK(ret = privilege_enumerate_accounts(&sid_list, &num_entries))) {
1489 if (q_u->enum_context >= num_entries)
1490 return NT_STATUS_NO_MORE_ENTRIES;
1492 sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context);
1493 sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context);
1495 if (sids->ptr_sid==NULL || sids->sid==NULL) {
1496 SAFE_FREE(sid_list);
1497 return NT_STATUS_NO_MEMORY;
1500 for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) {
1501 init_dom_sid2(&(*sids).sid[j], &sid_list[i]);
1502 (*sids).ptr_sid[j] = 1;
1505 SAFE_FREE(sid_list);
1507 init_lsa_r_enum_accounts(r_u, num_entries);
1509 return NT_STATUS_OK;
1513 NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u)
1515 const char *username, *domname;
1516 user_struct *vuser = get_valid_user_struct(p->vuid);
1519 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1523 * I'm 99% sure this is not the right place to do this,
1524 * global_sid_Anonymous should probably be put into the token
1525 * instead of the guest id -- vl
1527 if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous,
1528 &domname, &username, NULL)) {
1529 return NT_STATUS_NO_MEMORY;
1532 username = vuser->user.smb_name;
1533 domname = vuser->user.domain;
1536 r_u->ptr_user_name = 1;
1537 init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE);
1538 init_uni_hdr(&r_u->hdr_user_name, &r_u->uni2_user_name);
1542 r_u->ptr_dom_name = 1;
1543 init_unistr2(&r_u->uni2_dom_name, domname, UNI_STR_TERMINATE);
1544 init_uni_hdr(&r_u->hdr_dom_name, &r_u->uni2_dom_name);
1546 r_u->status = NT_STATUS_OK;
1551 /***************************************************************************
1553 ***************************************************************************/
1555 NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CREATEACCOUNT *r_u)
1557 struct lsa_info *handle;
1558 struct lsa_info *info;
1560 /* find the connection policy handle. */
1561 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1562 return NT_STATUS_INVALID_HANDLE;
1564 /* check if the user have enough rights */
1567 * I don't know if it's the right one. not documented.
1568 * but guessed with rpcclient.
1570 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) {
1571 DEBUG(10, ("_lsa_create_account: No POLICY_GET_PRIVATE_INFORMATION access right!\n"));
1572 return NT_STATUS_ACCESS_DENIED;
1575 /* check to see if the pipe_user is a Domain Admin since
1576 account_pol.tdb was already opened as root, this is all we have */
1578 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) {
1579 DEBUG(10, ("_lsa_create_account: The use is not a Domain Admin, deny access!\n"));
1580 return NT_STATUS_ACCESS_DENIED;
1583 if ( is_privileged_sid( &q_u->sid.sid ) ) {
1584 DEBUG(10, ("_lsa_create_account: Policy account already exists!\n"));
1585 return NT_STATUS_OBJECT_NAME_COLLISION;
1588 /* associate the user/group SID with the (unique) handle. */
1590 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1591 return NT_STATUS_NO_MEMORY;
1594 info->sid = q_u->sid.sid;
1595 info->access = q_u->access;
1597 /* get a (unique) handle. open a policy on it. */
1598 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
1599 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1601 DEBUG(10, ("_lsa_create_account: call privileges code to create an account\n"));
1602 return privilege_create_account( &info->sid );
1606 /***************************************************************************
1608 ***************************************************************************/
1610 NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u)
1612 struct lsa_info *handle;
1613 struct lsa_info *info;
1615 /* find the connection policy handle. */
1616 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1617 return NT_STATUS_INVALID_HANDLE;
1619 /* check if the user have enough rights */
1622 * I don't know if it's the right one. not documented.
1623 * but guessed with rpcclient.
1625 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
1626 return NT_STATUS_ACCESS_DENIED;
1628 /* TODO: Fis the parsing routine before reenabling this check! */
1630 if (!lookup_sid(&handle->sid, dom_name, name, &type))
1631 return NT_STATUS_ACCESS_DENIED;
1633 /* associate the user/group SID with the (unique) handle. */
1634 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1635 return NT_STATUS_NO_MEMORY;
1638 info->sid = q_u->sid.sid;
1639 info->access = q_u->access;
1641 /* get a (unique) handle. open a policy on it. */
1642 if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info))
1643 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1645 return NT_STATUS_OK;
1648 /***************************************************************************
1649 For a given SID, enumerate all the privilege this account has.
1650 ***************************************************************************/
1652 NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u)
1654 struct lsa_info *info=NULL;
1656 PRIVILEGE_SET privileges;
1658 /* find the connection policy handle. */
1659 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1660 return NT_STATUS_INVALID_HANDLE;
1662 if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) )
1663 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1665 privilege_set_init( &privileges );
1667 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
1669 DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n",
1670 sid_string_static(&info->sid), privileges.count));
1672 r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0);
1675 r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE;
1677 privilege_set_free( &privileges );
1682 /***************************************************************************
1684 ***************************************************************************/
1686 NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u)
1688 struct lsa_info *info=NULL;
1690 /* find the connection policy handle. */
1692 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1693 return NT_STATUS_INVALID_HANDLE;
1695 if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL))
1696 return NT_STATUS_OK;
1699 0x01 -> Log on locally
1700 0x02 -> Access this computer from network
1701 0x04 -> Log on as a batch job
1702 0x10 -> Log on as a service
1704 they can be ORed together
1707 r_u->access = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK;
1709 return NT_STATUS_OK;
1712 /***************************************************************************
1713 update the systemaccount information
1714 ***************************************************************************/
1716 NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA_R_SETSYSTEMACCOUNT *r_u)
1718 struct lsa_info *info=NULL;
1720 r_u->status = NT_STATUS_OK;
1722 /* find the connection policy handle. */
1723 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1724 return NT_STATUS_INVALID_HANDLE;
1726 /* check to see if the pipe_user is a Domain Admin since
1727 account_pol.tdb was already opened as root, this is all we have */
1729 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1730 return NT_STATUS_ACCESS_DENIED;
1732 if (!pdb_getgrsid(&map, info->sid))
1733 return NT_STATUS_NO_SUCH_GROUP;
1735 return pdb_update_group_mapping_entry(&map);
1738 /***************************************************************************
1739 For a given SID, add some privileges.
1740 ***************************************************************************/
1742 NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u)
1744 struct lsa_info *info = NULL;
1746 PRIVILEGE_SET *set = NULL;
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 root or a Domain Admin since
1753 account_pol.tdb was already opened as root, this is all we have */
1755 if ( p->pipe_user.ut.uid != sec_initial_uid()
1756 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1758 return NT_STATUS_ACCESS_DENIED;
1763 if ( !privilege_set_to_se_priv( &mask, set ) )
1764 return NT_STATUS_NO_SUCH_PRIVILEGE;
1766 if ( !grant_privilege( &info->sid, &mask ) ) {
1767 DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n",
1768 sid_string_static(&info->sid) ));
1769 DEBUG(3,("Privilege mask:\n"));
1770 dump_se_priv( DBGC_ALL, 3, &mask );
1771 return NT_STATUS_NO_SUCH_PRIVILEGE;
1774 return NT_STATUS_OK;
1777 /***************************************************************************
1778 For a given SID, remove some privileges.
1779 ***************************************************************************/
1781 NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u)
1783 struct lsa_info *info = NULL;
1785 PRIVILEGE_SET *set = NULL;
1787 /* find the connection policy handle. */
1788 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1789 return NT_STATUS_INVALID_HANDLE;
1791 /* check to see if the pipe_user is root or a Domain Admin since
1792 account_pol.tdb was already opened as root, this is all we have */
1794 if ( p->pipe_user.ut.uid != sec_initial_uid()
1795 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1797 return NT_STATUS_ACCESS_DENIED;
1802 if ( !privilege_set_to_se_priv( &mask, set ) )
1803 return NT_STATUS_NO_SUCH_PRIVILEGE;
1805 if ( !revoke_privilege( &info->sid, &mask ) ) {
1806 DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n",
1807 sid_string_static(&info->sid) ));
1808 DEBUG(3,("Privilege mask:\n"));
1809 dump_se_priv( DBGC_ALL, 3, &mask );
1810 return NT_STATUS_NO_SUCH_PRIVILEGE;
1813 return NT_STATUS_OK;
1816 /***************************************************************************
1817 For a given SID, remove some privileges.
1818 ***************************************************************************/
1820 NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUERY_SEC_OBJ *r_u)
1822 struct lsa_info *handle=NULL;
1823 SEC_DESC *psd = NULL;
1827 r_u->status = NT_STATUS_OK;
1829 /* find the connection policy handle. */
1830 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1831 return NT_STATUS_INVALID_HANDLE;
1833 /* check if the user have enough rights */
1834 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1835 return NT_STATUS_ACCESS_DENIED;
1838 switch (q_u->sec_info) {
1840 /* SD contains only the owner */
1842 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1843 if(!NT_STATUS_IS_OK(status))
1844 return NT_STATUS_NO_MEMORY;
1847 if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1848 return NT_STATUS_NO_MEMORY;
1851 /* SD contains only the ACL */
1853 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1854 if(!NT_STATUS_IS_OK(status))
1855 return NT_STATUS_NO_MEMORY;
1857 if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1858 return NT_STATUS_NO_MEMORY;
1861 return NT_STATUS_INVALID_LEVEL;
1869 #if 0 /* AD DC work in ongoing in Samba 4 */
1871 /***************************************************************************
1872 ***************************************************************************/
1874 NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u)
1876 struct lsa_info *handle;
1877 const char *nb_name;
1878 char *dns_name = NULL;
1879 char *forest_name = NULL;
1880 DOM_SID *sid = NULL;
1885 r_u->status = NT_STATUS_OK;
1887 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1888 return NT_STATUS_INVALID_HANDLE;
1890 switch (q_u->info_class) {
1892 /* check if the user have enough rights */
1893 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1894 return NT_STATUS_ACCESS_DENIED;
1896 /* Request PolicyPrimaryDomainInformation. */
1897 switch (lp_server_role()) {
1898 case ROLE_DOMAIN_PDC:
1899 case ROLE_DOMAIN_BDC:
1900 nb_name = get_global_sam_name();
1901 /* ugly temp hack for these next two */
1903 /* This should be a 'netbios domain -> DNS domain' mapping */
1904 dnsdomname[0] = '\0';
1905 get_mydnsdomname(dnsdomname);
1906 strlower_m(dnsdomname);
1908 dns_name = dnsdomname;
1909 forest_name = dnsdomname;
1911 sid = get_global_sam_sid();
1912 secrets_fetch_domain_guid(lp_workgroup(), &guid);
1915 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1917 init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name,
1918 forest_name,&guid,sid);
1921 DEBUG(0,("_lsa_query_info2: unknown info level in Lsa Query: %d\n", q_u->info_class));
1922 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1926 if (NT_STATUS_IS_OK(r_u->status)) {
1928 r_u->info_class = q_u->info_class;
1933 #endif /* AD DC work in ongoing in Samba 4 */
1935 /***************************************************************************
1936 ***************************************************************************/
1938 NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u)
1940 struct lsa_info *info = NULL;
1944 UNISTR4_ARRAY *uni_privnames = q_u->rights;
1947 /* find the connection policy handle. */
1948 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1949 return NT_STATUS_INVALID_HANDLE;
1951 /* check to see if the pipe_user is a Domain Admin since
1952 account_pol.tdb was already opened as root, this is all we have */
1954 if ( p->pipe_user.ut.uid != sec_initial_uid()
1955 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1957 return NT_STATUS_ACCESS_DENIED;
1960 /* according to an NT4 PDC, you can add privileges to SIDs even without
1961 call_lsa_create_account() first. And you can use any arbitrary SID. */
1963 sid_copy( &sid, &q_u->sid.sid );
1965 /* just a little sanity check */
1967 if ( q_u->count != uni_privnames->count ) {
1968 DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n"));
1969 return NT_STATUS_INVALID_HANDLE;
1972 for ( i=0; i<q_u->count; i++ ) {
1973 UNISTR4 *uni4_str = &uni_privnames->strings[i];
1975 /* only try to add non-null strings */
1977 if ( !uni4_str->string )
1980 rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE );
1982 if ( !grant_privilege_by_name( &sid, privname ) ) {
1983 DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname ));
1984 return NT_STATUS_NO_SUCH_PRIVILEGE;
1988 return NT_STATUS_OK;
1991 /***************************************************************************
1992 ***************************************************************************/
1994 NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u)
1996 struct lsa_info *info = NULL;
2000 UNISTR4_ARRAY *uni_privnames = q_u->rights;
2003 /* find the connection policy handle. */
2004 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2005 return NT_STATUS_INVALID_HANDLE;
2007 /* check to see if the pipe_user is a Domain Admin since
2008 account_pol.tdb was already opened as root, this is all we have */
2010 if ( p->pipe_user.ut.uid != sec_initial_uid()
2011 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
2013 return NT_STATUS_ACCESS_DENIED;
2016 sid_copy( &sid, &q_u->sid.sid );
2018 if ( q_u->removeall ) {
2019 if ( !revoke_all_privileges( &sid ) )
2020 return NT_STATUS_ACCESS_DENIED;
2022 return NT_STATUS_OK;
2025 /* just a little sanity check */
2027 if ( q_u->count != uni_privnames->count ) {
2028 DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n"));
2029 return NT_STATUS_INVALID_HANDLE;
2032 for ( i=0; i<q_u->count; i++ ) {
2033 UNISTR4 *uni4_str = &uni_privnames->strings[i];
2035 /* only try to add non-null strings */
2037 if ( !uni4_str->string )
2040 rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE );
2042 if ( !revoke_privilege_by_name( &sid, privname ) ) {
2043 DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname ));
2044 return NT_STATUS_NO_SUCH_PRIVILEGE;
2048 return NT_STATUS_OK;
2052 /***************************************************************************
2053 ***************************************************************************/
2055 NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u)
2057 struct lsa_info *info = NULL;
2059 PRIVILEGE_SET privileges;
2063 /* find the connection policy handle. */
2065 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2066 return NT_STATUS_INVALID_HANDLE;
2068 /* according to an NT4 PDC, you can add privileges to SIDs even without
2069 call_lsa_create_account() first. And you can use any arbitrary SID. */
2071 sid_copy( &sid, &q_u->sid.sid );
2073 if ( !get_privileges_for_sids( &mask, &sid, 1 ) )
2074 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
2076 privilege_set_init( &privileges );
2078 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
2080 DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n",
2081 sid_string_static(&sid), privileges.count));
2083 r_u->status = init_r_enum_acct_rights( r_u, &privileges );
2086 r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE;
2088 privilege_set_free( &privileges );
2094 /***************************************************************************
2095 ***************************************************************************/
2097 NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u)
2099 struct lsa_info *info = NULL;
2101 LUID_ATTR priv_luid;
2104 /* find the connection policy handle. */
2106 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2107 return NT_STATUS_INVALID_HANDLE;
2109 unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name));
2111 DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name));
2113 if ( !se_priv_from_name( name, &mask ) )
2114 return NT_STATUS_NO_SUCH_PRIVILEGE;
2116 priv_luid = get_privilege_luid( &mask );
2118 r_u->luid.low = priv_luid.luid.low;
2119 r_u->luid.high = priv_luid.luid.high;
2122 return NT_STATUS_OK;
2127 * From here on the server routines are just dummy ones to make smbd link with
2128 * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are
2129 * pulling the server stubs across one by one.
2132 NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r)
2134 p->rng_fault_state = True;
2135 return NT_STATUS_NOT_IMPLEMENTED;
2138 NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct lsa_EnumPrivs *r)
2140 p->rng_fault_state = True;
2141 return NT_STATUS_NOT_IMPLEMENTED;
2144 NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct lsa_QuerySecurity *r)
2146 p->rng_fault_state = True;
2147 return NT_STATUS_NOT_IMPLEMENTED;
2150 NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r)
2152 p->rng_fault_state = True;
2153 return NT_STATUS_NOT_IMPLEMENTED;
2156 NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r)
2158 p->rng_fault_state = True;
2159 return NT_STATUS_NOT_IMPLEMENTED;
2162 NTSTATUS _lsa_OpenPolicy(pipes_struct *p, struct lsa_OpenPolicy *r)
2164 p->rng_fault_state = True;
2165 return NT_STATUS_NOT_IMPLEMENTED;
2168 NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct lsa_QueryInfoPolicy *r)
2170 p->rng_fault_state = True;
2171 return NT_STATUS_NOT_IMPLEMENTED;
2174 NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p, struct lsa_SetInfoPolicy *r)
2176 p->rng_fault_state = True;
2177 return NT_STATUS_NOT_IMPLEMENTED;
2180 NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r)
2182 p->rng_fault_state = True;
2183 return NT_STATUS_NOT_IMPLEMENTED;
2186 NTSTATUS _lsa_CreateAccount(pipes_struct *p, struct lsa_CreateAccount *r)
2188 p->rng_fault_state = True;
2189 return NT_STATUS_NOT_IMPLEMENTED;
2192 NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r)
2194 p->rng_fault_state = True;
2195 return NT_STATUS_NOT_IMPLEMENTED;
2198 NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct lsa_EnumTrustDom *r)
2200 p->rng_fault_state = True;
2201 return NT_STATUS_NOT_IMPLEMENTED;
2204 NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r)
2206 p->rng_fault_state = True;
2207 return NT_STATUS_NOT_IMPLEMENTED;
2210 NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r)
2212 p->rng_fault_state = True;
2213 return NT_STATUS_NOT_IMPLEMENTED;
2216 NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct lsa_OpenAccount *r)
2218 p->rng_fault_state = True;
2219 return NT_STATUS_NOT_IMPLEMENTED;
2222 NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r)
2224 p->rng_fault_state = True;
2225 return NT_STATUS_NOT_IMPLEMENTED;
2228 NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r)
2230 p->rng_fault_state = True;
2231 return NT_STATUS_NOT_IMPLEMENTED;
2234 NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct lsa_RemovePrivilegesFromAccount *r)
2236 p->rng_fault_state = True;
2237 return NT_STATUS_NOT_IMPLEMENTED;
2240 NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r)
2242 p->rng_fault_state = True;
2243 return NT_STATUS_NOT_IMPLEMENTED;
2246 NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccount *r)
2248 p->rng_fault_state = True;
2249 return NT_STATUS_NOT_IMPLEMENTED;
2252 NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccessAccount *r)
2254 p->rng_fault_state = True;
2255 return NT_STATUS_NOT_IMPLEMENTED;
2258 NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, struct lsa_SetSystemAccessAccount *r)
2260 p->rng_fault_state = True;
2261 return NT_STATUS_NOT_IMPLEMENTED;
2264 NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r)
2266 p->rng_fault_state = True;
2267 return NT_STATUS_NOT_IMPLEMENTED;
2270 NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p, struct lsa_SetInformationTrustedDomain *r)
2272 p->rng_fault_state = True;
2273 return NT_STATUS_NOT_IMPLEMENTED;
2276 NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r)
2278 p->rng_fault_state = True;
2279 return NT_STATUS_NOT_IMPLEMENTED;
2282 NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct lsa_LookupPrivValue *r)
2284 p->rng_fault_state = True;
2285 return NT_STATUS_NOT_IMPLEMENTED;
2288 NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r)
2290 p->rng_fault_state = True;
2291 return NT_STATUS_NOT_IMPLEMENTED;
2294 NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct lsa_LookupPrivDisplayName *r)
2296 p->rng_fault_state = True;
2297 return NT_STATUS_NOT_IMPLEMENTED;
2300 NTSTATUS _lsa_DeleteObject(pipes_struct *p, struct lsa_DeleteObject *r)
2302 p->rng_fault_state = True;
2303 return NT_STATUS_NOT_IMPLEMENTED;
2306 NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r)
2308 p->rng_fault_state = True;
2309 return NT_STATUS_NOT_IMPLEMENTED;
2312 NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r)
2314 p->rng_fault_state = True;
2315 return NT_STATUS_NOT_IMPLEMENTED;
2318 NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct lsa_AddAccountRights *r)
2320 p->rng_fault_state = True;
2321 return NT_STATUS_NOT_IMPLEMENTED;
2324 NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r)
2326 p->rng_fault_state = True;
2327 return NT_STATUS_NOT_IMPLEMENTED;
2330 NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r)
2332 p->rng_fault_state = True;
2333 return NT_STATUS_NOT_IMPLEMENTED;
2336 NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p, struct lsa_SetTrustedDomainInfo *r)
2338 p->rng_fault_state = True;
2339 return NT_STATUS_NOT_IMPLEMENTED;
2342 NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct lsa_DeleteTrustedDomain *r)
2344 p->rng_fault_state = True;
2345 return NT_STATUS_NOT_IMPLEMENTED;
2348 NTSTATUS _lsa_StorePrivateData(pipes_struct *p, struct lsa_StorePrivateData *r)
2350 p->rng_fault_state = True;
2351 return NT_STATUS_NOT_IMPLEMENTED;
2354 NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateData *r)
2356 p->rng_fault_state = True;
2357 return NT_STATUS_NOT_IMPLEMENTED;
2360 NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, struct lsa_OpenPolicy2 *r)
2362 p->rng_fault_state = True;
2363 return NT_STATUS_NOT_IMPLEMENTED;
2366 NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r)
2368 p->rng_fault_state = True;
2369 return NT_STATUS_NOT_IMPLEMENTED;
2372 NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct lsa_QueryInfoPolicy2 *r)
2374 p->rng_fault_state = True;
2375 return NT_STATUS_NOT_IMPLEMENTED;
2378 NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p, struct lsa_SetInfoPolicy2 *r)
2380 p->rng_fault_state = True;
2381 return NT_STATUS_NOT_IMPLEMENTED;
2384 NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct lsa_QueryTrustedDomainInfoByName *r)
2386 p->rng_fault_state = True;
2387 return NT_STATUS_NOT_IMPLEMENTED;
2390 NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct lsa_SetTrustedDomainInfoByName *r)
2392 p->rng_fault_state = True;
2393 return NT_STATUS_NOT_IMPLEMENTED;
2396 NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct lsa_EnumTrustedDomainsEx *r)
2398 p->rng_fault_state = True;
2399 return NT_STATUS_NOT_IMPLEMENTED;
2402 NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p, struct lsa_CreateTrustedDomainEx *r)
2404 p->rng_fault_state = True;
2405 return NT_STATUS_NOT_IMPLEMENTED;
2408 NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct lsa_CloseTrustedDomainEx *r)
2410 p->rng_fault_state = True;
2411 return NT_STATUS_NOT_IMPLEMENTED;
2414 NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct lsa_QueryDomainInformationPolicy *r)
2416 p->rng_fault_state = True;
2417 return NT_STATUS_NOT_IMPLEMENTED;
2420 NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct lsa_SetDomainInformationPolicy *r)
2422 p->rng_fault_state = True;
2423 return NT_STATUS_NOT_IMPLEMENTED;
2426 NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct lsa_OpenTrustedDomainByName *r)
2428 p->rng_fault_state = True;
2429 return NT_STATUS_NOT_IMPLEMENTED;
2432 NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r)
2434 p->rng_fault_state = True;
2435 return NT_STATUS_NOT_IMPLEMENTED;
2438 NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r)
2440 p->rng_fault_state = True;
2441 return NT_STATUS_NOT_IMPLEMENTED;
2444 NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct lsa_LookupNames2 *r)
2446 p->rng_fault_state = True;
2447 return NT_STATUS_NOT_IMPLEMENTED;
2450 NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r)
2452 p->rng_fault_state = True;
2453 return NT_STATUS_NOT_IMPLEMENTED;
2456 NTSTATUS _lsa_CREDRWRITE(pipes_struct *p, struct lsa_CREDRWRITE *r)
2458 p->rng_fault_state = True;
2459 return NT_STATUS_NOT_IMPLEMENTED;
2462 NTSTATUS _lsa_CREDRREAD(pipes_struct *p, struct lsa_CREDRREAD *r)
2464 p->rng_fault_state = True;
2465 return NT_STATUS_NOT_IMPLEMENTED;
2468 NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p, struct lsa_CREDRENUMERATE *r)
2470 p->rng_fault_state = True;
2471 return NT_STATUS_NOT_IMPLEMENTED;
2474 NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRWRITEDOMAINCREDENTIALS *r)
2476 p->rng_fault_state = True;
2477 return NT_STATUS_NOT_IMPLEMENTED;
2480 NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRREADDOMAINCREDENTIALS *r)
2482 p->rng_fault_state = True;
2483 return NT_STATUS_NOT_IMPLEMENTED;
2486 NTSTATUS _lsa_CREDRDELETE(pipes_struct *p, struct lsa_CREDRDELETE *r)
2488 p->rng_fault_state = True;
2489 return NT_STATUS_NOT_IMPLEMENTED;
2492 NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p, struct lsa_CREDRGETTARGETINFO *r)
2494 p->rng_fault_state = True;
2495 return NT_STATUS_NOT_IMPLEMENTED;
2498 NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED *r)
2500 p->rng_fault_state = True;
2501 return NT_STATUS_NOT_IMPLEMENTED;
2504 NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r)
2506 p->rng_fault_state = True;
2507 return NT_STATUS_NOT_IMPLEMENTED;
2510 NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r)
2512 p->rng_fault_state = True;
2513 return NT_STATUS_NOT_IMPLEMENTED;
2516 NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARREGISTERAUDITEVENT *r)
2518 p->rng_fault_state = True;
2519 return NT_STATUS_NOT_IMPLEMENTED;
2522 NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p, struct lsa_LSARGENAUDITEVENT *r)
2524 p->rng_fault_state = True;
2525 return NT_STATUS_NOT_IMPLEMENTED;
2528 NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARUNREGISTERAUDITEVENT *r)
2530 p->rng_fault_state = True;
2531 return NT_STATUS_NOT_IMPLEMENTED;
2534 NTSTATUS _lsa_LSARQUERYFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARQUERYFORESTTRUSTINFORMATION *r)
2536 p->rng_fault_state = True;
2537 return NT_STATUS_NOT_IMPLEMENTED;
2540 NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARSETFORESTTRUSTINFORMATION *r)
2542 p->rng_fault_state = True;
2543 return NT_STATUS_NOT_IMPLEMENTED;
2546 NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r)
2548 p->rng_fault_state = True;
2549 return NT_STATUS_NOT_IMPLEMENTED;
2552 NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r)
2554 p->rng_fault_state = True;
2555 return NT_STATUS_NOT_IMPLEMENTED;
2558 NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r)
2560 p->rng_fault_state = True;
2561 return NT_STATUS_NOT_IMPLEMENTED;
2564 NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r)
2566 p->rng_fault_state = True;
2567 return NT_STATUS_NOT_IMPLEMENTED;
2570 NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r)
2572 p->rng_fault_state = True;
2573 return NT_STATUS_NOT_IMPLEMENTED;
2576 NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r)
2578 p->rng_fault_state = True;
2579 return NT_STATUS_NOT_IMPLEMENTED;
2582 NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p, struct lsa_LSARADTREPORTSECURITYEVENT *r)
2584 p->rng_fault_state = True;
2585 return NT_STATUS_NOT_IMPLEMENTED;