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 /***************************************************************************
50 init_lsa_ref_domain_list - adds a domain if it's not already in, returns the index.
51 ***************************************************************************/
53 static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx,
54 struct lsa_RefDomainList *ref,
60 if (dom_name != NULL) {
61 for (num = 0; num < ref->count; num++) {
62 if (sid_equal(dom_sid, ref->domains[num].sid)) {
70 if (num >= MAX_REF_DOMAINS) {
71 /* index not found, already at maximum domain limit */
76 ref->max_size = MAX_REF_DOMAINS;
78 ref->domains = TALLOC_REALLOC_ARRAY(mem_ctx, ref->domains,
79 struct lsa_DomainInfo, ref->count);
84 init_lsa_StringLarge(&ref->domains[num].name, dom_name);
85 ref->domains[num].sid = sid_dup_talloc(mem_ctx, dom_sid);
86 if (!ref->domains[num].sid) {
94 /*******************************************************************
95 Function to free the per handle data.
96 ********************************************************************/
98 static void free_lsa_info(void *ptr)
100 struct lsa_info *lsa = (struct lsa_info *)ptr;
105 /***************************************************************************
106 initialize a lsa_DomainInfo structure.
107 ***************************************************************************/
109 static void init_dom_query_3(struct lsa_DomainInfo *r,
113 init_lsa_StringLarge(&r->name, name);
117 /***************************************************************************
118 initialize a lsa_DomainInfo structure.
119 ***************************************************************************/
121 static void init_dom_query_5(struct lsa_DomainInfo *r,
125 init_lsa_StringLarge(&r->name, name);
129 /***************************************************************************
130 init_dom_ref - adds a domain if it's not already in, returns the index.
131 ***************************************************************************/
133 static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid)
137 if (dom_name != NULL) {
138 for (num = 0; num < ref->num_ref_doms_1; num++) {
139 if (sid_equal(dom_sid, &ref->ref_dom[num].ref_dom.sid))
143 num = ref->num_ref_doms_1;
146 if (num >= MAX_REF_DOMAINS) {
147 /* index not found, already at maximum domain limit */
151 ref->num_ref_doms_1 = num+1;
152 ref->ptr_ref_dom = 1;
153 ref->max_entries = MAX_REF_DOMAINS;
154 ref->num_ref_doms_2 = num+1;
156 ref->hdr_ref_dom[num].ptr_dom_sid = 1; /* dom sid cannot be NULL. */
158 init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE);
159 init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name);
161 init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid );
166 /***************************************************************************
167 lookup_lsa_rids. Must be called as root for lookup_name to work.
168 ***************************************************************************/
170 static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx,
171 struct lsa_RefDomainList *ref,
172 struct lsa_TranslatedSid *prid,
173 uint32_t num_entries,
174 struct lsa_String *name,
176 uint32_t *pmapped_count)
178 uint32 mapped_count, i;
180 SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
185 for (i = 0; i < num_entries; i++) {
189 const char *full_name;
191 enum lsa_SidType type = SID_NAME_UNKNOWN;
193 /* Split name into domain and user component */
195 full_name = name[i].string;
196 if (full_name == NULL) {
197 return NT_STATUS_NO_MEMORY;
200 DEBUG(5, ("lookup_lsa_rids: looking up name %s\n", full_name));
202 /* We can ignore the result of lookup_name, it will not touch
203 "type" if it's not successful */
205 lookup_name(mem_ctx, full_name, flags, &domain, NULL,
210 case SID_NAME_DOM_GRP:
211 case SID_NAME_DOMAIN:
213 case SID_NAME_WKN_GRP:
214 DEBUG(5, ("init_lsa_rids: %s found\n", full_name));
215 /* Leave these unchanged */
218 /* Don't hand out anything but the list above */
219 DEBUG(5, ("init_lsa_rids: %s not found\n", full_name));
220 type = SID_NAME_UNKNOWN;
227 if (type != SID_NAME_UNKNOWN) {
228 sid_split_rid(&sid, &rid);
229 dom_idx = init_lsa_ref_domain_list(mem_ctx, ref, domain, &sid);
233 init_lsa_translated_sid(&prid[i], type, rid, dom_idx);
236 *pmapped_count = mapped_count;
240 /***************************************************************************
241 lookup_lsa_sids. Must be called as root for lookup_name to work.
242 ***************************************************************************/
244 static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx,
246 LSA_TRANSLATED_SID3 *trans_sids,
250 uint32 *pmapped_count)
252 uint32 mapped_count, i;
254 SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
259 for (i = 0; i < num_entries; i++) {
265 enum lsa_SidType type = SID_NAME_UNKNOWN;
267 /* Split name into domain and user component */
269 full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]);
270 if (full_name == NULL) {
271 DEBUG(0, ("pull_ucs2_talloc failed\n"));
272 return NT_STATUS_NO_MEMORY;
275 DEBUG(5, ("init_lsa_sids: looking up name %s\n", full_name));
277 /* We can ignore the result of lookup_name, it will not touch
278 "type" if it's not successful */
280 lookup_name(mem_ctx, full_name, flags, &domain, NULL,
285 case SID_NAME_DOM_GRP:
286 case SID_NAME_DOMAIN:
288 case SID_NAME_WKN_GRP:
289 DEBUG(5, ("init_lsa_sids: %s found\n", full_name));
290 /* Leave these unchanged */
293 /* Don't hand out anything but the list above */
294 DEBUG(5, ("init_lsa_sids: %s not found\n", full_name));
295 type = SID_NAME_UNKNOWN;
302 if (type != SID_NAME_UNKNOWN) {
304 sid_copy(&domain_sid, &sid);
305 sid_split_rid(&domain_sid, &rid);
306 dom_idx = init_dom_ref(ref, domain, &domain_sid);
310 /* Initialize the LSA_TRANSLATED_SID3 return. */
311 trans_sids[i].sid_type = type;
312 trans_sids[i].sid2 = TALLOC_P(mem_ctx, DOM_SID2);
313 if (trans_sids[i].sid2 == NULL) {
314 return NT_STATUS_NO_MEMORY;
316 init_dom_sid2(trans_sids[i].sid2, &sid);
317 trans_sids[i].sid_idx = dom_idx;
320 *pmapped_count = mapped_count;
324 /***************************************************************************
325 init_reply_lookup_names
326 ***************************************************************************/
328 static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
329 DOM_R_REF *ref, uint32 num_entries,
330 DOM_RID *rid, uint32 mapped_count)
332 r_l->ptr_dom_ref = 1;
335 r_l->num_entries = num_entries;
336 r_l->ptr_entries = 1;
337 r_l->num_entries2 = num_entries;
340 r_l->mapped_count = mapped_count;
343 /***************************************************************************
344 init_reply_lookup_names2
345 ***************************************************************************/
347 static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l,
348 DOM_R_REF *ref, uint32 num_entries,
349 DOM_RID2 *rid, uint32 mapped_count)
351 r_l->ptr_dom_ref = 1;
354 r_l->num_entries = num_entries;
355 r_l->ptr_entries = 1;
356 r_l->num_entries2 = num_entries;
359 r_l->mapped_count = mapped_count;
362 /***************************************************************************
363 init_reply_lookup_names3
364 ***************************************************************************/
366 static void init_reply_lookup_names3(LSA_R_LOOKUP_NAMES3 *r_l,
367 DOM_R_REF *ref, uint32 num_entries,
368 LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count)
370 r_l->ptr_dom_ref = 1;
373 r_l->num_entries = num_entries;
374 r_l->ptr_entries = 1;
375 r_l->num_entries2 = num_entries;
376 r_l->trans_sids = trans_sids;
378 r_l->mapped_count = mapped_count;
381 /***************************************************************************
382 init_reply_lookup_names4
383 ***************************************************************************/
385 static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l,
386 DOM_R_REF *ref, uint32 num_entries,
387 LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count)
389 r_l->ptr_dom_ref = 1;
392 r_l->num_entries = num_entries;
393 r_l->ptr_entries = 1;
394 r_l->num_entries2 = num_entries;
395 r_l->trans_sids = trans_sids;
397 r_l->mapped_count = mapped_count;
400 /***************************************************************************
401 Init_reply_lookup_sids.
402 ***************************************************************************/
404 static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l,
408 r_l->ptr_dom_ref = ref ? 1 : 0;
410 r_l->mapped_count = mapped_count;
413 /***************************************************************************
414 Init_reply_lookup_sids.
415 ***************************************************************************/
417 static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l,
421 r_l->ptr_dom_ref = ref ? 1 : 0;
423 r_l->mapped_count = mapped_count;
426 /***************************************************************************
427 Init_reply_lookup_sids.
428 ***************************************************************************/
430 static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx,
431 LSA_R_LOOKUP_SIDS *r_l,
433 LSA_TRANS_NAME_ENUM2 *names,
436 LSA_TRANS_NAME_ENUM *oldnames = &r_l->names;
438 oldnames->num_entries = names->num_entries;
439 oldnames->ptr_trans_names = names->ptr_trans_names;
440 oldnames->num_entries2 = names->num_entries2;
441 oldnames->uni_name = names->uni_name;
443 if (names->num_entries) {
446 oldnames->name = TALLOC_ARRAY(mem_ctx, LSA_TRANS_NAME, names->num_entries);
448 if (!oldnames->name) {
449 return NT_STATUS_NO_MEMORY;
451 for (i = 0; i < names->num_entries; i++) {
452 oldnames->name[i].sid_name_use = names->name[i].sid_name_use;
453 oldnames->name[i].hdr_name = names->name[i].hdr_name;
454 oldnames->name[i].domain_idx = names->name[i].domain_idx;
458 r_l->ptr_dom_ref = ref ? 1 : 0;
460 r_l->mapped_count = mapped_count;
464 static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size)
466 DOM_SID local_adm_sid;
474 init_sec_access(&mask, POLICY_EXECUTE);
475 init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
477 sid_copy(&adm_sid, get_global_sam_sid());
478 sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS);
479 init_sec_access(&mask, POLICY_ALL_ACCESS);
480 init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
482 sid_copy(&local_adm_sid, &global_sid_Builtin);
483 sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS);
484 init_sec_access(&mask, POLICY_ALL_ACCESS);
485 init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
487 if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL)
488 return NT_STATUS_NO_MEMORY;
490 if((*sd = make_sec_desc(mem_ctx, SECURITY_DESCRIPTOR_REVISION_1,
491 SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL,
492 psa, sd_size)) == NULL)
493 return NT_STATUS_NO_MEMORY;
498 #if 0 /* AD DC work in ongoing in Samba 4 */
500 /***************************************************************************
502 ***************************************************************************/
504 static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name,
505 const char *dns_name, const char *forest_name,
506 struct GUID *dom_guid, DOM_SID *dom_sid)
508 if (nb_name && *nb_name) {
509 init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE);
510 init_uni_hdr(&r_l->hdr_nb_dom_name, &r_l->uni_nb_dom_name);
511 r_l->hdr_nb_dom_name.uni_max_len += 2;
512 r_l->uni_nb_dom_name.uni_max_len += 1;
515 if (dns_name && *dns_name) {
516 init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE);
517 init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name);
518 r_l->hdr_dns_dom_name.uni_max_len += 2;
519 r_l->uni_dns_dom_name.uni_max_len += 1;
522 if (forest_name && *forest_name) {
523 init_unistr2(&r_l->uni_forest_name, forest_name, UNI_FLAGS_NONE);
524 init_uni_hdr(&r_l->hdr_forest_name, &r_l->uni_forest_name);
525 r_l->hdr_forest_name.uni_max_len += 2;
526 r_l->uni_forest_name.uni_max_len += 1;
529 /* how do we init the guid ? probably should write an init fn */
531 memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID));
535 r_l->ptr_dom_sid = 1;
536 init_dom_sid2(&r_l->dom_sid, dom_sid);
539 #endif /* AD DC work in ongoing in Samba 4 */
542 /***************************************************************************
544 ***************************************************************************/
546 NTSTATUS _lsa_OpenPolicy2(pipes_struct *p,
547 struct lsa_OpenPolicy2 *r)
549 struct lsa_info *info;
550 SEC_DESC *psd = NULL;
552 uint32 des_access = r->in.access_mask;
557 /* map the generic bits to the lsa policy ones */
558 se_map_generic(&des_access, &lsa_generic_mapping);
560 /* get the generic lsa policy SD until we store it */
561 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
563 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
564 if (p->pipe_user.ut.uid != sec_initial_uid()) {
567 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
568 acc_granted, des_access));
569 DEBUGADD(4,("but overwritten by euid == 0\n"));
572 /* This is needed for lsa_open_account and rpcclient .... :-) */
574 if (p->pipe_user.ut.uid == sec_initial_uid())
575 acc_granted = POLICY_ALL_ACCESS;
577 /* associate the domain SID with the (unique) handle. */
578 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
579 return NT_STATUS_NO_MEMORY;
582 sid_copy(&info->sid,get_global_sam_sid());
583 info->access = acc_granted;
585 /* set up the LSA QUERY INFO response */
586 if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
587 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
592 /***************************************************************************
594 ***************************************************************************/
596 NTSTATUS _lsa_OpenPolicy(pipes_struct *p,
597 struct lsa_OpenPolicy *r)
599 struct lsa_info *info;
600 SEC_DESC *psd = NULL;
602 uint32 des_access= r->in.access_mask;
607 /* map the generic bits to the lsa policy ones */
608 se_map_generic(&des_access, &lsa_generic_mapping);
610 /* get the generic lsa policy SD until we store it */
611 lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
613 if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) {
614 if (geteuid() != 0) {
617 DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n",
618 acc_granted, des_access));
619 DEBUGADD(4,("but overwritten by euid == 0\n"));
620 acc_granted = des_access;
623 /* associate the domain SID with the (unique) handle. */
624 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
625 return NT_STATUS_NO_MEMORY;
628 sid_copy(&info->sid,get_global_sam_sid());
629 info->access = acc_granted;
631 /* set up the LSA QUERY INFO response */
632 if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info))
633 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
638 /***************************************************************************
639 _lsa_EnumTrustDom - this needs fixing to do more than return NULL ! JRA.
641 ***************************************************************************/
643 NTSTATUS _lsa_EnumTrustDom(pipes_struct *p,
644 struct lsa_EnumTrustDom *r)
646 struct lsa_info *info;
648 struct trustdom_info **domains;
649 struct lsa_DomainInfo *lsa_domains = NULL;
653 * preferred length is set to 5 as a "our" preferred length
654 * nt sets this parameter to 2
655 * update (20.08.2002): it's not preferred length, but preferred size!
656 * it needs further investigation how to optimally choose this value
658 uint32 max_num_domains =
659 r->in.max_size < 5 ? r->in.max_size : 10;
664 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
665 return NT_STATUS_INVALID_HANDLE;
667 /* check if the user have enough rights */
668 if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION))
669 return NT_STATUS_ACCESS_DENIED;
671 nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains);
673 if (!NT_STATUS_IS_OK(nt_status)) {
677 if (*r->in.resume_handle < num_domains) {
678 num_thistime = MIN(num_domains, max_num_domains);
680 nt_status = STATUS_MORE_ENTRIES;
682 if (*r->in.resume_handle + num_thistime > num_domains) {
683 num_thistime = num_domains - *r->in.resume_handle;
684 nt_status = NT_STATUS_OK;
687 next_idx = *r->in.resume_handle + num_thistime;
690 next_idx = 0xffffffff;
691 nt_status = NT_STATUS_NO_MORE_ENTRIES;
694 /* set up the lsa_enum_trust_dom response */
696 lsa_domains = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_DomainInfo,
699 return NT_STATUS_NO_MEMORY;
702 for (i=0; i<num_thistime; i++) {
703 init_lsa_StringLarge(&lsa_domains[i].name, domains[i]->name);
704 lsa_domains[i].sid = &domains[i]->sid;
707 *r->out.resume_handle = next_idx;
708 r->out.domains->count = num_thistime;
709 r->out.domains->domains = lsa_domains;
714 /***************************************************************************
716 ***************************************************************************/
718 NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p,
719 struct lsa_QueryInfoPolicy *r)
721 NTSTATUS status = NT_STATUS_OK;
722 struct lsa_info *handle;
726 union lsa_PolicyInformation *info = NULL;
728 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
729 return NT_STATUS_INVALID_HANDLE;
731 info = TALLOC_ZERO_P(p->mem_ctx, union lsa_PolicyInformation);
733 return NT_STATUS_NO_MEMORY;
736 switch (r->in.level) {
740 uint32 policy_def = LSA_AUDIT_POLICY_ALL;
742 /* check if the user have enough rights */
743 if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) {
744 DEBUG(10,("_lsa_QueryInfoPolicy: insufficient access rights\n"));
745 return NT_STATUS_ACCESS_DENIED;
748 /* fake info: We audit everything. ;) */
750 info->audit_events.auditing_mode = true;
751 info->audit_events.count = LSA_AUDIT_NUM_CATEGORIES;
752 info->audit_events.settings = TALLOC_ZERO_ARRAY(p->mem_ctx,
753 enum lsa_PolicyAuditPolicy,
754 info->audit_events.count);
755 if (!info->audit_events.settings) {
756 return NT_STATUS_NO_MEMORY;
759 info->audit_events.settings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def;
760 info->audit_events.settings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def;
761 info->audit_events.settings[LSA_AUDIT_CATEGORY_LOGON] = policy_def;
762 info->audit_events.settings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def;
763 info->audit_events.settings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def;
764 info->audit_events.settings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def;
765 info->audit_events.settings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def;
770 /* check if the user have enough rights */
771 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
772 return NT_STATUS_ACCESS_DENIED;
774 /* Request PolicyPrimaryDomainInformation. */
775 switch (lp_server_role()) {
776 case ROLE_DOMAIN_PDC:
777 case ROLE_DOMAIN_BDC:
778 name = get_global_sam_name();
779 sid = get_global_sam_sid();
781 case ROLE_DOMAIN_MEMBER:
782 name = lp_workgroup();
783 /* We need to return the Domain SID here. */
784 if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid))
787 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
789 case ROLE_STANDALONE:
790 name = lp_workgroup();
794 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
796 init_dom_query_3(&info->domain, name, sid);
799 /* check if the user have enough rights */
800 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
801 return NT_STATUS_ACCESS_DENIED;
803 /* Request PolicyAccountDomainInformation. */
804 name = get_global_sam_name();
805 sid = get_global_sam_sid();
807 init_dom_query_5(&info->account_domain, name, sid);
810 /* check if the user have enough rights */
811 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
812 return NT_STATUS_ACCESS_DENIED;
814 switch (lp_server_role()) {
815 case ROLE_DOMAIN_BDC:
817 * only a BDC is a backup controller
818 * of the domain, it controls.
824 * any other role is a primary
825 * of the domain, it controls.
832 DEBUG(0,("_lsa_QueryInfoPolicy: unknown info level in Lsa Query: %d\n",
834 status = NT_STATUS_INVALID_INFO_CLASS;
843 /***************************************************************************
844 _lsa_lookup_sids_internal
845 ***************************************************************************/
847 static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p,
848 uint16 level, /* input */
849 int num_sids, /* input */
850 const DOM_SID2 *sid, /* input */
851 DOM_R_REF **pp_ref, /* output */
852 LSA_TRANS_NAME_ENUM2 *names, /* input/output */
853 uint32 *pp_mapped_count)
857 const DOM_SID **sids = NULL;
858 DOM_R_REF *ref = NULL;
859 uint32 mapped_count = 0;
860 struct lsa_dom_info *dom_infos = NULL;
861 struct lsa_name_info *name_infos = NULL;
863 *pp_mapped_count = 0;
871 sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids);
872 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
874 if (sids == NULL || ref == NULL) {
875 return NT_STATUS_NO_MEMORY;
878 for (i=0; i<num_sids; i++) {
879 sids[i] = &sid[i].sid;
882 status = lookup_sids(p->mem_ctx, num_sids, sids, level,
883 &dom_infos, &name_infos);
885 if (!NT_STATUS_IS_OK(status)) {
889 names->name = TALLOC_ARRAY(p->mem_ctx, LSA_TRANS_NAME2, num_sids);
890 names->uni_name = TALLOC_ARRAY(p->mem_ctx, UNISTR2, num_sids);
891 if ((names->name == NULL) || (names->uni_name == NULL)) {
892 return NT_STATUS_NO_MEMORY;
895 for (i=0; i<MAX_REF_DOMAINS; i++) {
897 if (!dom_infos[i].valid) {
901 if (init_dom_ref(ref, dom_infos[i].name,
902 &dom_infos[i].sid) != i) {
903 DEBUG(0, ("Domain %s mentioned twice??\n",
905 return NT_STATUS_INTERNAL_ERROR;
909 for (i=0; i<num_sids; i++) {
910 struct lsa_name_info *name = &name_infos[i];
912 if (name->type == SID_NAME_UNKNOWN) {
915 /* Unknown sids should return the string
916 * representation of the SID. Windows 2003 behaves
917 * rather erratic here, in many cases it returns the
918 * RID as 8 bytes hex, in others it returns the full
919 * SID. We (Jerry/VL) could not figure out which the
920 * hard cases are, so leave it with the SID. */
921 name->name = talloc_asprintf(p->mem_ctx, "%s",
924 if (name->name == NULL) {
925 return NT_STATUS_NO_MEMORY;
930 init_lsa_trans_name2(&names->name[i], &names->uni_name[i],
931 name->type, name->name, name->dom_idx);
934 names->num_entries = num_sids;
935 names->ptr_trans_names = 1;
936 names->num_entries2 = num_sids;
938 status = NT_STATUS_NONE_MAPPED;
939 if (mapped_count > 0) {
940 status = (mapped_count < num_sids) ?
941 STATUS_SOME_UNMAPPED : NT_STATUS_OK;
944 DEBUG(10, ("num_sids %d, mapped_count %d, status %s\n",
945 num_sids, mapped_count, nt_errstr(status)));
947 *pp_mapped_count = mapped_count;
953 /***************************************************************************
955 ***************************************************************************/
957 NTSTATUS _lsa_lookup_sids(pipes_struct *p,
958 LSA_Q_LOOKUP_SIDS *q_u,
959 LSA_R_LOOKUP_SIDS *r_u)
961 struct lsa_info *handle;
962 int num_sids = q_u->sids.num_entries;
963 uint32 mapped_count = 0;
964 DOM_R_REF *ref = NULL;
965 LSA_TRANS_NAME_ENUM2 names;
968 if ((q_u->level < 1) || (q_u->level > 6)) {
969 return NT_STATUS_INVALID_PARAMETER;
972 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
973 return NT_STATUS_INVALID_HANDLE;
976 /* check if the user has enough rights */
977 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
978 return NT_STATUS_ACCESS_DENIED;
981 if (num_sids > MAX_LOOKUP_SIDS) {
982 DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n",
983 MAX_LOOKUP_SIDS, num_sids));
984 return NT_STATUS_NONE_MAPPED;
987 r_u->status = _lsa_lookup_sids_internal(p,
995 /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */
997 status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, &names, mapped_count);
998 if (!NT_STATUS_IS_OK(status)) {
1004 /***************************************************************************
1006 ***************************************************************************/
1008 NTSTATUS _lsa_lookup_sids2(pipes_struct *p,
1009 LSA_Q_LOOKUP_SIDS2 *q_u,
1010 LSA_R_LOOKUP_SIDS2 *r_u)
1012 struct lsa_info *handle;
1013 int num_sids = q_u->sids.num_entries;
1014 uint32 mapped_count = 0;
1015 DOM_R_REF *ref = NULL;
1017 if ((q_u->level < 1) || (q_u->level > 6)) {
1018 return NT_STATUS_INVALID_PARAMETER;
1021 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1022 return NT_STATUS_INVALID_HANDLE;
1025 /* check if the user have enough rights */
1026 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1027 return NT_STATUS_ACCESS_DENIED;
1030 if (num_sids > MAX_LOOKUP_SIDS) {
1031 DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n",
1032 MAX_LOOKUP_SIDS, num_sids));
1033 return NT_STATUS_NONE_MAPPED;
1036 r_u->status = _lsa_lookup_sids_internal(p,
1044 init_reply_lookup_sids2(r_u, ref, mapped_count);
1048 /***************************************************************************
1050 ***************************************************************************/
1052 NTSTATUS _lsa_lookup_sids3(pipes_struct *p,
1053 LSA_Q_LOOKUP_SIDS3 *q_u,
1054 LSA_R_LOOKUP_SIDS3 *r_u)
1056 int num_sids = q_u->sids.num_entries;
1057 uint32 mapped_count = 0;
1058 DOM_R_REF *ref = NULL;
1060 if ((q_u->level < 1) || (q_u->level > 6)) {
1061 return NT_STATUS_INVALID_PARAMETER;
1064 /* No policy handle on this call. Restrict to crypto connections. */
1065 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1066 DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n",
1067 get_remote_machine_name() ));
1068 return NT_STATUS_INVALID_PARAMETER;
1071 if (num_sids > MAX_LOOKUP_SIDS) {
1072 DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n",
1073 MAX_LOOKUP_SIDS, num_sids));
1074 return NT_STATUS_NONE_MAPPED;
1077 r_u->status = _lsa_lookup_sids_internal(p,
1085 init_reply_lookup_sids3(r_u, ref, mapped_count);
1089 static int lsa_lookup_level_to_flags(uint16 level)
1095 flags = LOOKUP_NAME_ALL;
1098 flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_REMOTE|LOOKUP_NAME_ISOLATED;
1101 flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED;
1107 flags = LOOKUP_NAME_NONE;
1114 /***************************************************************************
1116 ***************************************************************************/
1118 NTSTATUS _lsa_LookupNames(pipes_struct *p,
1119 struct lsa_LookupNames *r)
1121 NTSTATUS status = NT_STATUS_NONE_MAPPED;
1122 struct lsa_info *handle;
1123 struct lsa_String *names = r->in.names;
1124 uint32 num_entries = r->in.num_names;
1125 struct lsa_RefDomainList *domains = NULL;
1126 struct lsa_TranslatedSid *rids = NULL;
1127 uint32 mapped_count = 0;
1130 if (num_entries > MAX_LOOKUP_SIDS) {
1131 num_entries = MAX_LOOKUP_SIDS;
1132 DEBUG(5,("_lsa_LookupNames: truncating name lookup list to %d\n",
1136 flags = lsa_lookup_level_to_flags(r->in.level);
1138 domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList);
1140 return NT_STATUS_NO_MEMORY;
1144 rids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid,
1147 return NT_STATUS_NO_MEMORY;
1153 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) {
1154 status = NT_STATUS_INVALID_HANDLE;
1158 /* check if the user have enough rights */
1159 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1160 status = NT_STATUS_ACCESS_DENIED;
1164 /* set up the LSA Lookup RIDs response */
1165 become_root(); /* lookup_name can require root privs */
1166 status = lookup_lsa_rids(p->mem_ctx, domains, rids, num_entries,
1167 names, flags, &mapped_count);
1172 if (NT_STATUS_IS_OK(status) && (num_entries != 0) ) {
1173 if (mapped_count == 0) {
1174 status = NT_STATUS_NONE_MAPPED;
1175 } else if (mapped_count != num_entries) {
1176 status = STATUS_SOME_UNMAPPED;
1180 *r->out.count = num_entries;
1181 *r->out.domains = domains;
1182 r->out.sids->sids = rids;
1183 r->out.sids->count = mapped_count;
1188 /***************************************************************************
1190 ***************************************************************************/
1192 NTSTATUS _lsa_LookupNames2(pipes_struct *p,
1193 struct lsa_LookupNames2 *r)
1196 struct lsa_LookupNames q;
1197 struct lsa_TransSidArray2 *sid_array2 = r->in.sids;
1198 struct lsa_TransSidArray *sid_array = NULL;
1201 sid_array = TALLOC_ZERO_P(p->mem_ctx, struct lsa_TransSidArray);
1203 return NT_STATUS_NO_MEMORY;
1206 q.in.handle = r->in.handle;
1207 q.in.num_names = r->in.num_names;
1208 q.in.names = r->in.names;
1209 q.in.level = r->in.level;
1210 q.in.sids = sid_array;
1211 q.in.count = r->in.count;
1212 /* we do not know what this is for */
1213 /* = r->in.unknown1; */
1214 /* = r->in.unknown2; */
1216 q.out.domains = r->out.domains;
1217 q.out.sids = sid_array;
1218 q.out.count = r->out.count;
1220 status = _lsa_LookupNames(p, &q);
1222 sid_array2->sids = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count);
1223 if (!sid_array2->sids) {
1224 return NT_STATUS_NO_MEMORY;
1227 for (i=0; i<sid_array->count; i++) {
1228 sid_array2->sids[i].sid_type = sid_array->sids[i].sid_type;
1229 sid_array2->sids[i].rid = sid_array->sids[i].rid;
1230 sid_array2->sids[i].sid_index = sid_array->sids[i].sid_index;
1231 sid_array2->sids[i].unknown = 0;
1234 r->out.sids = sid_array2;
1239 /***************************************************************************
1240 lsa_reply_lookup_names3.
1241 ***************************************************************************/
1243 NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u)
1245 struct lsa_info *handle;
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_names3: 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 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1265 return NT_STATUS_NO_MEMORY;
1268 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1270 return NT_STATUS_NO_MEMORY;
1276 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
1277 r_u->status = NT_STATUS_INVALID_HANDLE;
1281 /* check if the user have enough rights */
1282 if (!(handle->access & POLICY_LOOKUP_NAMES)) {
1283 r_u->status = NT_STATUS_ACCESS_DENIED;
1287 /* set up the LSA Lookup SIDs response */
1288 become_root(); /* lookup_name can require root privs */
1289 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1290 names, flags, &mapped_count);
1295 if (NT_STATUS_IS_OK(r_u->status)) {
1296 if (mapped_count == 0) {
1297 r_u->status = NT_STATUS_NONE_MAPPED;
1298 } else if (mapped_count != num_entries) {
1299 r_u->status = STATUS_SOME_UNMAPPED;
1303 init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count);
1307 /***************************************************************************
1308 lsa_reply_lookup_names4.
1309 ***************************************************************************/
1311 NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u)
1313 UNISTR2 *names = q_u->uni_name;
1314 uint32 num_entries = q_u->num_entries;
1315 DOM_R_REF *ref = NULL;
1316 LSA_TRANSLATED_SID3 *trans_sids = NULL;
1317 uint32 mapped_count = 0;
1320 if (num_entries > MAX_LOOKUP_SIDS) {
1321 num_entries = MAX_LOOKUP_SIDS;
1322 DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries));
1325 /* Probably the lookup_level is some sort of bitmask. */
1326 if (q_u->lookup_level == 1) {
1327 flags = LOOKUP_NAME_ALL;
1330 /* No policy handle on this call. Restrict to crypto connections. */
1331 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1332 DEBUG(0,("_lsa_lookup_names4: client %s not using schannel for netlogon\n",
1333 get_remote_machine_name() ));
1334 return NT_STATUS_INVALID_PARAMETER;
1337 ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
1339 return NT_STATUS_NO_MEMORY;
1343 trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
1345 return NT_STATUS_NO_MEMORY;
1351 /* set up the LSA Lookup SIDs response */
1352 become_root(); /* lookup_name can require root privs */
1353 r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
1354 names, flags, &mapped_count);
1357 if (NT_STATUS_IS_OK(r_u->status)) {
1358 if (mapped_count == 0) {
1359 r_u->status = NT_STATUS_NONE_MAPPED;
1360 } else if (mapped_count != num_entries) {
1361 r_u->status = STATUS_SOME_UNMAPPED;
1365 init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count);
1369 /***************************************************************************
1370 _lsa_close. Also weird - needs to check if lsa handle is correct. JRA.
1371 ***************************************************************************/
1373 NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r)
1375 if (!find_policy_by_hnd(p, r->in.handle, NULL)) {
1376 return NT_STATUS_INVALID_HANDLE;
1379 close_policy_hnd(p, r->in.handle);
1380 return NT_STATUS_OK;
1383 /***************************************************************************
1384 ***************************************************************************/
1386 NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct lsa_OpenSecret *r)
1388 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1391 /***************************************************************************
1392 ***************************************************************************/
1394 NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct lsa_OpenTrustedDomain *r)
1396 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1399 /***************************************************************************
1400 ***************************************************************************/
1402 NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, struct lsa_CreateTrustedDomain *r)
1404 return NT_STATUS_ACCESS_DENIED;
1407 /***************************************************************************
1408 ***************************************************************************/
1410 NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct lsa_CreateSecret *r)
1412 return NT_STATUS_ACCESS_DENIED;
1415 /***************************************************************************
1416 ***************************************************************************/
1418 NTSTATUS _lsa_SetSecret(pipes_struct *p, struct lsa_SetSecret *r)
1420 return NT_STATUS_ACCESS_DENIED;
1423 /***************************************************************************
1425 ***************************************************************************/
1427 NTSTATUS _lsa_DeleteObject(pipes_struct *p,
1428 struct lsa_DeleteObject *r)
1430 return NT_STATUS_ACCESS_DENIED;
1433 /***************************************************************************
1435 ***************************************************************************/
1437 NTSTATUS _lsa_EnumPrivs(pipes_struct *p,
1438 struct lsa_EnumPrivs *r)
1440 struct lsa_info *handle;
1442 uint32 enum_context = *r->in.resume_handle;
1443 int num_privs = count_all_privileges();
1444 struct lsa_PrivEntry *entries = NULL;
1447 /* remember that the enum_context starts at 0 and not 1 */
1449 if ( enum_context >= num_privs )
1450 return NT_STATUS_NO_MORE_ENTRIES;
1452 DEBUG(10,("_lsa_EnumPrivs: enum_context:%d total entries:%d\n",
1453 enum_context, num_privs));
1455 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1456 return NT_STATUS_INVALID_HANDLE;
1458 /* check if the user have enough rights
1459 I don't know if it's the right one. not documented. */
1461 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1462 return NT_STATUS_ACCESS_DENIED;
1465 entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_PrivEntry, num_privs);
1467 return NT_STATUS_NO_MEMORY;
1473 for (i = 0; i < num_privs; i++) {
1474 if( i < enum_context) {
1476 init_lsa_StringLarge(&entries[i].name, NULL);
1478 entries[i].luid.low = 0;
1479 entries[i].luid.high = 0;
1482 init_lsa_StringLarge(&entries[i].name, privs[i].name);
1484 luid = get_privilege_luid( &privs[i].se_priv );
1486 entries[i].luid.low = luid.luid.low;
1487 entries[i].luid.high = luid.luid.high;
1491 enum_context = num_privs;
1493 *r->out.resume_handle = enum_context;
1494 r->out.privs->count = num_privs;
1495 r->out.privs->privs = entries;
1497 return NT_STATUS_OK;
1500 /***************************************************************************
1501 _lsa_LookupPrivDisplayName
1502 ***************************************************************************/
1504 NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p,
1505 struct lsa_LookupPrivDisplayName *r)
1507 struct lsa_info *handle;
1508 const char *description;
1509 struct lsa_StringLarge *lsa_name;
1511 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1512 return NT_STATUS_INVALID_HANDLE;
1514 /* check if the user have enough rights */
1517 * I don't know if it's the right one. not documented.
1519 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1520 return NT_STATUS_ACCESS_DENIED;
1522 DEBUG(10,("_lsa_LookupPrivDisplayName: name = %s\n", r->in.name->string));
1524 description = get_privilege_dispname(r->in.name->string);
1526 DEBUG(10,("_lsa_LookupPrivDisplayName: doesn't exist\n"));
1527 return NT_STATUS_NO_SUCH_PRIVILEGE;
1530 DEBUG(10,("_lsa_LookupPrivDisplayName: display name = %s\n", description));
1532 lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge);
1534 return NT_STATUS_NO_MEMORY;
1537 init_lsa_StringLarge(lsa_name, description);
1539 *r->out.returned_language_id = r->in.language_id;
1540 *r->out.disp_name = lsa_name;
1542 return NT_STATUS_OK;
1545 /***************************************************************************
1547 ***************************************************************************/
1549 NTSTATUS _lsa_EnumAccounts(pipes_struct *p,
1550 struct lsa_EnumAccounts *r)
1552 struct lsa_info *handle;
1554 int i, j, num_entries;
1556 struct lsa_SidPtr *sids = NULL;
1558 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1559 return NT_STATUS_INVALID_HANDLE;
1561 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1562 return NT_STATUS_ACCESS_DENIED;
1567 /* The only way we can currently find out all the SIDs that have been
1568 privileged is to scan all privileges */
1570 status = privilege_enumerate_accounts(&sid_list, &num_entries);
1571 if (!NT_STATUS_IS_OK(status)) {
1575 if (*r->in.resume_handle >= num_entries) {
1576 return NT_STATUS_NO_MORE_ENTRIES;
1579 if (num_entries - *r->in.resume_handle) {
1580 sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr,
1581 num_entries - *r->in.resume_handle);
1583 SAFE_FREE(sid_list);
1584 return NT_STATUS_NO_MEMORY;
1587 for (i = *r->in.resume_handle, j = 0; i < num_entries; i++, j++) {
1588 sids[j].sid = sid_dup_talloc(p->mem_ctx, &sid_list[i]);
1590 SAFE_FREE(sid_list);
1591 return NT_STATUS_NO_MEMORY;
1596 talloc_free(sid_list);
1598 *r->out.resume_handle = num_entries;
1599 r->out.sids->num_sids = num_entries;
1600 r->out.sids->sids = sids;
1602 return NT_STATUS_OK;
1605 /***************************************************************************
1607 ***************************************************************************/
1609 NTSTATUS _lsa_GetUserName(pipes_struct *p,
1610 struct lsa_GetUserName *r)
1612 const char *username, *domname;
1613 user_struct *vuser = get_valid_user_struct(p->vuid);
1614 struct lsa_String *account_name = NULL;
1615 struct lsa_String *authority_name = NULL;
1618 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
1622 * I'm 99% sure this is not the right place to do this,
1623 * global_sid_Anonymous should probably be put into the token
1624 * instead of the guest id -- vl
1626 if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous,
1627 &domname, &username, NULL)) {
1628 return NT_STATUS_NO_MEMORY;
1631 username = vuser->user.smb_name;
1632 domname = vuser->user.domain;
1635 account_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String);
1636 if (!account_name) {
1637 return NT_STATUS_NO_MEMORY;
1640 authority_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String);
1641 if (!authority_name) {
1642 return NT_STATUS_NO_MEMORY;
1645 init_lsa_String(account_name, username);
1646 init_lsa_String(authority_name, domname);
1648 *r->out.account_name = account_name;
1649 *r->out.authority_name = authority_name;
1651 return NT_STATUS_OK;
1654 /***************************************************************************
1656 ***************************************************************************/
1658 NTSTATUS _lsa_CreateAccount(pipes_struct *p,
1659 struct lsa_CreateAccount *r)
1661 struct lsa_info *handle;
1662 struct lsa_info *info;
1664 /* find the connection policy handle. */
1665 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1666 return NT_STATUS_INVALID_HANDLE;
1668 /* check if the user have enough rights */
1671 * I don't know if it's the right one. not documented.
1672 * but guessed with rpcclient.
1674 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
1675 return NT_STATUS_ACCESS_DENIED;
1677 /* check to see if the pipe_user is a Domain Admin since
1678 account_pol.tdb was already opened as root, this is all we have */
1680 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1681 return NT_STATUS_ACCESS_DENIED;
1683 if ( is_privileged_sid( r->in.sid ) )
1684 return NT_STATUS_OBJECT_NAME_COLLISION;
1686 /* associate the user/group SID with the (unique) handle. */
1688 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1689 return NT_STATUS_NO_MEMORY;
1692 info->sid = *r->in.sid;
1693 info->access = r->in.access_mask;
1695 /* get a (unique) handle. open a policy on it. */
1696 if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info))
1697 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1699 return privilege_create_account( &info->sid );
1703 /***************************************************************************
1705 ***************************************************************************/
1707 NTSTATUS _lsa_OpenAccount(pipes_struct *p,
1708 struct lsa_OpenAccount *r)
1710 struct lsa_info *handle;
1711 struct lsa_info *info;
1713 /* find the connection policy handle. */
1714 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1715 return NT_STATUS_INVALID_HANDLE;
1717 /* check if the user have enough rights */
1720 * I don't know if it's the right one. not documented.
1721 * but guessed with rpcclient.
1723 if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION))
1724 return NT_STATUS_ACCESS_DENIED;
1726 /* TODO: Fis the parsing routine before reenabling this check! */
1728 if (!lookup_sid(&handle->sid, dom_name, name, &type))
1729 return NT_STATUS_ACCESS_DENIED;
1731 /* associate the user/group SID with the (unique) handle. */
1732 if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL)
1733 return NT_STATUS_NO_MEMORY;
1736 info->sid = *r->in.sid;
1737 info->access = r->in.access_mask;
1739 /* get a (unique) handle. open a policy on it. */
1740 if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info))
1741 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1743 return NT_STATUS_OK;
1746 /***************************************************************************
1747 _lsa_EnumPrivsAccount
1748 For a given SID, enumerate all the privilege this account has.
1749 ***************************************************************************/
1751 NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p,
1752 struct lsa_EnumPrivsAccount *r)
1754 NTSTATUS status = NT_STATUS_OK;
1755 struct lsa_info *info=NULL;
1757 PRIVILEGE_SET privileges;
1758 struct lsa_PrivilegeSet *priv_set = NULL;
1759 struct lsa_LUIDAttribute *luid_attrs = NULL;
1762 /* find the connection policy handle. */
1763 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1764 return NT_STATUS_INVALID_HANDLE;
1766 if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) )
1767 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
1769 privilege_set_init( &privileges );
1771 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
1773 DEBUG(10,("_lsa_EnumPrivsAccount: %s has %d privileges\n",
1774 sid_string_dbg(&info->sid),
1777 priv_set = TALLOC_ZERO_P(p->mem_ctx, struct lsa_PrivilegeSet);
1779 status = NT_STATUS_NO_MEMORY;
1783 luid_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx,
1784 struct lsa_LUIDAttribute,
1787 status = NT_STATUS_NO_MEMORY;
1791 for (i=0; i<privileges.count; i++) {
1792 luid_attrs[i].luid.low = privileges.set[i].luid.low;
1793 luid_attrs[i].luid.high = privileges.set[i].luid.high;
1794 luid_attrs[i].attribute = privileges.set[i].attr;
1797 priv_set->count = privileges.count;
1798 priv_set->unknown = 0;
1799 priv_set->set = luid_attrs;
1801 *r->out.privs = priv_set;
1803 status = NT_STATUS_NO_SUCH_PRIVILEGE;
1807 privilege_set_free( &privileges );
1812 /***************************************************************************
1813 _lsa_GetSystemAccessAccount
1814 ***************************************************************************/
1816 NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p,
1817 struct lsa_GetSystemAccessAccount *r)
1819 struct lsa_info *info=NULL;
1821 /* find the connection policy handle. */
1823 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1824 return NT_STATUS_INVALID_HANDLE;
1826 if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL))
1827 return NT_STATUS_ACCESS_DENIED;
1830 0x01 -> Log on locally
1831 0x02 -> Access this computer from network
1832 0x04 -> Log on as a batch job
1833 0x10 -> Log on as a service
1835 they can be ORed together
1838 *r->out.access_mask = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK;
1840 return NT_STATUS_OK;
1843 /***************************************************************************
1844 update the systemaccount information
1845 ***************************************************************************/
1847 NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p,
1848 struct lsa_SetSystemAccessAccount *r)
1850 struct lsa_info *info=NULL;
1853 /* find the connection policy handle. */
1854 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1855 return NT_STATUS_INVALID_HANDLE;
1857 /* check to see if the pipe_user is a Domain Admin since
1858 account_pol.tdb was already opened as root, this is all we have */
1860 if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1861 return NT_STATUS_ACCESS_DENIED;
1863 if (!pdb_getgrsid(&map, info->sid))
1864 return NT_STATUS_NO_SUCH_GROUP;
1866 return pdb_update_group_mapping_entry(&map);
1869 /***************************************************************************
1870 _lsa_AddPrivilegesToAccount
1871 For a given SID, add some privileges.
1872 ***************************************************************************/
1874 NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p,
1875 struct lsa_AddPrivilegesToAccount *r)
1877 struct lsa_info *info = NULL;
1879 struct lsa_PrivilegeSet *set = NULL;
1881 /* find the connection policy handle. */
1882 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1883 return NT_STATUS_INVALID_HANDLE;
1885 /* check to see if the pipe_user is root or a Domain Admin since
1886 account_pol.tdb was already opened as root, this is all we have */
1888 if ( p->pipe_user.ut.uid != sec_initial_uid()
1889 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1891 return NT_STATUS_ACCESS_DENIED;
1895 if ( !privilege_set_to_se_priv( &mask, set ) )
1896 return NT_STATUS_NO_SUCH_PRIVILEGE;
1898 if ( !grant_privilege( &info->sid, &mask ) ) {
1899 DEBUG(3,("_lsa_AddPrivilegesToAccount: grant_privilege(%s) failed!\n",
1900 sid_string_dbg(&info->sid) ));
1901 DEBUG(3,("Privilege mask:\n"));
1902 dump_se_priv( DBGC_ALL, 3, &mask );
1903 return NT_STATUS_NO_SUCH_PRIVILEGE;
1906 return NT_STATUS_OK;
1909 /***************************************************************************
1910 _lsa_RemovePrivilegesFromAccount
1911 For a given SID, remove some privileges.
1912 ***************************************************************************/
1914 NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p,
1915 struct lsa_RemovePrivilegesFromAccount *r)
1917 struct lsa_info *info = NULL;
1919 struct lsa_PrivilegeSet *set = NULL;
1921 /* find the connection policy handle. */
1922 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
1923 return NT_STATUS_INVALID_HANDLE;
1925 /* check to see if the pipe_user is root or a Domain Admin since
1926 account_pol.tdb was already opened as root, this is all we have */
1928 if ( p->pipe_user.ut.uid != sec_initial_uid()
1929 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
1931 return NT_STATUS_ACCESS_DENIED;
1936 if ( !privilege_set_to_se_priv( &mask, set ) )
1937 return NT_STATUS_NO_SUCH_PRIVILEGE;
1939 if ( !revoke_privilege( &info->sid, &mask ) ) {
1940 DEBUG(3,("_lsa_RemovePrivilegesFromAccount: revoke_privilege(%s) failed!\n",
1941 sid_string_dbg(&info->sid) ));
1942 DEBUG(3,("Privilege mask:\n"));
1943 dump_se_priv( DBGC_ALL, 3, &mask );
1944 return NT_STATUS_NO_SUCH_PRIVILEGE;
1947 return NT_STATUS_OK;
1950 /***************************************************************************
1952 ***************************************************************************/
1954 NTSTATUS _lsa_QuerySecurity(pipes_struct *p,
1955 struct lsa_QuerySecurity *r)
1957 struct lsa_info *handle=NULL;
1958 SEC_DESC *psd = NULL;
1962 /* find the connection policy handle. */
1963 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle))
1964 return NT_STATUS_INVALID_HANDLE;
1966 /* check if the user have enough rights */
1967 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
1968 return NT_STATUS_ACCESS_DENIED;
1971 switch (r->in.sec_info) {
1973 /* SD contains only the owner */
1975 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1976 if(!NT_STATUS_IS_OK(status))
1977 return NT_STATUS_NO_MEMORY;
1980 if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1981 return NT_STATUS_NO_MEMORY;
1984 /* SD contains only the ACL */
1986 status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size);
1987 if(!NT_STATUS_IS_OK(status))
1988 return NT_STATUS_NO_MEMORY;
1990 if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL)
1991 return NT_STATUS_NO_MEMORY;
1994 return NT_STATUS_INVALID_LEVEL;
2000 #if 0 /* AD DC work in ongoing in Samba 4 */
2002 /***************************************************************************
2003 ***************************************************************************/
2005 NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u)
2007 struct lsa_info *handle;
2008 const char *nb_name;
2009 char *dns_name = NULL;
2010 char *forest_name = NULL;
2011 DOM_SID *sid = NULL;
2016 r_u->status = NT_STATUS_OK;
2018 if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle))
2019 return NT_STATUS_INVALID_HANDLE;
2021 switch (q_u->info_class) {
2023 /* check if the user have enough rights */
2024 if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
2025 return NT_STATUS_ACCESS_DENIED;
2027 /* Request PolicyPrimaryDomainInformation. */
2028 switch (lp_server_role()) {
2029 case ROLE_DOMAIN_PDC:
2030 case ROLE_DOMAIN_BDC:
2031 nb_name = get_global_sam_name();
2032 /* ugly temp hack for these next two */
2034 /* This should be a 'netbios domain -> DNS domain' mapping */
2035 dnsdomname = get_mydnsdomname(p->mem_ctx);
2036 if (!dnsdomname || !*dnsdomname) {
2037 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
2039 strlower_m(dnsdomname);
2041 dns_name = dnsdomname;
2042 forest_name = dnsdomname;
2044 sid = get_global_sam_sid();
2045 secrets_fetch_domain_guid(lp_workgroup(), &guid);
2048 return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
2050 init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name,
2051 forest_name,&guid,sid);
2054 DEBUG(0,("_lsa_query_info2: unknown info level in Lsa Query: %d\n", q_u->info_class));
2055 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
2059 if (NT_STATUS_IS_OK(r_u->status)) {
2061 r_u->info_class = q_u->info_class;
2066 #endif /* AD DC work in ongoing in Samba 4 */
2068 /***************************************************************************
2069 _lsa_AddAccountRights
2070 ***************************************************************************/
2072 NTSTATUS _lsa_AddAccountRights(pipes_struct *p,
2073 struct lsa_AddAccountRights *r)
2075 struct lsa_info *info = NULL;
2079 /* find the connection policy handle. */
2080 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
2081 return NT_STATUS_INVALID_HANDLE;
2083 /* check to see if the pipe_user is a Domain Admin since
2084 account_pol.tdb was already opened as root, this is all we have */
2086 if ( p->pipe_user.ut.uid != sec_initial_uid()
2087 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
2089 return NT_STATUS_ACCESS_DENIED;
2092 /* according to an NT4 PDC, you can add privileges to SIDs even without
2093 call_lsa_create_account() first. And you can use any arbitrary SID. */
2095 sid_copy( &sid, r->in.sid );
2097 for ( i=0; i < r->in.rights->count; i++ ) {
2099 const char *privname = r->in.rights->names[i].string;
2101 /* only try to add non-null strings */
2106 if ( !grant_privilege_by_name( &sid, privname ) ) {
2107 DEBUG(2,("_lsa_AddAccountRights: Failed to add privilege [%s]\n",
2109 return NT_STATUS_NO_SUCH_PRIVILEGE;
2113 return NT_STATUS_OK;
2116 /***************************************************************************
2117 _lsa_RemoveAccountRights
2118 ***************************************************************************/
2120 NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p,
2121 struct lsa_RemoveAccountRights *r)
2123 struct lsa_info *info = NULL;
2126 const char *privname = NULL;
2128 /* find the connection policy handle. */
2129 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
2130 return NT_STATUS_INVALID_HANDLE;
2132 /* check to see if the pipe_user is a Domain Admin since
2133 account_pol.tdb was already opened as root, this is all we have */
2135 if ( p->pipe_user.ut.uid != sec_initial_uid()
2136 && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) )
2138 return NT_STATUS_ACCESS_DENIED;
2141 sid_copy( &sid, r->in.sid );
2143 if ( r->in.remove_all ) {
2144 if ( !revoke_all_privileges( &sid ) )
2145 return NT_STATUS_ACCESS_DENIED;
2147 return NT_STATUS_OK;
2150 for ( i=0; i < r->in.rights->count; i++ ) {
2152 privname = r->in.rights->names[i].string;
2154 /* only try to add non-null strings */
2159 if ( !revoke_privilege_by_name( &sid, privname ) ) {
2160 DEBUG(2,("_lsa_RemoveAccountRights: Failed to revoke privilege [%s]\n",
2162 return NT_STATUS_NO_SUCH_PRIVILEGE;
2166 return NT_STATUS_OK;
2169 /*******************************************************************
2170 ********************************************************************/
2172 static NTSTATUS init_lsa_right_set(TALLOC_CTX *mem_ctx,
2173 struct lsa_RightSet *r,
2174 PRIVILEGE_SET *privileges)
2177 const char *privname;
2178 const char **privname_array = NULL;
2181 for (i=0; i<privileges->count; i++) {
2183 privname = luid_to_privilege_name(&privileges->set[i].luid);
2185 if (!add_string_to_array(mem_ctx, privname,
2186 &privname_array, &num_priv)) {
2187 return NT_STATUS_NO_MEMORY;
2194 r->names = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_StringLarge,
2197 return NT_STATUS_NO_MEMORY;
2200 for (i=0; i<num_priv; i++) {
2201 init_lsa_StringLarge(&r->names[i], privname_array[i]);
2204 r->count = num_priv;
2207 return NT_STATUS_OK;
2210 /***************************************************************************
2211 _lsa_EnumAccountRights
2212 ***************************************************************************/
2214 NTSTATUS _lsa_EnumAccountRights(pipes_struct *p,
2215 struct lsa_EnumAccountRights *r)
2218 struct lsa_info *info = NULL;
2220 PRIVILEGE_SET privileges;
2223 /* find the connection policy handle. */
2225 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
2226 return NT_STATUS_INVALID_HANDLE;
2228 /* according to an NT4 PDC, you can add privileges to SIDs even without
2229 call_lsa_create_account() first. And you can use any arbitrary SID. */
2231 sid_copy( &sid, r->in.sid );
2233 if ( !get_privileges_for_sids( &mask, &sid, 1 ) )
2234 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
2236 privilege_set_init( &privileges );
2238 if ( se_priv_to_privilege_set( &privileges, &mask ) ) {
2240 DEBUG(10,("_lsa_EnumAccountRights: %s has %d privileges\n",
2241 sid_string_dbg(&sid), privileges.count));
2243 status = init_lsa_right_set(p->mem_ctx, r->out.rights, &privileges);
2245 status = NT_STATUS_NO_SUCH_PRIVILEGE;
2248 privilege_set_free( &privileges );
2253 /***************************************************************************
2254 _lsa_LookupPrivValue
2255 ***************************************************************************/
2257 NTSTATUS _lsa_LookupPrivValue(pipes_struct *p,
2258 struct lsa_LookupPrivValue *r)
2260 struct lsa_info *info = NULL;
2261 const char *name = NULL;
2262 LUID_ATTR priv_luid;
2265 /* find the connection policy handle. */
2267 if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info))
2268 return NT_STATUS_INVALID_HANDLE;
2270 name = r->in.name->string;
2272 DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name));
2274 if ( !se_priv_from_name( name, &mask ) )
2275 return NT_STATUS_NO_SUCH_PRIVILEGE;
2277 priv_luid = get_privilege_luid( &mask );
2279 r->out.luid->low = priv_luid.luid.low;
2280 r->out.luid->high = priv_luid.luid.high;
2282 return NT_STATUS_OK;
2286 * From here on the server routines are just dummy ones to make smbd link with
2287 * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are
2288 * pulling the server stubs across one by one.
2291 NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r)
2293 p->rng_fault_state = True;
2294 return NT_STATUS_NOT_IMPLEMENTED;
2297 NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r)
2299 p->rng_fault_state = True;
2300 return NT_STATUS_NOT_IMPLEMENTED;
2303 NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r)
2305 p->rng_fault_state = True;
2306 return NT_STATUS_NOT_IMPLEMENTED;
2309 NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p, struct lsa_SetInfoPolicy *r)
2311 p->rng_fault_state = True;
2312 return NT_STATUS_NOT_IMPLEMENTED;
2315 NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r)
2317 p->rng_fault_state = True;
2318 return NT_STATUS_NOT_IMPLEMENTED;
2321 NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r)
2323 p->rng_fault_state = True;
2324 return NT_STATUS_NOT_IMPLEMENTED;
2327 NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r)
2329 p->rng_fault_state = True;
2330 return NT_STATUS_NOT_IMPLEMENTED;
2333 NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccount *r)
2335 p->rng_fault_state = True;
2336 return NT_STATUS_NOT_IMPLEMENTED;
2339 NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r)
2341 p->rng_fault_state = True;
2342 return NT_STATUS_NOT_IMPLEMENTED;
2345 NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p, struct lsa_SetInformationTrustedDomain *r)
2347 p->rng_fault_state = True;
2348 return NT_STATUS_NOT_IMPLEMENTED;
2351 NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r)
2353 p->rng_fault_state = True;
2354 return NT_STATUS_NOT_IMPLEMENTED;
2357 NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r)
2359 p->rng_fault_state = True;
2360 return NT_STATUS_NOT_IMPLEMENTED;
2363 NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r)
2365 p->rng_fault_state = True;
2366 return NT_STATUS_NOT_IMPLEMENTED;
2369 NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r)
2371 p->rng_fault_state = True;
2372 return NT_STATUS_NOT_IMPLEMENTED;
2375 NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p, struct lsa_SetTrustedDomainInfo *r)
2377 p->rng_fault_state = True;
2378 return NT_STATUS_NOT_IMPLEMENTED;
2381 NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct lsa_DeleteTrustedDomain *r)
2383 p->rng_fault_state = True;
2384 return NT_STATUS_NOT_IMPLEMENTED;
2387 NTSTATUS _lsa_StorePrivateData(pipes_struct *p, struct lsa_StorePrivateData *r)
2389 p->rng_fault_state = True;
2390 return NT_STATUS_NOT_IMPLEMENTED;
2393 NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateData *r)
2395 p->rng_fault_state = True;
2396 return NT_STATUS_NOT_IMPLEMENTED;
2399 NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct lsa_QueryInfoPolicy2 *r)
2401 p->rng_fault_state = True;
2402 return NT_STATUS_NOT_IMPLEMENTED;
2405 NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p, struct lsa_SetInfoPolicy2 *r)
2407 p->rng_fault_state = True;
2408 return NT_STATUS_NOT_IMPLEMENTED;
2411 NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct lsa_QueryTrustedDomainInfoByName *r)
2413 p->rng_fault_state = True;
2414 return NT_STATUS_NOT_IMPLEMENTED;
2417 NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct lsa_SetTrustedDomainInfoByName *r)
2419 p->rng_fault_state = True;
2420 return NT_STATUS_NOT_IMPLEMENTED;
2423 NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct lsa_EnumTrustedDomainsEx *r)
2425 p->rng_fault_state = True;
2426 return NT_STATUS_NOT_IMPLEMENTED;
2429 NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p, struct lsa_CreateTrustedDomainEx *r)
2431 p->rng_fault_state = True;
2432 return NT_STATUS_NOT_IMPLEMENTED;
2435 NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct lsa_CloseTrustedDomainEx *r)
2437 p->rng_fault_state = True;
2438 return NT_STATUS_NOT_IMPLEMENTED;
2441 NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct lsa_QueryDomainInformationPolicy *r)
2443 p->rng_fault_state = True;
2444 return NT_STATUS_NOT_IMPLEMENTED;
2447 NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct lsa_SetDomainInformationPolicy *r)
2449 p->rng_fault_state = True;
2450 return NT_STATUS_NOT_IMPLEMENTED;
2453 NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct lsa_OpenTrustedDomainByName *r)
2455 p->rng_fault_state = True;
2456 return NT_STATUS_NOT_IMPLEMENTED;
2459 NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r)
2461 p->rng_fault_state = True;
2462 return NT_STATUS_NOT_IMPLEMENTED;
2465 NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r)
2467 p->rng_fault_state = True;
2468 return NT_STATUS_NOT_IMPLEMENTED;
2471 NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r)
2473 p->rng_fault_state = True;
2474 return NT_STATUS_NOT_IMPLEMENTED;
2477 NTSTATUS _lsa_CREDRWRITE(pipes_struct *p, struct lsa_CREDRWRITE *r)
2479 p->rng_fault_state = True;
2480 return NT_STATUS_NOT_IMPLEMENTED;
2483 NTSTATUS _lsa_CREDRREAD(pipes_struct *p, struct lsa_CREDRREAD *r)
2485 p->rng_fault_state = True;
2486 return NT_STATUS_NOT_IMPLEMENTED;
2489 NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p, struct lsa_CREDRENUMERATE *r)
2491 p->rng_fault_state = True;
2492 return NT_STATUS_NOT_IMPLEMENTED;
2495 NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRWRITEDOMAINCREDENTIALS *r)
2497 p->rng_fault_state = True;
2498 return NT_STATUS_NOT_IMPLEMENTED;
2501 NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRREADDOMAINCREDENTIALS *r)
2503 p->rng_fault_state = True;
2504 return NT_STATUS_NOT_IMPLEMENTED;
2507 NTSTATUS _lsa_CREDRDELETE(pipes_struct *p, struct lsa_CREDRDELETE *r)
2509 p->rng_fault_state = True;
2510 return NT_STATUS_NOT_IMPLEMENTED;
2513 NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p, struct lsa_CREDRGETTARGETINFO *r)
2515 p->rng_fault_state = True;
2516 return NT_STATUS_NOT_IMPLEMENTED;
2519 NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED *r)
2521 p->rng_fault_state = True;
2522 return NT_STATUS_NOT_IMPLEMENTED;
2525 NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r)
2527 p->rng_fault_state = True;
2528 return NT_STATUS_NOT_IMPLEMENTED;
2531 NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r)
2533 p->rng_fault_state = True;
2534 return NT_STATUS_NOT_IMPLEMENTED;
2537 NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARREGISTERAUDITEVENT *r)
2539 p->rng_fault_state = True;
2540 return NT_STATUS_NOT_IMPLEMENTED;
2543 NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p, struct lsa_LSARGENAUDITEVENT *r)
2545 p->rng_fault_state = True;
2546 return NT_STATUS_NOT_IMPLEMENTED;
2549 NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARUNREGISTERAUDITEVENT *r)
2551 p->rng_fault_state = True;
2552 return NT_STATUS_NOT_IMPLEMENTED;
2555 NTSTATUS _lsa_lsaRQueryForestTrustInformation(pipes_struct *p, struct lsa_lsaRQueryForestTrustInformation *r)
2557 p->rng_fault_state = True;
2558 return NT_STATUS_NOT_IMPLEMENTED;
2561 NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARSETFORESTTRUSTINFORMATION *r)
2563 p->rng_fault_state = True;
2564 return NT_STATUS_NOT_IMPLEMENTED;
2567 NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r)
2569 p->rng_fault_state = True;
2570 return NT_STATUS_NOT_IMPLEMENTED;
2573 NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r)
2575 p->rng_fault_state = True;
2576 return NT_STATUS_NOT_IMPLEMENTED;
2579 NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r)
2581 p->rng_fault_state = True;
2582 return NT_STATUS_NOT_IMPLEMENTED;
2585 NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r)
2587 p->rng_fault_state = True;
2588 return NT_STATUS_NOT_IMPLEMENTED;
2591 NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r)
2593 p->rng_fault_state = True;
2594 return NT_STATUS_NOT_IMPLEMENTED;
2597 NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r)
2599 p->rng_fault_state = True;
2600 return NT_STATUS_NOT_IMPLEMENTED;
2603 NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p, struct lsa_LSARADTREPORTSECURITYEVENT *r)
2605 p->rng_fault_state = True;
2606 return NT_STATUS_NOT_IMPLEMENTED;