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, see <http://www.gnu.org/licenses/>.
28 /* This is the implementation of the lsa server code. */
33 #define DBGC_CLASS DBGC_RPC_SRV
42 const struct generic_mapping lsa_generic_mapping = {
49 /*******************************************************************
51 ********************************************************************/
53 static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s)
59 /*******************************************************************
60 Function to free the per handle data.
61 ********************************************************************/
63 static void free_lsa_info(void *ptr)
65 struct lsa_info *lsa = (struct lsa_info *)ptr;
70 /***************************************************************************
71 initialize a lsa_DomainInfo structure.
72 ***************************************************************************/
74 static void init_dom_query_3(struct lsa_DomainInfo *r,
78 init_lsa_StringLarge(&r->name, name);
82 /***************************************************************************
83 initialize a lsa_DomainInfo structure.
84 ***************************************************************************/
86 static void init_dom_query_5(struct lsa_DomainInfo *r,
90 init_lsa_StringLarge(&r->name, name);
94 /***************************************************************************
95 init_dom_ref - adds a domain if it's not already in, returns the index.
96 ***************************************************************************/
98 static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid)
102 if (dom_name != NULL) {
103 for (num = 0; num < ref->num_ref_doms_1; num++) {
104 if (sid_equal(dom_sid, &ref->ref_dom[num].ref_dom.sid))
108 num = ref->num_ref_doms_1;
111 if (num >= MAX_REF_DOMAINS) {
112 /* index not found, already at maximum domain limit */
116 ref->num_ref_doms_1 = num+1;
117 ref->ptr_ref_dom = 1;
118 ref->max_entries = MAX_REF_DOMAINS;
119 ref->num_ref_doms_2 = num+1;
121 ref->hdr_ref_dom[num].ptr_dom_sid = 1; /* dom sid cannot be NULL. */
123 init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE);
124 init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name);
126 init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid );
131 /***************************************************************************
132 lookup_lsa_rids. Must be called as root for lookup_name to work.
133 ***************************************************************************/
135 static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx,
141 uint32 *pmapped_count)
143 uint32 mapped_count, i;
145 SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
150 for (i = 0; i < num_entries; i++) {
156 enum lsa_SidType type = SID_NAME_UNKNOWN;
158 /* Split name into domain and user component */
160 full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]);
161 if (full_name == NULL) {
162 DEBUG(0, ("pull_ucs2_talloc failed\n"));
163 return NT_STATUS_NO_MEMORY;
166 DEBUG(5, ("lookup_lsa_rids: looking up name %s\n", full_name));
168 /* We can ignore the result of lookup_name, it will not touch
169 "type" if it's not successful */
171 lookup_name(mem_ctx, full_name, flags, &domain, NULL,
176 case SID_NAME_DOM_GRP:
177 case SID_NAME_DOMAIN:
179 case SID_NAME_WKN_GRP:
180 DEBUG(5, ("init_lsa_rids: %s found\n", full_name));
181 /* Leave these unchanged */
184 /* Don't hand out anything but the list above */
185 DEBUG(5, ("init_lsa_rids: %s not found\n", full_name));
186 type = SID_NAME_UNKNOWN;
193 if (type != SID_NAME_UNKNOWN) {
194 sid_split_rid(&sid, &rid);
195 dom_idx = init_dom_ref(ref, domain, &sid);
199 init_dom_rid(&prid[i], rid, type, dom_idx);
202 *pmapped_count = mapped_count;
206 /***************************************************************************
207 lookup_lsa_sids. Must be called as root for lookup_name to work.
208 ***************************************************************************/
210 static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx,
212 LSA_TRANSLATED_SID3 *trans_sids,
216 uint32 *pmapped_count)
218 uint32 mapped_count, i;
220 SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
225 for (i = 0; i < num_entries; i++) {
231 enum lsa_SidType type = SID_NAME_UNKNOWN;
233 /* Split name into domain and user component */
235 full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]);
236 if (full_name == NULL) {
237 DEBUG(0, ("pull_ucs2_talloc failed\n"));
238 return NT_STATUS_NO_MEMORY;
241 DEBUG(5, ("init_lsa_sids: looking up name %s\n", full_name));
243 /* We can ignore the result of lookup_name, it will not touch
244 "type" if it's not successful */
246 lookup_name(mem_ctx, full_name, flags, &domain, NULL,
251 case SID_NAME_DOM_GRP:
252 case SID_NAME_DOMAIN:
254 case SID_NAME_WKN_GRP:
255 DEBUG(5, ("init_lsa_sids: %s found\n", full_name));
256 /* Leave these unchanged */
259 /* Don't hand out anything but the list above */
260 DEBUG(5, ("init_lsa_sids: %s not found\n", full_name));
261 type = SID_NAME_UNKNOWN;
268 if (type != SID_NAME_UNKNOWN) {
270 sid_copy(&domain_sid, &sid);
271 sid_split_rid(&domain_sid, &rid);
272 dom_idx = init_dom_ref(ref, domain, &domain_sid);
276 /* Initialize the LSA_TRANSLATED_SID3 return. */
277 trans_sids[i].sid_type = type;
278 trans_sids[i].sid2 = TALLOC_P(mem_ctx, DOM_SID2);
279 if (trans_sids[i].sid2 == NULL) {
280 return NT_STATUS_NO_MEMORY;
282 init_dom_sid2(trans_sids[i].sid2, &sid);
283 trans_sids[i].sid_idx = dom_idx;
286 *pmapped_count = mapped_count;
290 /***************************************************************************
291 init_reply_lookup_names
292 ***************************************************************************/
294 static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
295 DOM_R_REF *ref, uint32 num_entries,
296 DOM_RID *rid, uint32 mapped_count)
298 r_l->ptr_dom_ref = 1;
301 r_l->num_entries = num_entries;
302 r_l->ptr_entries = 1;
303 r_l->num_entries2 = num_entries;
306 r_l->mapped_count = mapped_count;
309 /***************************************************************************
310 init_reply_lookup_names2
311 ***************************************************************************/
313 static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l,
314 DOM_R_REF *ref, uint32 num_entries,
315 DOM_RID2 *rid, uint32 mapped_count)
317 r_l->ptr_dom_ref = 1;
320 r_l->num_entries = num_entries;
321 r_l->ptr_entries = 1;
322 r_l->num_entries2 = num_entries;
325 r_l->mapped_count = mapped_count;
328 /***************************************************************************
329 init_reply_lookup_names3
330 ***************************************************************************/
332 static void init_reply_lookup_names3(LSA_R_LOOKUP_NAMES3 *r_l,
333 DOM_R_REF *ref, uint32 num_entries,
334 LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count)
336 r_l->ptr_dom_ref = 1;
339 r_l->num_entries = num_entries;
340 r_l->ptr_entries = 1;
341 r_l->num_entries2 = num_entries;
342 r_l->trans_sids = trans_sids;
344 r_l->mapped_count = mapped_count;
347 /***************************************************************************
348 init_reply_lookup_names4
349 ***************************************************************************/
351 static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l,
352 DOM_R_REF *ref, uint32 num_entries,
353 LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count)
355 r_l->ptr_dom_ref = 1;
358 r_l->num_entries = num_entries;
359 r_l->ptr_entries = 1;
360 r_l->num_entries2 = num_entries;
361 r_l->trans_sids = trans_sids;
363 r_l->mapped_count = mapped_count;
366 /***************************************************************************
367 Init_reply_lookup_sids.
368 ***************************************************************************/
370 static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l,
374 r_l->ptr_dom_ref = ref ? 1 : 0;
376 r_l->mapped_count = mapped_count;
379 /***************************************************************************
380 Init_reply_lookup_sids.
381 ***************************************************************************/
383 static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l,
387 r_l->ptr_dom_ref = ref ? 1 : 0;
389 r_l->mapped_count = mapped_count;
392 /***************************************************************************
393 Init_reply_lookup_sids.
394 ***************************************************************************/
396 static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx,
397 LSA_R_LOOKUP_SIDS *r_l,
399 LSA_TRANS_NAME_ENUM2 *names,
402 LSA_TRANS_NAME_ENUM *oldnames = &r_l->names;
404 oldnames->num_entries = names->num_entries;
405 oldnames->ptr_trans_names = names->ptr_trans_names;
406 oldnames->num_entries2 = names->num_entries2;
407 oldnames->uni_name = names->uni_name;
409 if (names->num_entries) {
412 oldnames->name = TALLOC_ARRAY(mem_ctx, LSA_TRANS_NAME, names->num_entries);
414 if (!oldnames->name) {
415 return NT_STATUS_NO_MEMORY;
417 for (i = 0; i < names->num_entries; i++) {
418 oldnames->name[i].sid_name_use = names->name[i].sid_name_use;
419 oldnames->name[i].hdr_name = names->name[i].hdr_name;
420 oldnames->name[i].domain_idx = names->name[i].domain_idx;
424 r_l->ptr_dom_ref = ref ? 1 : 0;
426 r_l->mapped_count = mapped_count;
430 static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size)
432 DOM_SID local_adm_sid;
440 init_sec_access(&mask, POLICY_EXECUTE);
441 init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
443 sid_copy(&adm_sid, get_global_sam_sid());
444 sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS);
445 init_sec_access(&mask, POLICY_ALL_ACCESS);
446 init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
448 sid_copy(&local_adm_sid, &global_sid_Builtin);
449 sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS);
450 init_sec_access(&mask, POLICY_ALL_ACCESS);
451 init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
453 if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL)
454 return NT_STATUS_NO_MEMORY;
456 if((*sd = make_sec_desc(mem_ctx, SECURITY_DESCRIPTOR_REVISION_1,
457 SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL,
458 psa, sd_size)) == NULL)
459 return NT_STATUS_NO_MEMORY;
464 #if 0 /* AD DC work in ongoing in Samba 4 */
466 /***************************************************************************
468 ***************************************************************************/
470 static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name,
471 const char *dns_name, const char *forest_name,
472 struct GUID *dom_guid, DOM_SID *dom_sid)
474 if (nb_name && *nb_name) {
475 init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE);
476 init_uni_hdr(&r_l->hdr_nb_dom_name, &r_l->uni_nb_dom_name);
477 r_l->hdr_nb_dom_name.uni_max_len += 2;
478 r_l->uni_nb_dom_name.uni_max_len += 1;
481 if (dns_name && *dns_name) {
482 init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE);
483 init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name);
484 r_l->hdr_dns_dom_name.uni_max_len += 2;
485 r_l->uni_dns_dom_name.uni_max_len += 1;
488 if (forest_name && *forest_name) {
489 init_unistr2(&r_l->uni_forest_name, forest_name, UNI_FLAGS_NONE);
490 init_uni_hdr(&r_l->hdr_forest_name, &r_l->uni_forest_name);
491 r_l->hdr_forest_name.uni_max_len += 2;
492 r_l->uni_forest_name.uni_max_len += 1;
495 /* how do we init the guid ? probably should write an init fn */
497 memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID));
501 r_l->ptr_dom_sid = 1;
502 init_dom_sid2(&r_l->dom_sid, dom_sid);
505 #endif /* AD DC work in ongoing in Samba 4 */
508 /***************************************************************************
510 ***************************************************************************/
512 NTSTATUS _lsa_OpenPolicy2(pipes_struct *p,
513 struct lsa_OpenPolicy2 *r)
515 struct lsa_info *info;
516 SEC_DESC *psd = NULL;
518 uint32 des_access = r->in.access_mask;
523 /* map the generic bits to the lsa policy ones */
524 se_map_generic(&des_access, &lsa_generic_mapping);
526 /* get the generic lsa policy SD until we store it */
527 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
529 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
530 if (p->pipe_user.ut.uid != sec_initial_uid()) {
533 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
534 acc_granted, des_access));
535 DEBUGADD(4,("but overwritten by euid == 0\n"));
538 /* This is needed for lsa_open_account and rpcclient .... :-) */
540 if (p->pipe_user.ut.uid == sec_initial_uid())
541 acc_granted = POLICY_ALL_ACCESS;
543 /* associate the domain SID with the (unique) handle. */
544 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
545 return NT_STATUS_NO_MEMORY;
548 sid_copy(&info->sid,get_global_sam_sid());
549 info->access = acc_granted;
551 /* set up the LSA QUERY INFO response */
552 if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
553 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
558 /***************************************************************************
560 ***************************************************************************/
562 NTSTATUS _lsa_OpenPolicy(pipes_struct *p,
563 struct lsa_OpenPolicy *r)
565 struct lsa_info *info;
566 SEC_DESC *psd = NULL;
568 uint32 des_access= r->in.access_mask;
573 /* map the generic bits to the lsa policy ones */
574 se_map_generic(&des_access, &lsa_generic_mapping);
576 /* get the generic lsa policy SD until we store it */
577 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
579 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
580 if (geteuid() != 0) {
583 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
584 acc_granted, des_access));
585 DEBUGADD(4,("but overwritten by euid == 0\n"));
586 acc_granted = des_access;
589 /* associate the domain SID with the (unique) handle. */
590 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
591 return NT_STATUS_NO_MEMORY;
594 sid_copy(&info->sid,get_global_sam_sid());
595 info->access = acc_granted;
597 /* set up the LSA QUERY INFO response */
598 if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
599 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
604 /***************************************************************************
605 _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA.
607 ***************************************************************************/
609 NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u,
610 LSA_R_ENUM_TRUST_DOM *r_u)
612 struct lsa_info *info;
614 struct trustdom_info **domains;
617 * preferred length is set to 5 as a "our" preferred length
618 * nt sets this parameter to 2
619 * update (20.08.2002): it's not preferred length, but preferred size!
620 * it needs further investigation how to optimally choose this value
622 uint32 max_num_domains =
623 q_u->preferred_len < 5 ? q_u->preferred_len : 10;
628 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
629 return NT_STATUS_INVALID_HANDLE;
631 /* check if the user have enough rights */
632 if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION))
633 return NT_STATUS_ACCESS_DENIED;
635 nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains);
637 if (!NT_STATUS_IS_OK(nt_status)) {
641 if (q_u->enum_context < num_domains) {
642 num_thistime = MIN(num_domains, max_num_domains);
644 r_u->status = STATUS_MORE_ENTRIES;
646 if (q_u->enum_context + num_thistime > num_domains) {
647 num_thistime = num_domains - q_u->enum_context;
648 r_u->status = NT_STATUS_OK;
651 next_idx = q_u->enum_context + num_thistime;
654 next_idx = 0xffffffff;
655 r_u->status = NT_STATUS_NO_MORE_ENTRIES;
658 /* set up the lsa_enum_trust_dom response */
660 init_r_enum_trust_dom(p->mem_ctx, r_u, next_idx,
661 num_thistime, domains+q_u->enum_context);
666 /***************************************************************************
668 ***************************************************************************/
670 NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p,
671 struct lsa_QueryInfoPolicy *r)
673 NTSTATUS status = NT_STATUS_OK;
674 struct lsa_info *handle;
678 union lsa_PolicyInformation *info = NULL;
680 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
681 return NT_STATUS_INVALID_HANDLE;
683 info = TALLOC_ZERO_P(p->mem_ctx, union lsa_PolicyInformation);
685 return NT_STATUS_NO_MEMORY;
688 switch (r->in.level) {
692 uint32 policy_def = LSA_AUDIT_POLICY_ALL;
694 /* check if the user have enough rights */
695 if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) {
696 DEBUG(10,("_lsa_QueryInfoPolicy: insufficient access rights\n"));
697 return NT_STATUS_ACCESS_DENIED;
700 /* fake info: We audit everything. ;) */
702 info->audit_events.auditing_mode = true;
703 info->audit_events.count = LSA_AUDIT_NUM_CATEGORIES;
704 info->audit_events.settings = TALLOC_ZERO_ARRAY(p->mem_ctx,
705 enum lsa_PolicyAuditPolicy,
706 info->audit_events.count);
707 if (!info->audit_events.settings) {
708 return NT_STATUS_NO_MEMORY;
711 info->audit_events.settings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def;
712 info->audit_events.settings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def;
713 info->audit_events.settings[LSA_AUDIT_CATEGORY_LOGON] = policy_def;
714 info->audit_events.settings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def;
715 info->audit_events.settings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def;
716 info->audit_events.settings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def;
717 info->audit_events.settings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def;
722 /* check if the user have enough rights */
723 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
724 return NT_STATUS_ACCESS_DENIED;
726 /* Request PolicyPrimaryDomainInformation. */
727 switch (lp_server_role()) {
728 case ROLE_DOMAIN_PDC:
729 case ROLE_DOMAIN_BDC:
730 name = get_global_sam_name();
731 sid = get_global_sam_sid();
733 case ROLE_DOMAIN_MEMBER:
734 name = lp_workgroup();
735 /* We need to return the Domain SID here. */
736 if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid))
739 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
741 case ROLE_STANDALONE:
742 name = lp_workgroup();
746 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
748 init_dom_query_3(&info->domain, name, sid);
751 /* check if the user have enough rights */
752 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
753 return NT_STATUS_ACCESS_DENIED;
755 /* Request PolicyAccountDomainInformation. */
756 name = get_global_sam_name();
757 sid = get_global_sam_sid();
759 init_dom_query_5(&info->account_domain, name, sid);
762 /* check if the user have enough rights */
763 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
764 return NT_STATUS_ACCESS_DENIED;
766 switch (lp_server_role()) {
767 case ROLE_DOMAIN_BDC:
769 * only a BDC is a backup controller
770 * of the domain, it controls.
776 * any other role is a primary
777 * of the domain, it controls.
784 DEBUG(0,("_lsa_QueryInfoPolicy: unknown info level in Lsa Query: %d\n",
786 status = NT_STATUS_INVALID_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) {
867 /* Unknown sids should return the string
868 * representation of the SID. Windows 2003 behaves
869 * rather erratic here, in many cases it returns the
870 * RID as 8 bytes hex, in others it returns the full
871 * SID. We (Jerry/VL) could not figure out which the
872 * hard cases are, so leave it with the SID. */
873 name->name = talloc_asprintf(p->mem_ctx, "%s",
876 if (name->name == NULL) {
877 return NT_STATUS_NO_MEMORY;
882 init_lsa_trans_name2(&names->name[i], &names->uni_name[i],
883 name->type, name->name, name->dom_idx);
886 names->num_entries = num_sids;
887 names->ptr_trans_names = 1;
888 names->num_entries2 = num_sids;
890 status = NT_STATUS_NONE_MAPPED;
891 if (mapped_count > 0) {
892 status = (mapped_count < num_sids) ?
893 STATUS_SOME_UNMAPPED : NT_STATUS_OK;
896 DEBUG(10, ("num_sids %d, mapped_count %d, status %s\n",
897 num_sids, mapped_count, nt_errstr(status)));
899 *pp_mapped_count = mapped_count;
905 /***************************************************************************
907 ***************************************************************************/
909 NTSTATUS _lsa_lookup_sids(pipes_struct *p,
910 LSA_Q_LOOKUP_SIDS *q_u,
911 LSA_R_LOOKUP_SIDS *r_u)
913 struct lsa_info *handle;
914 int num_sids = q_u->sids.num_entries;
915 uint32 mapped_count = 0;
916 DOM_R_REF *ref = NULL;
917 LSA_TRANS_NAME_ENUM2 names;
920 if ((q_u->level < 1) || (q_u->level > 6)) {
921 return NT_STATUS_INVALID_PARAMETER;
924 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
925 return NT_STATUS_INVALID_HANDLE;
928 /* check if the user has enough rights */
929 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
930 return NT_STATUS_ACCESS_DENIED;
933 if (num_sids > MAX_LOOKUP_SIDS) {
934 DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n",
935 MAX_LOOKUP_SIDS, num_sids));
936 return NT_STATUS_NONE_MAPPED;
939 r_u->status = _lsa_lookup_sids_internal(p,
947 /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */
949 status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, &names, mapped_count);
950 if (!NT_STATUS_IS_OK(status)) {
956 /***************************************************************************
958 ***************************************************************************/
960 NTSTATUS _lsa_lookup_sids2(pipes_struct *p,
961 LSA_Q_LOOKUP_SIDS2 *q_u,
962 LSA_R_LOOKUP_SIDS2 *r_u)
964 struct lsa_info *handle;
965 int num_sids = q_u->sids.num_entries;
966 uint32 mapped_count = 0;
967 DOM_R_REF *ref = NULL;
969 if ((q_u->level < 1) || (q_u->level > 6)) {
970 return NT_STATUS_INVALID_PARAMETER;
973 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
974 return NT_STATUS_INVALID_HANDLE;
977 /* check if the user have enough rights */
978 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
979 return NT_STATUS_ACCESS_DENIED;
982 if (num_sids > MAX_LOOKUP_SIDS) {
983 DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n",
984 MAX_LOOKUP_SIDS, num_sids));
985 return NT_STATUS_NONE_MAPPED;
988 r_u->status = _lsa_lookup_sids_internal(p,
996 init_reply_lookup_sids2(r_u, ref, mapped_count);
1000 /***************************************************************************
1002 ***************************************************************************/
1004 NTSTATUS _lsa_lookup_sids3(pipes_struct *p,
1005 LSA_Q_LOOKUP_SIDS3 *q_u,
1006 LSA_R_LOOKUP_SIDS3 *r_u)
1008 int num_sids = q_u->sids.num_entries;
1009 uint32 mapped_count = 0;
1010 DOM_R_REF *ref = NULL;
1012 if ((q_u->level < 1) || (q_u->level > 6)) {
1013 return NT_STATUS_INVALID_PARAMETER;
1016 /* No policy handle on this call. Restrict to crypto connections. */
1017 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1018 DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n",
1019 get_remote_machine_name() ));
1020 return NT_STATUS_INVALID_PARAMETER;
1023 if (num_sids > MAX_LOOKUP_SIDS) {
1024 DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n",
1025 MAX_LOOKUP_SIDS, num_sids));
1026 return NT_STATUS_NONE_MAPPED;
1029 r_u->status = _lsa_lookup_sids_internal(p,
1037 init_reply_lookup_sids3(r_u, ref, mapped_count);
1041 static int lsa_lookup_level_to_flags(uint16 level)
1047 flags = LOOKUP_NAME_ALL;
1050 flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_REMOTE|LOOKUP_NAME_ISOLATED;
1053 flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED;
1059 flags = LOOKUP_NAME_NONE;
1066 /***************************************************************************
1067 lsa_reply_lookup_names
1068 ***************************************************************************/
1070 NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u)
1072 struct lsa_info *handle;
1073 UNISTR2 *names = q_u->uni_name;
1074 uint32 num_entries = q_u->num_entries;
1077 uint32 mapped_count = 0;
1080 if (num_entries > MAX_LOOKUP_SIDS) {
1081 num_entries = MAX_LOOKUP_SIDS;
1082 DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries));
1085 flags = lsa_lookup_level_to_flags(q_u->lookup_level);
1087 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1089 return NT_STATUS_NO_MEMORY;
1093 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
1095 return NT_STATUS_NO_MEMORY;
1101 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1102 r_u->status = NT_STATUS_INVALID_HANDLE;
1106 /* check if the user have enough rights */
1107 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1108 r_u->status = NT_STATUS_ACCESS_DENIED;
1112 /* set up the LSA Lookup RIDs response */
1113 become_root(); /* lookup_name can require root privs */
1114 r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
1115 names, flags, &mapped_count);
1120 if (NT_STATUS_IS_OK(r_u->status) && (num_entries != 0) ) {
1121 if (mapped_count == 0)
1122 r_u->status = NT_STATUS_NONE_MAPPED;
1123 else if (mapped_count != num_entries)
1124 r_u->status = STATUS_SOME_UNMAPPED;
1127 init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count);
1131 /***************************************************************************
1132 lsa_reply_lookup_names2
1133 ***************************************************************************/
1135 NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOOKUP_NAMES2 *r_u)
1137 struct lsa_info *handle;
1138 UNISTR2 *names = q_u->uni_name;
1139 uint32 num_entries = q_u->num_entries;
1144 uint32 mapped_count = 0;
1147 if (num_entries > MAX_LOOKUP_SIDS) {
1148 num_entries = MAX_LOOKUP_SIDS;
1149 DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries));
1152 flags = lsa_lookup_level_to_flags(q_u->lookup_level);
1154 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1156 r_u->status = NT_STATUS_NO_MEMORY;
1157 return NT_STATUS_NO_MEMORY;
1161 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
1162 rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries);
1163 if ((rids == NULL) || (rids2 == NULL)) {
1164 r_u->status = NT_STATUS_NO_MEMORY;
1165 return NT_STATUS_NO_MEMORY;
1172 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1173 r_u->status = NT_STATUS_INVALID_HANDLE;
1177 /* check if the user have enough rights */
1178 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1179 r_u->status = NT_STATUS_ACCESS_DENIED;
1183 /* set up the LSA Lookup RIDs response */
1184 become_root(); /* lookup_name can require root privs */
1185 r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
1186 names, flags, &mapped_count);
1191 if (NT_STATUS_IS_OK(r_u->status)) {
1192 if (mapped_count == 0) {
1193 r_u->status = NT_STATUS_NONE_MAPPED;
1194 } else if (mapped_count != num_entries) {
1195 r_u->status = STATUS_SOME_UNMAPPED;
1199 /* Convert the rids array to rids2. */
1200 for (i = 0; i < num_entries; i++) {
1201 rids2[i].type = rids[i].type;
1202 rids2[i].rid = rids[i].rid;
1203 rids2[i].rid_idx = rids[i].rid_idx;
1204 rids2[i].unknown = 0;
1207 init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count);
1211 /***************************************************************************
1212 lsa_reply_lookup_names3.
1213 ***************************************************************************/
1215 NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u)
1217 struct lsa_info *handle;
1218 UNISTR2 *names = q_u->uni_name;
1219 uint32 num_entries = q_u->num_entries;
1220 DOM_R_REF *ref = NULL;
1221 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1222 uint32 mapped_count = 0;
1225 if (num_entries > MAX_LOOKUP_SIDS) {
1226 num_entries = MAX_LOOKUP_SIDS;
1227 DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries));
1230 /* Probably the lookup_level is some sort of bitmask. */
1231 if (q_u->lookup_level == 1) {
1232 flags = LOOKUP_NAME_ALL;
1235 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1237 return NT_STATUS_NO_MEMORY;
1240 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1242 return NT_STATUS_NO_MEMORY;
1248 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1249 r_u->status = NT_STATUS_INVALID_HANDLE;
1253 /* check if the user have enough rights */
1254 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1255 r_u->status = NT_STATUS_ACCESS_DENIED;
1259 /* set up the LSA Lookup SIDs response */
1260 become_root(); /* lookup_name can require root privs */
1261 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1262 names, flags, &mapped_count);
1267 if (NT_STATUS_IS_OK(r_u->status)) {
1268 if (mapped_count == 0) {
1269 r_u->status = NT_STATUS_NONE_MAPPED;
1270 } else if (mapped_count != num_entries) {
1271 r_u->status = STATUS_SOME_UNMAPPED;
1275 init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count);
1279 /***************************************************************************
1280 lsa_reply_lookup_names4.
1281 ***************************************************************************/
1283 NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u)
1285 UNISTR2 *names = q_u->uni_name;
1286 uint32 num_entries = q_u->num_entries;
1287 DOM_R_REF *ref = NULL;
1288 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1289 uint32 mapped_count = 0;
1292 if (num_entries > MAX_LOOKUP_SIDS) {
1293 num_entries = MAX_LOOKUP_SIDS;
1294 DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries));
1297 /* Probably the lookup_level is some sort of bitmask. */
1298 if (q_u->lookup_level == 1) {
1299 flags = LOOKUP_NAME_ALL;
1302 /* No policy handle on this call. Restrict to crypto connections. */
1303 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1304 DEBUG(0,("_lsa_lookup_names4: client %s not using schannel for netlogon\n",
1305 get_remote_machine_name() ));
1306 return NT_STATUS_INVALID_PARAMETER;
1309 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1311 return NT_STATUS_NO_MEMORY;
1315 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1317 return NT_STATUS_NO_MEMORY;
1323 /* set up the LSA Lookup SIDs response */
1324 become_root(); /* lookup_name can require root privs */
1325 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1326 names, flags, &mapped_count);
1329 if (NT_STATUS_IS_OK(r_u->status)) {
1330 if (mapped_count == 0) {
1331 r_u->status = NT_STATUS_NONE_MAPPED;
1332 } else if (mapped_count != num_entries) {
1333 r_u->status = STATUS_SOME_UNMAPPED;
1337 init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count);
1341 /***************************************************************************
1342 _lsa_close. Also weird - needs to check if lsa handle is correct. JRA.
1343 ***************************************************************************/
1345 NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r)
1347 if (!find_policy_by_hnd(p, r->in.handle, NULL)) {
1348 return NT_STATUS_INVALID_HANDLE;
1351 close_policy_hnd(p, r->in.handle);
1352 return NT_STATUS_OK;
1355 /***************************************************************************
1356 ***************************************************************************/
1358 NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct lsa_OpenSecret *r)
1360 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1363 /***************************************************************************
1364 ***************************************************************************/
1366 NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct lsa_OpenTrustedDomain *r)
1368 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1371 /***************************************************************************
1372 ***************************************************************************/
1374 NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, struct lsa_CreateTrustedDomain *r)
1376 return NT_STATUS_ACCESS_DENIED;
1379 /***************************************************************************
1380 ***************************************************************************/
1382 NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct lsa_CreateSecret *r)
1384 return NT_STATUS_ACCESS_DENIED;
1387 /***************************************************************************
1388 ***************************************************************************/
1390 NTSTATUS _lsa_SetSecret(pipes_struct *p, struct lsa_SetSecret *r)
1392 return NT_STATUS_ACCESS_DENIED;
1395 /***************************************************************************
1397 ***************************************************************************/
1399 NTSTATUS _lsa_DeleteObject(pipes_struct *p,
1400 struct lsa_DeleteObject *r)
1402 return NT_STATUS_ACCESS_DENIED;
1405 /***************************************************************************
1407 ***************************************************************************/
1409 NTSTATUS _lsa_EnumPrivs(pipes_struct *p,
1410 struct lsa_EnumPrivs *r)
1412 struct lsa_info *handle;
1414 uint32 enum_context = *r->in.resume_handle;
1415 int num_privs = count_all_privileges();
1416 struct lsa_PrivEntry *entries = NULL;
1419 /* remember that the enum_context starts at 0 and not 1 */
1421 if ( enum_context >= num_privs )
1422 return NT_STATUS_NO_MORE_ENTRIES;
1424 DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n",
1425 enum_context, num_privs));
1427 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1428 return NT_STATUS_INVALID_HANDLE;
1430 /* 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;
1437 entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_PrivEntry, num_privs);
1439 return NT_STATUS_NO_MEMORY;
1445 for (i = 0; i < num_privs; i++) {
1446 if( i < enum_context) {
1448 init_lsa_StringLarge(&entries[i].name, NULL);
1450 entries[i].luid.low = 0;
1451 entries[i].luid.high = 0;
1454 init_lsa_StringLarge(&entries[i].name, privs[i].name);
1456 luid = get_privilege_luid( &privs[i].se_priv );
1458 entries[i].luid.low = luid.luid.low;
1459 entries[i].luid.high = luid.luid.high;
1463 enum_context = num_privs;
1465 *r->out.resume_handle = enum_context;
1466 r->out.privs->count = num_privs;
1467 r->out.privs->privs = entries;
1469 return NT_STATUS_OK;
1472 /***************************************************************************
1473 _lsa_LookupPrivDisplayName
1474 ***************************************************************************/
1476 NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p,
1477 struct lsa_LookupPrivDisplayName *r)
1479 struct lsa_info *handle;
1480 const char *description;
1481 struct lsa_StringLarge *lsa_name;
1483 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1484 return NT_STATUS_INVALID_HANDLE;
1486 /* check if the user have enough rights */
1489 * I don't know if it's the right one. not documented.
1491 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1492 return NT_STATUS_ACCESS_DENIED;
1494 DEBUG(10,("_lsa_LookupPrivDisplayName: name = %s\n", r->in.name->string));
1496 description = get_privilege_dispname(r->in.name->string);
1498 DEBUG(10,("_lsa_LookupPrivDisplayName: doesn't exist\n"));
1499 return NT_STATUS_NO_SUCH_PRIVILEGE;
1502 DEBUG(10,("_lsa_LookupPrivDisplayName: display name = %s\n", description));
1504 lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge);
1506 return NT_STATUS_NO_MEMORY;
1509 init_lsa_StringLarge(lsa_name, description);
1511 *r->out.returned_language_id = r->in.language_id;
1512 *r->out.disp_name = lsa_name;
1514 return NT_STATUS_OK;
1517 /***************************************************************************
1519 ***************************************************************************/
1521 NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u)
1523 struct lsa_info *handle;
1525 int i, j, num_entries;
1526 LSA_SID_ENUM *sids=&r_u->sids;
1529 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1530 return NT_STATUS_INVALID_HANDLE;
1532 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1533 return NT_STATUS_ACCESS_DENIED;
1538 /* The only way we can currently find out all the SIDs that have been
1539 privileged is to scan all privileges */
1541 if (!NT_STATUS_IS_OK(ret = privilege_enumerate_accounts(&sid_list, &num_entries))) {
1545 if (q_u->enum_context >= num_entries)
1546 return NT_STATUS_NO_MORE_ENTRIES;
1548 if (num_entries-q_u->enum_context) {
1549 sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context);
1550 sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context);
1552 if (sids->ptr_sid==NULL || sids->sid==NULL) {
1553 SAFE_FREE(sid_list);
1554 return NT_STATUS_NO_MEMORY;
1557 for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) {
1558 init_dom_sid2(&(*sids).sid[j], &sid_list[i]);
1559 (*sids).ptr_sid[j] = 1;
1562 sids->ptr_sid = NULL;
1566 talloc_free(sid_list);
1568 init_lsa_r_enum_accounts(r_u, num_entries);
1570 return NT_STATUS_OK;
1574 NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u)
1576 const char *username, *domname;
1577 user_struct *vuser = get_valid_user_struct(p->vuid);
1580 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1584 * I'm 99% sure this is not the right place to do this,
1585 * global_sid_Anonymous should probably be put into the token
1586 * instead of the guest id -- vl
1588 if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous,
1589 &domname, &username, NULL)) {
1590 return NT_STATUS_NO_MEMORY;
1593 username = vuser->user.smb_name;
1594 domname = vuser->user.domain;
1597 r_u->ptr_user_name = 1;
1598 init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE);
1599 init_uni_hdr(&r_u->hdr_user_name, &r_u->uni2_user_name);
1603 r_u->ptr_dom_name = 1;
1604 init_unistr2(&r_u->uni2_dom_name, domname, UNI_STR_TERMINATE);
1605 init_uni_hdr(&r_u->hdr_dom_name, &r_u->uni2_dom_name);
1607 r_u->status = NT_STATUS_OK;
1612 /***************************************************************************
1614 ***************************************************************************/
1616 NTSTATUS _lsa_CreateAccount(pipes_struct *p,
1617 struct lsa_CreateAccount *r)
1619 struct lsa_info *handle;
1620 struct lsa_info *info;
1622 /* find the connection policy handle. */
1623 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1624 return NT_STATUS_INVALID_HANDLE;
1626 /* check if the user have enough rights */
1629 * I don't know if it's the right one. not documented.
1630 * but guessed with rpcclient.
1632 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
1633 return NT_STATUS_ACCESS_DENIED;
1635 /* check to see if the pipe_user is a Domain Admin since
1636 account_pol.tdb was already opened as root, this is all we have */
1638 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1639 return NT_STATUS_ACCESS_DENIED;
1641 if ( is_privileged_sid( r->in.sid ) )
1642 return NT_STATUS_OBJECT_NAME_COLLISION;
1644 /* associate the user/group SID with the (unique) handle. */
1646 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1647 return NT_STATUS_NO_MEMORY;
1650 info->sid = *r->in.sid;
1651 info->access = r->in.access_mask;
1653 /* get a (unique) handle. open a policy on it. */
1654 if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info))
1655 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1657 return privilege_create_account( &info->sid );
1661 /***************************************************************************
1663 ***************************************************************************/
1665 NTSTATUS _lsa_OpenAccount(pipes_struct *p,
1666 struct lsa_OpenAccount *r)
1668 struct lsa_info *handle;
1669 struct lsa_info *info;
1671 /* find the connection policy handle. */
1672 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1673 return NT_STATUS_INVALID_HANDLE;
1675 /* check if the user have enough rights */
1678 * I don't know if it's the right one. not documented.
1679 * but guessed with rpcclient.
1681 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
1682 return NT_STATUS_ACCESS_DENIED;
1684 /* TODO: Fis the parsing routine before reenabling this check! */
1686 if (!lookup_sid(&handle->sid, dom_name, name, &type))
1687 return NT_STATUS_ACCESS_DENIED;
1689 /* associate the user/group SID with the (unique) handle. */
1690 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1691 return NT_STATUS_NO_MEMORY;
1694 info->sid = *r->in.sid;
1695 info->access = r->in.access_mask;
1697 /* get a (unique) handle. open a policy on it. */
1698 if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info))
1699 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1701 return NT_STATUS_OK;
1704 /***************************************************************************
1705 For a given SID, enumerate all the privilege this account has.
1706 ***************************************************************************/
1708 NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u)
1710 struct lsa_info *info=NULL;
1712 PRIVILEGE_SET privileges;
1714 /* find the connection policy handle. */
1715 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1716 return NT_STATUS_INVALID_HANDLE;
1718 if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) )
1719 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1721 privilege_set_init( &privileges );
1723 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
1725 DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n",
1726 sid_string_dbg(&info->sid),
1729 r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0);
1732 r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE;
1734 privilege_set_free( &privileges );
1739 /***************************************************************************
1740 _lsa_GetSystemAccessAccount
1741 ***************************************************************************/
1743 NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p,
1744 struct lsa_GetSystemAccessAccount *r)
1746 struct lsa_info *info=NULL;
1748 /* find the connection policy handle. */
1750 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1751 return NT_STATUS_INVALID_HANDLE;
1753 if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL))
1754 return NT_STATUS_ACCESS_DENIED;
1757 0x01 -> Log on locally
1758 0x02 -> Access this computer from network
1759 0x04 -> Log on as a batch job
1760 0x10 -> Log on as a service
1762 they can be ORed together
1765 *r->out.access_mask = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK;
1767 return NT_STATUS_OK;
1770 /***************************************************************************
1771 update the systemaccount information
1772 ***************************************************************************/
1774 NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p,
1775 struct lsa_SetSystemAccessAccount *r)
1777 struct lsa_info *info=NULL;
1780 /* find the connection policy handle. */
1781 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1782 return NT_STATUS_INVALID_HANDLE;
1784 /* check to see if the pipe_user is a Domain Admin since
1785 account_pol.tdb was already opened as root, this is all we have */
1787 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1788 return NT_STATUS_ACCESS_DENIED;
1790 if (!pdb_getgrsid(&map, info->sid))
1791 return NT_STATUS_NO_SUCH_GROUP;
1793 return pdb_update_group_mapping_entry(&map);
1796 /***************************************************************************
1797 For a given SID, add some privileges.
1798 ***************************************************************************/
1800 NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u)
1802 struct lsa_info *info = NULL;
1804 PRIVILEGE_SET *set = NULL;
1806 /* find the connection policy handle. */
1807 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1808 return NT_STATUS_INVALID_HANDLE;
1810 /* check to see if the pipe_user is root or a Domain Admin since
1811 account_pol.tdb was already opened as root, this is all we have */
1813 if ( p->pipe_user.ut.uid != sec_initial_uid()
1814 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1816 return NT_STATUS_ACCESS_DENIED;
1821 if ( !privilege_set_to_se_priv( &mask, set ) )
1822 return NT_STATUS_NO_SUCH_PRIVILEGE;
1824 if ( !grant_privilege( &info->sid, &mask ) ) {
1825 DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n",
1826 sid_string_dbg(&info->sid) ));
1827 DEBUG(3,("Privilege mask:\n"));
1828 dump_se_priv( DBGC_ALL, 3, &mask );
1829 return NT_STATUS_NO_SUCH_PRIVILEGE;
1832 return NT_STATUS_OK;
1835 /***************************************************************************
1836 For a given SID, remove some privileges.
1837 ***************************************************************************/
1839 NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u)
1841 struct lsa_info *info = NULL;
1843 PRIVILEGE_SET *set = NULL;
1845 /* find the connection policy handle. */
1846 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
1847 return NT_STATUS_INVALID_HANDLE;
1849 /* check to see if the pipe_user is root or a Domain Admin since
1850 account_pol.tdb was already opened as root, this is all we have */
1852 if ( p->pipe_user.ut.uid != sec_initial_uid()
1853 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1855 return NT_STATUS_ACCESS_DENIED;
1860 if ( !privilege_set_to_se_priv( &mask, set ) )
1861 return NT_STATUS_NO_SUCH_PRIVILEGE;
1863 if ( !revoke_privilege( &info->sid, &mask ) ) {
1864 DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n",
1865 sid_string_dbg(&info->sid) ));
1866 DEBUG(3,("Privilege mask:\n"));
1867 dump_se_priv( DBGC_ALL, 3, &mask );
1868 return NT_STATUS_NO_SUCH_PRIVILEGE;
1871 return NT_STATUS_OK;
1874 /***************************************************************************
1876 ***************************************************************************/
1878 NTSTATUS _lsa_QuerySecurity(pipes_struct *p,
1879 struct lsa_QuerySecurity *r)
1881 struct lsa_info *handle=NULL;
1882 SEC_DESC *psd = NULL;
1886 /* find the connection policy handle. */
1887 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1888 return NT_STATUS_INVALID_HANDLE;
1890 /* check if the user have enough rights */
1891 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1892 return NT_STATUS_ACCESS_DENIED;
1895 switch (r->in.sec_info) {
1897 /* SD contains only the owner */
1899 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1900 if(!NT_STATUS_IS_OK(status))
1901 return NT_STATUS_NO_MEMORY;
1904 if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1905 return NT_STATUS_NO_MEMORY;
1908 /* SD contains only the ACL */
1910 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1911 if(!NT_STATUS_IS_OK(status))
1912 return NT_STATUS_NO_MEMORY;
1914 if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1915 return NT_STATUS_NO_MEMORY;
1918 return NT_STATUS_INVALID_LEVEL;
1924 #if 0 /* AD DC work in ongoing in Samba 4 */
1926 /***************************************************************************
1927 ***************************************************************************/
1929 NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u)
1931 struct lsa_info *handle;
1932 const char *nb_name;
1933 char *dns_name = NULL;
1934 char *forest_name = NULL;
1935 DOM_SID *sid = NULL;
1940 r_u->status = NT_STATUS_OK;
1942 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
1943 return NT_STATUS_INVALID_HANDLE;
1945 switch (q_u->info_class) {
1947 /* check if the user have enough rights */
1948 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1949 return NT_STATUS_ACCESS_DENIED;
1951 /* Request PolicyPrimaryDomainInformation. */
1952 switch (lp_server_role()) {
1953 case ROLE_DOMAIN_PDC:
1954 case ROLE_DOMAIN_BDC:
1955 nb_name = get_global_sam_name();
1956 /* ugly temp hack for these next two */
1958 /* This should be a 'netbios domain -> DNS domain' mapping */
1959 dnsdomname = get_mydnsdomname(p->mem_ctx);
1960 if (!dnsdomname || !*dnsdomname) {
1961 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1963 strlower_m(dnsdomname);
1965 dns_name = dnsdomname;
1966 forest_name = dnsdomname;
1968 sid = get_global_sam_sid();
1969 secrets_fetch_domain_guid(lp_workgroup(), &guid);
1972 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1974 init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name,
1975 forest_name,&guid,sid);
1978 DEBUG(0,("_lsa_query_info2: unknown info level in Lsa Query: %d\n", q_u->info_class));
1979 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1983 if (NT_STATUS_IS_OK(r_u->status)) {
1985 r_u->info_class = q_u->info_class;
1990 #endif /* AD DC work in ongoing in Samba 4 */
1992 /***************************************************************************
1993 ***************************************************************************/
1995 NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u)
1997 struct lsa_info *info = NULL;
2001 UNISTR4_ARRAY *uni_privnames = q_u->rights;
2004 /* find the connection policy handle. */
2005 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2006 return NT_STATUS_INVALID_HANDLE;
2008 /* check to see if the pipe_user is a Domain Admin since
2009 account_pol.tdb was already opened as root, this is all we have */
2011 if ( p->pipe_user.ut.uid != sec_initial_uid()
2012 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
2014 return NT_STATUS_ACCESS_DENIED;
2017 /* according to an NT4 PDC, you can add privileges to SIDs even without
2018 call_lsa_create_account() first. And you can use any arbitrary SID. */
2020 sid_copy( &sid, &q_u->sid.sid );
2022 /* just a little sanity check */
2024 if ( q_u->count != uni_privnames->count ) {
2025 DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n"));
2026 return NT_STATUS_INVALID_HANDLE;
2029 for ( i=0; i<q_u->count; i++ ) {
2030 UNISTR4 *uni4_str = &uni_privnames->strings[i];
2032 /* only try to add non-null strings */
2034 if ( !uni4_str->string )
2037 rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE );
2039 if ( !grant_privilege_by_name( &sid, privname ) ) {
2040 DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname ));
2041 return NT_STATUS_NO_SUCH_PRIVILEGE;
2045 return NT_STATUS_OK;
2048 /***************************************************************************
2049 ***************************************************************************/
2051 NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u)
2053 struct lsa_info *info = NULL;
2057 UNISTR4_ARRAY *uni_privnames = q_u->rights;
2060 /* find the connection policy handle. */
2061 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2062 return NT_STATUS_INVALID_HANDLE;
2064 /* check to see if the pipe_user is a Domain Admin since
2065 account_pol.tdb was already opened as root, this is all we have */
2067 if ( p->pipe_user.ut.uid != sec_initial_uid()
2068 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
2070 return NT_STATUS_ACCESS_DENIED;
2073 sid_copy( &sid, &q_u->sid.sid );
2075 if ( q_u->removeall ) {
2076 if ( !revoke_all_privileges( &sid ) )
2077 return NT_STATUS_ACCESS_DENIED;
2079 return NT_STATUS_OK;
2082 /* just a little sanity check */
2084 if ( q_u->count != uni_privnames->count ) {
2085 DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n"));
2086 return NT_STATUS_INVALID_HANDLE;
2089 for ( i=0; i<q_u->count; i++ ) {
2090 UNISTR4 *uni4_str = &uni_privnames->strings[i];
2092 /* only try to add non-null strings */
2094 if ( !uni4_str->string )
2097 rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE );
2099 if ( !revoke_privilege_by_name( &sid, privname ) ) {
2100 DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname ));
2101 return NT_STATUS_NO_SUCH_PRIVILEGE;
2105 return NT_STATUS_OK;
2109 /***************************************************************************
2110 ***************************************************************************/
2112 NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u)
2114 struct lsa_info *info = NULL;
2116 PRIVILEGE_SET privileges;
2120 /* find the connection policy handle. */
2122 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2123 return NT_STATUS_INVALID_HANDLE;
2125 /* according to an NT4 PDC, you can add privileges to SIDs even without
2126 call_lsa_create_account() first. And you can use any arbitrary SID. */
2128 sid_copy( &sid, &q_u->sid.sid );
2130 if ( !get_privileges_for_sids( &mask, &sid, 1 ) )
2131 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
2133 privilege_set_init( &privileges );
2135 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
2137 DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n",
2138 sid_string_dbg(&sid), privileges.count));
2140 r_u->status = init_r_enum_acct_rights( r_u, &privileges );
2143 r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE;
2145 privilege_set_free( &privileges );
2151 /***************************************************************************
2152 ***************************************************************************/
2154 NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u)
2156 struct lsa_info *info = NULL;
2158 LUID_ATTR priv_luid;
2161 /* find the connection policy handle. */
2163 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info))
2164 return NT_STATUS_INVALID_HANDLE;
2166 unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name));
2168 DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name));
2170 if ( !se_priv_from_name( name, &mask ) )
2171 return NT_STATUS_NO_SUCH_PRIVILEGE;
2173 priv_luid = get_privilege_luid( &mask );
2175 r_u->luid.low = priv_luid.luid.low;
2176 r_u->luid.high = priv_luid.luid.high;
2179 return NT_STATUS_OK;
2184 * From here on the server routines are just dummy ones to make smbd link with
2185 * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are
2186 * pulling the server stubs across one by one.
2189 NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r)
2191 p->rng_fault_state = True;
2192 return NT_STATUS_NOT_IMPLEMENTED;
2195 NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r)
2197 p->rng_fault_state = True;
2198 return NT_STATUS_NOT_IMPLEMENTED;
2201 NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r)
2203 p->rng_fault_state = True;
2204 return NT_STATUS_NOT_IMPLEMENTED;
2207 NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p, struct lsa_SetInfoPolicy *r)
2209 p->rng_fault_state = True;
2210 return NT_STATUS_NOT_IMPLEMENTED;
2213 NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r)
2215 p->rng_fault_state = True;
2216 return NT_STATUS_NOT_IMPLEMENTED;
2219 NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r)
2221 p->rng_fault_state = True;
2222 return NT_STATUS_NOT_IMPLEMENTED;
2225 NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct lsa_EnumTrustDom *r)
2227 p->rng_fault_state = True;
2228 return NT_STATUS_NOT_IMPLEMENTED;
2231 NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r)
2233 p->rng_fault_state = True;
2234 return NT_STATUS_NOT_IMPLEMENTED;
2237 NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r)
2239 p->rng_fault_state = True;
2240 return NT_STATUS_NOT_IMPLEMENTED;
2243 NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r)
2245 p->rng_fault_state = True;
2246 return NT_STATUS_NOT_IMPLEMENTED;
2249 NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r)
2251 p->rng_fault_state = True;
2252 return NT_STATUS_NOT_IMPLEMENTED;
2255 NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct lsa_RemovePrivilegesFromAccount *r)
2257 p->rng_fault_state = True;
2258 return NT_STATUS_NOT_IMPLEMENTED;
2261 NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r)
2263 p->rng_fault_state = True;
2264 return NT_STATUS_NOT_IMPLEMENTED;
2267 NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccount *r)
2269 p->rng_fault_state = True;
2270 return NT_STATUS_NOT_IMPLEMENTED;
2273 NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r)
2275 p->rng_fault_state = True;
2276 return NT_STATUS_NOT_IMPLEMENTED;
2279 NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p, struct lsa_SetInformationTrustedDomain *r)
2281 p->rng_fault_state = True;
2282 return NT_STATUS_NOT_IMPLEMENTED;
2285 NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r)
2287 p->rng_fault_state = True;
2288 return NT_STATUS_NOT_IMPLEMENTED;
2291 NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct lsa_LookupPrivValue *r)
2293 p->rng_fault_state = True;
2294 return NT_STATUS_NOT_IMPLEMENTED;
2297 NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r)
2299 p->rng_fault_state = True;
2300 return NT_STATUS_NOT_IMPLEMENTED;
2303 NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r)
2305 p->rng_fault_state = True;
2306 return NT_STATUS_NOT_IMPLEMENTED;
2309 NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r)
2311 p->rng_fault_state = True;
2312 return NT_STATUS_NOT_IMPLEMENTED;
2315 NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct lsa_AddAccountRights *r)
2317 p->rng_fault_state = True;
2318 return NT_STATUS_NOT_IMPLEMENTED;
2321 NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r)
2323 p->rng_fault_state = True;
2324 return NT_STATUS_NOT_IMPLEMENTED;
2327 NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r)
2329 p->rng_fault_state = True;
2330 return NT_STATUS_NOT_IMPLEMENTED;
2333 NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p, struct lsa_SetTrustedDomainInfo *r)
2335 p->rng_fault_state = True;
2336 return NT_STATUS_NOT_IMPLEMENTED;
2339 NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct lsa_DeleteTrustedDomain *r)
2341 p->rng_fault_state = True;
2342 return NT_STATUS_NOT_IMPLEMENTED;
2345 NTSTATUS _lsa_StorePrivateData(pipes_struct *p, struct lsa_StorePrivateData *r)
2347 p->rng_fault_state = True;
2348 return NT_STATUS_NOT_IMPLEMENTED;
2351 NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateData *r)
2353 p->rng_fault_state = True;
2354 return NT_STATUS_NOT_IMPLEMENTED;
2357 NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r)
2359 p->rng_fault_state = True;
2360 return NT_STATUS_NOT_IMPLEMENTED;
2363 NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct lsa_QueryInfoPolicy2 *r)
2365 p->rng_fault_state = True;
2366 return NT_STATUS_NOT_IMPLEMENTED;
2369 NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p, struct lsa_SetInfoPolicy2 *r)
2371 p->rng_fault_state = True;
2372 return NT_STATUS_NOT_IMPLEMENTED;
2375 NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct lsa_QueryTrustedDomainInfoByName *r)
2377 p->rng_fault_state = True;
2378 return NT_STATUS_NOT_IMPLEMENTED;
2381 NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct lsa_SetTrustedDomainInfoByName *r)
2383 p->rng_fault_state = True;
2384 return NT_STATUS_NOT_IMPLEMENTED;
2387 NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct lsa_EnumTrustedDomainsEx *r)
2389 p->rng_fault_state = True;
2390 return NT_STATUS_NOT_IMPLEMENTED;
2393 NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p, struct lsa_CreateTrustedDomainEx *r)
2395 p->rng_fault_state = True;
2396 return NT_STATUS_NOT_IMPLEMENTED;
2399 NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct lsa_CloseTrustedDomainEx *r)
2401 p->rng_fault_state = True;
2402 return NT_STATUS_NOT_IMPLEMENTED;
2405 NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct lsa_QueryDomainInformationPolicy *r)
2407 p->rng_fault_state = True;
2408 return NT_STATUS_NOT_IMPLEMENTED;
2411 NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct lsa_SetDomainInformationPolicy *r)
2413 p->rng_fault_state = True;
2414 return NT_STATUS_NOT_IMPLEMENTED;
2417 NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct lsa_OpenTrustedDomainByName *r)
2419 p->rng_fault_state = True;
2420 return NT_STATUS_NOT_IMPLEMENTED;
2423 NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r)
2425 p->rng_fault_state = True;
2426 return NT_STATUS_NOT_IMPLEMENTED;
2429 NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r)
2431 p->rng_fault_state = True;
2432 return NT_STATUS_NOT_IMPLEMENTED;
2435 NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct lsa_LookupNames2 *r)
2437 p->rng_fault_state = True;
2438 return NT_STATUS_NOT_IMPLEMENTED;
2441 NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r)
2443 p->rng_fault_state = True;
2444 return NT_STATUS_NOT_IMPLEMENTED;
2447 NTSTATUS _lsa_CREDRWRITE(pipes_struct *p, struct lsa_CREDRWRITE *r)
2449 p->rng_fault_state = True;
2450 return NT_STATUS_NOT_IMPLEMENTED;
2453 NTSTATUS _lsa_CREDRREAD(pipes_struct *p, struct lsa_CREDRREAD *r)
2455 p->rng_fault_state = True;
2456 return NT_STATUS_NOT_IMPLEMENTED;
2459 NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p, struct lsa_CREDRENUMERATE *r)
2461 p->rng_fault_state = True;
2462 return NT_STATUS_NOT_IMPLEMENTED;
2465 NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRWRITEDOMAINCREDENTIALS *r)
2467 p->rng_fault_state = True;
2468 return NT_STATUS_NOT_IMPLEMENTED;
2471 NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRREADDOMAINCREDENTIALS *r)
2473 p->rng_fault_state = True;
2474 return NT_STATUS_NOT_IMPLEMENTED;
2477 NTSTATUS _lsa_CREDRDELETE(pipes_struct *p, struct lsa_CREDRDELETE *r)
2479 p->rng_fault_state = True;
2480 return NT_STATUS_NOT_IMPLEMENTED;
2483 NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p, struct lsa_CREDRGETTARGETINFO *r)
2485 p->rng_fault_state = True;
2486 return NT_STATUS_NOT_IMPLEMENTED;
2489 NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED *r)
2491 p->rng_fault_state = True;
2492 return NT_STATUS_NOT_IMPLEMENTED;
2495 NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r)
2497 p->rng_fault_state = True;
2498 return NT_STATUS_NOT_IMPLEMENTED;
2501 NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r)
2503 p->rng_fault_state = True;
2504 return NT_STATUS_NOT_IMPLEMENTED;
2507 NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARREGISTERAUDITEVENT *r)
2509 p->rng_fault_state = True;
2510 return NT_STATUS_NOT_IMPLEMENTED;
2513 NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p, struct lsa_LSARGENAUDITEVENT *r)
2515 p->rng_fault_state = True;
2516 return NT_STATUS_NOT_IMPLEMENTED;
2519 NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARUNREGISTERAUDITEVENT *r)
2521 p->rng_fault_state = True;
2522 return NT_STATUS_NOT_IMPLEMENTED;
2525 NTSTATUS _lsa_lsaRQueryForestTrustInformation(pipes_struct *p, struct lsa_lsaRQueryForestTrustInformation *r)
2527 p->rng_fault_state = True;
2528 return NT_STATUS_NOT_IMPLEMENTED;
2531 NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARSETFORESTTRUSTINFORMATION *r)
2533 p->rng_fault_state = True;
2534 return NT_STATUS_NOT_IMPLEMENTED;
2537 NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r)
2539 p->rng_fault_state = True;
2540 return NT_STATUS_NOT_IMPLEMENTED;
2543 NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r)
2545 p->rng_fault_state = True;
2546 return NT_STATUS_NOT_IMPLEMENTED;
2549 NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r)
2551 p->rng_fault_state = True;
2552 return NT_STATUS_NOT_IMPLEMENTED;
2555 NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r)
2557 p->rng_fault_state = True;
2558 return NT_STATUS_NOT_IMPLEMENTED;
2561 NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r)
2563 p->rng_fault_state = True;
2564 return NT_STATUS_NOT_IMPLEMENTED;
2567 NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r)
2569 p->rng_fault_state = True;
2570 return NT_STATUS_NOT_IMPLEMENTED;
2573 NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p, struct lsa_LSARADTREPORTSECURITYEVENT *r)
2575 p->rng_fault_state = True;
2576 return NT_STATUS_NOT_IMPLEMENTED;