2 * Unix SMB/CIFS implementation.
4 * Winbind rpc backend functions
6 * Copyright (c) 2000-2003 Tim Potter
7 * Copyright (c) 2001 Andrew Tridgell
8 * Copyright (c) 2005 Volker Lendecke
9 * Copyright (c) 2008 Guenther Deschner (pidl conversion)
10 * Copyright (c) 2010 Andreas Schneider <asn@samba.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "winbindd_rpc.h"
29 #include "rpc_client/rpc_client.h"
30 #include "../librpc/gen_ndr/ndr_samr_c.h"
31 #include "rpc_client/cli_samr.h"
32 #include "../librpc/gen_ndr/ndr_lsa_c.h"
33 #include "rpc_client/cli_lsarpc.h"
34 #include "rpc_server/rpc_ncacn_np.h"
35 #include "../libcli/security/security.h"
36 #include "passdb/machine_sid.h"
40 #define DBGC_CLASS DBGC_WINBIND
42 static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx,
43 struct rpc_pipe_client **samr_pipe)
45 struct rpc_pipe_client *cli = NULL;
46 struct auth_serversupplied_info *session_info = NULL;
49 if (session_info == NULL) {
50 status = make_session_info_system(mem_ctx, &session_info);
51 if (!NT_STATUS_IS_OK(status)) {
52 DEBUG(0, ("open_samr_pipe: Could not create auth_serversupplied_info: %s\n",
58 /* create a samr connection */
59 status = rpc_pipe_open_interface(mem_ctx,
60 &ndr_table_samr.syntax_id,
63 winbind_messaging_context(),
65 if (!NT_STATUS_IS_OK(status)) {
66 DEBUG(0, ("open_samr_pipe: Could not connect to samr_pipe: %s\n",
78 NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
79 struct winbindd_domain *domain,
80 struct rpc_pipe_client **samr_pipe,
81 struct policy_handle *samr_domain_hnd)
83 NTSTATUS status, result;
84 struct policy_handle samr_connect_hnd;
85 struct dcerpc_binding_handle *b;
87 status = open_internal_samr_pipe(mem_ctx, samr_pipe);
88 if (!NT_STATUS_IS_OK(status)) {
92 b = (*samr_pipe)->binding_handle;
94 status = dcerpc_samr_Connect2(b, mem_ctx,
95 (*samr_pipe)->desthost,
96 SEC_FLAG_MAXIMUM_ALLOWED,
99 if (!NT_STATUS_IS_OK(status)) {
102 if (!NT_STATUS_IS_OK(result)) {
106 status = dcerpc_samr_OpenDomain(b, mem_ctx,
108 SEC_FLAG_MAXIMUM_ALLOWED,
112 if (!NT_STATUS_IS_OK(status)) {
119 static NTSTATUS open_internal_lsa_pipe(TALLOC_CTX *mem_ctx,
120 struct rpc_pipe_client **lsa_pipe)
122 struct rpc_pipe_client *cli = NULL;
123 struct auth_serversupplied_info *session_info = NULL;
126 if (session_info == NULL) {
127 status = make_session_info_system(mem_ctx, &session_info);
128 if (!NT_STATUS_IS_OK(status)) {
129 DEBUG(0, ("open_lsa_pipe: Could not create auth_serversupplied_info: %s\n",
135 /* create a lsa connection */
136 status = rpc_pipe_open_interface(mem_ctx,
137 &ndr_table_lsarpc.syntax_id,
140 winbind_messaging_context(),
142 if (!NT_STATUS_IS_OK(status)) {
143 DEBUG(0, ("open_lsa_pipe: Could not connect to lsa_pipe: %s\n",
155 static NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
156 struct rpc_pipe_client **lsa_pipe,
157 struct policy_handle *lsa_hnd)
161 status = open_internal_lsa_pipe(mem_ctx, lsa_pipe);
162 if (!NT_STATUS_IS_OK(status)) {
166 status = rpccli_lsa_open_policy((*lsa_pipe),
169 SEC_FLAG_MAXIMUM_ALLOWED,
175 /*********************************************************************
176 SAM specific functions.
177 *********************************************************************/
179 /* List all domain groups */
180 static NTSTATUS sam_enum_dom_groups(struct winbindd_domain *domain,
183 struct wb_acct_info **pinfo)
185 struct rpc_pipe_client *samr_pipe;
186 struct policy_handle dom_pol;
187 struct wb_acct_info *info = NULL;
188 uint32_t num_info = 0;
190 NTSTATUS status, result;
191 struct dcerpc_binding_handle *b = NULL;
193 DEBUG(3,("sam_enum_dom_groups\n"));
195 ZERO_STRUCT(dom_pol);
201 tmp_ctx = talloc_stackframe();
202 if (tmp_ctx == NULL) {
203 return NT_STATUS_NO_MEMORY;
206 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
207 if (!NT_STATUS_IS_OK(status)) {
211 b = samr_pipe->binding_handle;
213 status = rpc_enum_dom_groups(tmp_ctx,
218 if (!NT_STATUS_IS_OK(status)) {
223 *pnum_info = num_info;
227 *pinfo = talloc_move(mem_ctx, &info);
231 if (b && is_valid_policy_hnd(&dom_pol)) {
232 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
234 TALLOC_FREE(tmp_ctx);
238 /* Query display info for a domain */
239 static NTSTATUS sam_query_user_list(struct winbindd_domain *domain,
242 struct wbint_userinfo **pinfo)
244 struct rpc_pipe_client *samr_pipe = NULL;
245 struct policy_handle dom_pol;
246 struct wbint_userinfo *info = NULL;
247 uint32_t num_info = 0;
249 NTSTATUS status, result;
250 struct dcerpc_binding_handle *b = NULL;
252 DEBUG(3,("samr_query_user_list\n"));
254 ZERO_STRUCT(dom_pol);
260 tmp_ctx = talloc_stackframe();
261 if (tmp_ctx == NULL) {
262 return NT_STATUS_NO_MEMORY;
265 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
266 if (!NT_STATUS_IS_OK(status)) {
270 b = samr_pipe->binding_handle;
272 status = rpc_query_user_list(tmp_ctx,
278 if (!NT_STATUS_IS_OK(status)) {
283 *pnum_info = num_info;
287 *pinfo = talloc_move(mem_ctx, &info);
291 if (b && is_valid_policy_hnd(&dom_pol)) {
292 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
295 TALLOC_FREE(tmp_ctx);
299 /* Lookup user information from a rid or username. */
300 static NTSTATUS sam_query_user(struct winbindd_domain *domain,
302 const struct dom_sid *user_sid,
303 struct wbint_userinfo *user_info)
305 struct rpc_pipe_client *samr_pipe;
306 struct policy_handle dom_pol;
308 NTSTATUS status, result;
309 struct dcerpc_binding_handle *b = NULL;
311 DEBUG(3,("sam_query_user\n"));
313 ZERO_STRUCT(dom_pol);
316 if (!sid_check_is_in_our_domain(user_sid)) {
317 return NT_STATUS_NO_SUCH_USER;
321 user_info->homedir = NULL;
322 user_info->shell = NULL;
323 user_info->primary_gid = (gid_t) -1;
326 tmp_ctx = talloc_stackframe();
327 if (tmp_ctx == NULL) {
328 return NT_STATUS_NO_MEMORY;
331 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
332 if (!NT_STATUS_IS_OK(status)) {
336 b = samr_pipe->binding_handle;
338 status = rpc_query_user(tmp_ctx,
346 if (b && is_valid_policy_hnd(&dom_pol)) {
347 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
350 TALLOC_FREE(tmp_ctx);
354 /* get a list of trusted domains - builtin domain */
355 static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
357 struct netr_DomainTrustList *ptrust_list)
359 struct rpc_pipe_client *lsa_pipe;
360 struct policy_handle lsa_policy;
361 struct netr_DomainTrust *trusts = NULL;
362 uint32_t num_trusts = 0;
364 NTSTATUS status, result;
365 struct dcerpc_binding_handle *b = NULL;
367 DEBUG(3,("samr: trusted domains\n"));
369 ZERO_STRUCT(lsa_policy);
372 ZERO_STRUCTP(ptrust_list);
375 tmp_ctx = talloc_stackframe();
376 if (tmp_ctx == NULL) {
377 return NT_STATUS_NO_MEMORY;
380 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
381 if (!NT_STATUS_IS_OK(status)) {
385 b = lsa_pipe->binding_handle;
387 status = rpc_trusted_domains(tmp_ctx,
392 if (!NT_STATUS_IS_OK(status)) {
397 ptrust_list->count = num_trusts;
398 ptrust_list->array = talloc_move(mem_ctx, &trusts);
402 if (b && is_valid_policy_hnd(&lsa_policy)) {
403 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
406 TALLOC_FREE(tmp_ctx);
410 /* Lookup group membership given a rid. */
411 static NTSTATUS sam_lookup_groupmem(struct winbindd_domain *domain,
413 const struct dom_sid *group_sid,
414 enum lsa_SidType type,
415 uint32_t *pnum_names,
416 struct dom_sid **psid_mem,
418 uint32_t **pname_types)
420 struct rpc_pipe_client *samr_pipe;
421 struct policy_handle dom_pol;
423 uint32_t num_names = 0;
424 struct dom_sid *sid_mem = NULL;
426 uint32_t *name_types = NULL;
429 NTSTATUS status, result;
430 struct dcerpc_binding_handle *b = NULL;
432 DEBUG(3,("sam_lookup_groupmem\n"));
434 ZERO_STRUCT(dom_pol);
437 if (sid_check_is_in_builtin(group_sid) && (type != SID_NAME_ALIAS)) {
438 /* There's no groups, only aliases in BUILTIN */
439 return NT_STATUS_NO_SUCH_GROUP;
446 tmp_ctx = talloc_stackframe();
447 if (tmp_ctx == NULL) {
448 return NT_STATUS_NO_MEMORY;
451 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
452 if (!NT_STATUS_IS_OK(status)) {
456 b = samr_pipe->binding_handle;
458 status = rpc_lookup_groupmem(tmp_ctx,
471 *pnum_names = num_names;
475 *pnames = talloc_move(mem_ctx, &names);
479 *pname_types = talloc_move(mem_ctx, &name_types);
483 *psid_mem = talloc_move(mem_ctx, &sid_mem);
487 if (b && is_valid_policy_hnd(&dom_pol)) {
488 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
491 TALLOC_FREE(tmp_ctx);
495 /*********************************************************************
496 BUILTIN specific functions.
497 *********************************************************************/
499 /* List all domain groups */
500 static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain,
503 struct wb_acct_info **info)
505 /* BUILTIN doesn't have domain groups */
511 /* Query display info for a domain */
512 static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain,
515 struct wbint_userinfo **info)
517 /* We don't have users */
523 /* Lookup user information from a rid or username. */
524 static NTSTATUS builtin_query_user(struct winbindd_domain *domain,
526 const struct dom_sid *user_sid,
527 struct wbint_userinfo *user_info)
529 return NT_STATUS_NO_SUCH_USER;
532 /* get a list of trusted domains - builtin domain */
533 static NTSTATUS builtin_trusted_domains(struct winbindd_domain *domain,
535 struct netr_DomainTrustList *trusts)
537 ZERO_STRUCTP(trusts);
541 /*********************************************************************
543 *********************************************************************/
545 /* List all local groups (aliases) */
546 static NTSTATUS sam_enum_local_groups(struct winbindd_domain *domain,
549 struct wb_acct_info **pinfo)
551 struct rpc_pipe_client *samr_pipe;
552 struct policy_handle dom_pol;
553 struct wb_acct_info *info = NULL;
554 uint32_t num_info = 0;
556 NTSTATUS status, result;
557 struct dcerpc_binding_handle *b = NULL;
559 DEBUG(3,("samr: enum local groups\n"));
561 ZERO_STRUCT(dom_pol);
567 tmp_ctx = talloc_stackframe();
568 if (tmp_ctx == NULL) {
569 return NT_STATUS_NO_MEMORY;
572 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
573 if (!NT_STATUS_IS_OK(status)) {
577 b = samr_pipe->binding_handle;
579 status = rpc_enum_local_groups(mem_ctx,
584 if (!NT_STATUS_IS_OK(status)) {
589 *pnum_info = num_info;
593 *pinfo = talloc_move(mem_ctx, &info);
597 if (b && is_valid_policy_hnd(&dom_pol)) {
598 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
601 TALLOC_FREE(tmp_ctx);
605 /* convert a single name to a sid in a domain */
606 static NTSTATUS sam_name_to_sid(struct winbindd_domain *domain,
608 const char *domain_name,
611 struct dom_sid *psid,
612 enum lsa_SidType *ptype)
614 struct rpc_pipe_client *lsa_pipe;
615 struct policy_handle lsa_policy;
617 enum lsa_SidType type;
619 NTSTATUS status, result;
620 struct dcerpc_binding_handle *b = NULL;
622 DEBUG(3,("sam_name_to_sid\n"));
624 ZERO_STRUCT(lsa_policy);
626 tmp_ctx = talloc_stackframe();
627 if (tmp_ctx == NULL) {
628 return NT_STATUS_NO_MEMORY;
631 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
632 if (!NT_STATUS_IS_OK(status)) {
636 b = lsa_pipe->binding_handle;
638 status = rpc_name_to_sid(tmp_ctx,
646 if (!NT_STATUS_IS_OK(status)) {
651 sid_copy(psid, &sid);
658 if (b && is_valid_policy_hnd(&lsa_policy)) {
659 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
662 TALLOC_FREE(tmp_ctx);
666 /* convert a domain SID to a user or group name */
667 static NTSTATUS sam_sid_to_name(struct winbindd_domain *domain,
669 const struct dom_sid *sid,
672 enum lsa_SidType *ptype)
674 struct rpc_pipe_client *lsa_pipe;
675 struct policy_handle lsa_policy;
676 char *domain_name = NULL;
678 enum lsa_SidType type;
680 NTSTATUS status, result;
681 struct dcerpc_binding_handle *b = NULL;
683 DEBUG(3,("sam_sid_to_name\n"));
685 ZERO_STRUCT(lsa_policy);
688 if (!sid_check_is_in_builtin(sid) &&
689 !sid_check_is_in_our_domain(sid) &&
690 !sid_check_is_in_unix_users(sid) &&
691 !sid_check_is_unix_users(sid) &&
692 !sid_check_is_in_unix_groups(sid) &&
693 !sid_check_is_unix_groups(sid) &&
694 !sid_check_is_in_wellknown_domain(sid)) {
695 DEBUG(0, ("sam_sid_to_name: possible deadlock - trying to "
696 "lookup SID %s\n", sid_string_dbg(sid)));
697 return NT_STATUS_NONE_MAPPED;
700 tmp_ctx = talloc_stackframe();
701 if (tmp_ctx == NULL) {
702 return NT_STATUS_NO_MEMORY;
705 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
706 if (!NT_STATUS_IS_OK(status)) {
710 b = lsa_pipe->binding_handle;
712 status = rpc_sid_to_name(tmp_ctx,
726 *pname = talloc_move(mem_ctx, &name);
730 *pdomain_name = talloc_move(mem_ctx, &domain_name);
734 if (b && is_valid_policy_hnd(&lsa_policy)) {
735 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
738 TALLOC_FREE(tmp_ctx);
742 static NTSTATUS sam_rids_to_names(struct winbindd_domain *domain,
744 const struct dom_sid *domain_sid,
749 enum lsa_SidType **ptypes)
751 struct rpc_pipe_client *lsa_pipe;
752 struct policy_handle lsa_policy;
753 enum lsa_SidType *types = NULL;
754 char *domain_name = NULL;
757 NTSTATUS status, result;
758 struct dcerpc_binding_handle *b = NULL;
760 DEBUG(3,("sam_rids_to_names for %s\n", domain->name));
762 ZERO_STRUCT(lsa_policy);
765 if (!sid_check_is_builtin(domain_sid) &&
766 !sid_check_is_domain(domain_sid) &&
767 !sid_check_is_unix_users(domain_sid) &&
768 !sid_check_is_unix_groups(domain_sid) &&
769 !sid_check_is_in_wellknown_domain(domain_sid)) {
770 DEBUG(0, ("sam_rids_to_names: possible deadlock - trying to "
771 "lookup SID %s\n", sid_string_dbg(domain_sid)));
772 return NT_STATUS_NONE_MAPPED;
775 tmp_ctx = talloc_stackframe();
776 if (tmp_ctx == NULL) {
777 return NT_STATUS_NO_MEMORY;
780 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
781 if (!NT_STATUS_IS_OK(status)) {
785 b = lsa_pipe->binding_handle;
787 status = rpc_rids_to_names(tmp_ctx,
797 if (!NT_STATUS_IS_OK(status)) {
802 *pdomain_name = talloc_move(mem_ctx, &domain_name);
806 *ptypes = talloc_move(mem_ctx, &types);
810 *pnames = talloc_move(mem_ctx, &names);
814 if (b && is_valid_policy_hnd(&lsa_policy)) {
815 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
818 TALLOC_FREE(tmp_ctx);
822 static NTSTATUS sam_lockout_policy(struct winbindd_domain *domain,
824 struct samr_DomInfo12 *lockout_policy)
826 struct rpc_pipe_client *samr_pipe;
827 struct policy_handle dom_pol;
828 union samr_DomainInfo *info = NULL;
830 NTSTATUS status, result;
831 struct dcerpc_binding_handle *b = NULL;
833 DEBUG(3,("sam_lockout_policy\n"));
835 ZERO_STRUCT(dom_pol);
837 tmp_ctx = talloc_stackframe();
838 if (tmp_ctx == NULL) {
839 return NT_STATUS_NO_MEMORY;
842 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
843 if (!NT_STATUS_IS_OK(status)) {
847 b = samr_pipe->binding_handle;
849 status = dcerpc_samr_QueryDomainInfo(b,
855 if (!NT_STATUS_IS_OK(status)) {
858 if (!NT_STATUS_IS_OK(result)) {
863 *lockout_policy = info->info12;
866 if (b && is_valid_policy_hnd(&dom_pol)) {
867 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
870 TALLOC_FREE(tmp_ctx);
874 static NTSTATUS sam_password_policy(struct winbindd_domain *domain,
876 struct samr_DomInfo1 *passwd_policy)
878 struct rpc_pipe_client *samr_pipe;
879 struct policy_handle dom_pol;
880 union samr_DomainInfo *info = NULL;
882 NTSTATUS status, result;
883 struct dcerpc_binding_handle *b = NULL;
885 DEBUG(3,("sam_password_policy\n"));
887 ZERO_STRUCT(dom_pol);
889 tmp_ctx = talloc_stackframe();
890 if (tmp_ctx == NULL) {
891 return NT_STATUS_NO_MEMORY;
894 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
895 if (!NT_STATUS_IS_OK(status)) {
899 b = samr_pipe->binding_handle;
901 status = dcerpc_samr_QueryDomainInfo(b,
907 if (!NT_STATUS_IS_OK(status)) {
910 if (!NT_STATUS_IS_OK(result)) {
915 *passwd_policy = info->info1;
918 if (b && is_valid_policy_hnd(&dom_pol)) {
919 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
922 TALLOC_FREE(tmp_ctx);
926 /* Lookup groups a user is a member of. */
927 static NTSTATUS sam_lookup_usergroups(struct winbindd_domain *domain,
929 const struct dom_sid *user_sid,
930 uint32_t *pnum_groups,
931 struct dom_sid **puser_grpsids)
933 struct rpc_pipe_client *samr_pipe;
934 struct policy_handle dom_pol;
935 struct dom_sid *user_grpsids = NULL;
936 uint32_t num_groups = 0;
938 NTSTATUS status, result;
939 struct dcerpc_binding_handle *b = NULL;
941 DEBUG(3,("sam_lookup_usergroups\n"));
943 ZERO_STRUCT(dom_pol);
949 tmp_ctx = talloc_stackframe();
950 if (tmp_ctx == NULL) {
951 return NT_STATUS_NO_MEMORY;
954 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
955 if (!NT_STATUS_IS_OK(status)) {
959 b = samr_pipe->binding_handle;
961 status = rpc_lookup_usergroups(tmp_ctx,
968 if (!NT_STATUS_IS_OK(status)) {
973 *pnum_groups = num_groups;
977 *puser_grpsids = talloc_move(mem_ctx, &user_grpsids);
981 if (b && is_valid_policy_hnd(&dom_pol)) {
982 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
985 TALLOC_FREE(tmp_ctx);
989 static NTSTATUS sam_lookup_useraliases(struct winbindd_domain *domain,
992 const struct dom_sid *sids,
993 uint32_t *pnum_aliases,
994 uint32_t **palias_rids)
996 struct rpc_pipe_client *samr_pipe;
997 struct policy_handle dom_pol;
998 uint32_t num_aliases = 0;
999 uint32_t *alias_rids = NULL;
1000 TALLOC_CTX *tmp_ctx;
1001 NTSTATUS status, result;
1002 struct dcerpc_binding_handle *b = NULL;
1004 DEBUG(3,("sam_lookup_useraliases\n"));
1006 ZERO_STRUCT(dom_pol);
1012 tmp_ctx = talloc_stackframe();
1013 if (tmp_ctx == NULL) {
1014 return NT_STATUS_NO_MEMORY;
1017 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
1018 if (!NT_STATUS_IS_OK(status)) {
1022 b = samr_pipe->binding_handle;
1024 status = rpc_lookup_useraliases(tmp_ctx,
1031 if (!NT_STATUS_IS_OK(status)) {
1036 *pnum_aliases = num_aliases;
1040 *palias_rids = talloc_move(mem_ctx, &alias_rids);
1044 if (b && is_valid_policy_hnd(&dom_pol)) {
1045 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
1048 TALLOC_FREE(tmp_ctx);
1052 /* find the sequence number for a domain */
1053 static NTSTATUS sam_sequence_number(struct winbindd_domain *domain,
1056 struct rpc_pipe_client *samr_pipe;
1057 struct policy_handle dom_pol;
1059 TALLOC_CTX *tmp_ctx;
1060 NTSTATUS status, result;
1061 struct dcerpc_binding_handle *b = NULL;
1063 DEBUG(3,("samr: sequence number\n"));
1065 ZERO_STRUCT(dom_pol);
1068 *pseq = DOM_SEQUENCE_NONE;
1071 tmp_ctx = talloc_stackframe();
1072 if (tmp_ctx == NULL) {
1073 return NT_STATUS_NO_MEMORY;
1076 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
1077 if (!NT_STATUS_IS_OK(status)) {
1081 b = samr_pipe->binding_handle;
1083 status = rpc_sequence_number(tmp_ctx,
1088 if (!NT_STATUS_IS_OK(status)) {
1096 if (b && is_valid_policy_hnd(&dom_pol)) {
1097 dcerpc_samr_Close(b, tmp_ctx, &dom_pol, &result);
1100 TALLOC_FREE(tmp_ctx);
1104 /* the rpc backend methods are exposed via this structure */
1105 struct winbindd_methods builtin_passdb_methods = {
1106 .consistent = false,
1108 .query_user_list = builtin_query_user_list,
1109 .enum_dom_groups = builtin_enum_dom_groups,
1110 .enum_local_groups = sam_enum_local_groups,
1111 .name_to_sid = sam_name_to_sid,
1112 .sid_to_name = sam_sid_to_name,
1113 .rids_to_names = sam_rids_to_names,
1114 .query_user = builtin_query_user,
1115 .lookup_usergroups = sam_lookup_usergroups,
1116 .lookup_useraliases = sam_lookup_useraliases,
1117 .lookup_groupmem = sam_lookup_groupmem,
1118 .sequence_number = sam_sequence_number,
1119 .lockout_policy = sam_lockout_policy,
1120 .password_policy = sam_password_policy,
1121 .trusted_domains = builtin_trusted_domains
1124 /* the rpc backend methods are exposed via this structure */
1125 struct winbindd_methods sam_passdb_methods = {
1126 .consistent = false,
1128 .query_user_list = sam_query_user_list,
1129 .enum_dom_groups = sam_enum_dom_groups,
1130 .enum_local_groups = sam_enum_local_groups,
1131 .name_to_sid = sam_name_to_sid,
1132 .sid_to_name = sam_sid_to_name,
1133 .rids_to_names = sam_rids_to_names,
1134 .query_user = sam_query_user,
1135 .lookup_usergroups = sam_lookup_usergroups,
1136 .lookup_useraliases = sam_lookup_useraliases,
1137 .lookup_groupmem = sam_lookup_groupmem,
1138 .sequence_number = sam_sequence_number,
1139 .lockout_policy = sam_lockout_policy,
1140 .password_policy = sam_password_policy,
1141 .trusted_domains = sam_trusted_domains