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_session_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_session_info: %s\n",
58 /* create a samr connection */
59 status = rpc_pipe_open_internal(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_session_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_session_info: %s\n",
135 /* create a lsa connection */
136 status = rpc_pipe_open_internal(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;
320 user_info->homedir = NULL;
321 user_info->shell = NULL;
322 user_info->primary_gid = (gid_t) -1;
324 tmp_ctx = talloc_stackframe();
325 if (tmp_ctx == NULL) {
326 return NT_STATUS_NO_MEMORY;
329 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
330 if (!NT_STATUS_IS_OK(status)) {
334 b = samr_pipe->binding_handle;
336 status = rpc_query_user(tmp_ctx,
344 if (b && is_valid_policy_hnd(&dom_pol)) {
345 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
348 TALLOC_FREE(tmp_ctx);
352 /* get a list of trusted domains - builtin domain */
353 static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
355 struct netr_DomainTrustList *ptrust_list)
357 struct rpc_pipe_client *lsa_pipe;
358 struct policy_handle lsa_policy;
359 struct netr_DomainTrust *trusts = NULL;
360 uint32_t num_trusts = 0;
362 NTSTATUS status, result;
363 struct dcerpc_binding_handle *b = NULL;
365 DEBUG(3,("samr: trusted domains\n"));
367 ZERO_STRUCT(lsa_policy);
370 ZERO_STRUCTP(ptrust_list);
373 tmp_ctx = talloc_stackframe();
374 if (tmp_ctx == NULL) {
375 return NT_STATUS_NO_MEMORY;
378 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
379 if (!NT_STATUS_IS_OK(status)) {
383 b = lsa_pipe->binding_handle;
385 status = rpc_trusted_domains(tmp_ctx,
390 if (!NT_STATUS_IS_OK(status)) {
395 ptrust_list->count = num_trusts;
396 ptrust_list->array = talloc_move(mem_ctx, &trusts);
400 if (b && is_valid_policy_hnd(&lsa_policy)) {
401 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
404 TALLOC_FREE(tmp_ctx);
408 /* Lookup group membership given a rid. */
409 static NTSTATUS sam_lookup_groupmem(struct winbindd_domain *domain,
411 const struct dom_sid *group_sid,
412 enum lsa_SidType type,
413 uint32_t *pnum_names,
414 struct dom_sid **psid_mem,
416 uint32_t **pname_types)
418 struct rpc_pipe_client *samr_pipe;
419 struct policy_handle dom_pol;
421 uint32_t num_names = 0;
422 struct dom_sid *sid_mem = NULL;
424 uint32_t *name_types = NULL;
427 NTSTATUS status, result;
428 struct dcerpc_binding_handle *b = NULL;
430 DEBUG(3,("sam_lookup_groupmem\n"));
432 ZERO_STRUCT(dom_pol);
435 if (sid_check_is_in_builtin(group_sid) && (type != SID_NAME_ALIAS)) {
436 /* There's no groups, only aliases in BUILTIN */
437 return NT_STATUS_NO_SUCH_GROUP;
444 tmp_ctx = talloc_stackframe();
445 if (tmp_ctx == NULL) {
446 return NT_STATUS_NO_MEMORY;
449 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
450 if (!NT_STATUS_IS_OK(status)) {
454 b = samr_pipe->binding_handle;
456 status = rpc_lookup_groupmem(tmp_ctx,
469 *pnum_names = num_names;
473 *pnames = talloc_move(mem_ctx, &names);
477 *pname_types = talloc_move(mem_ctx, &name_types);
481 *psid_mem = talloc_move(mem_ctx, &sid_mem);
485 if (b && is_valid_policy_hnd(&dom_pol)) {
486 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
489 TALLOC_FREE(tmp_ctx);
493 /*********************************************************************
494 BUILTIN specific functions.
495 *********************************************************************/
497 /* List all domain groups */
498 static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain,
501 struct wb_acct_info **info)
503 /* BUILTIN doesn't have domain groups */
509 /* Query display info for a domain */
510 static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain,
513 struct wbint_userinfo **info)
515 /* We don't have users */
521 /* Lookup user information from a rid or username. */
522 static NTSTATUS builtin_query_user(struct winbindd_domain *domain,
524 const struct dom_sid *user_sid,
525 struct wbint_userinfo *user_info)
527 return NT_STATUS_NO_SUCH_USER;
530 /* get a list of trusted domains - builtin domain */
531 static NTSTATUS builtin_trusted_domains(struct winbindd_domain *domain,
533 struct netr_DomainTrustList *trusts)
535 ZERO_STRUCTP(trusts);
539 /*********************************************************************
541 *********************************************************************/
543 /* List all local groups (aliases) */
544 static NTSTATUS sam_enum_local_groups(struct winbindd_domain *domain,
547 struct wb_acct_info **pinfo)
549 struct rpc_pipe_client *samr_pipe;
550 struct policy_handle dom_pol;
551 struct wb_acct_info *info = NULL;
552 uint32_t num_info = 0;
554 NTSTATUS status, result;
555 struct dcerpc_binding_handle *b = NULL;
557 DEBUG(3,("samr: enum local groups\n"));
559 ZERO_STRUCT(dom_pol);
565 tmp_ctx = talloc_stackframe();
566 if (tmp_ctx == NULL) {
567 return NT_STATUS_NO_MEMORY;
570 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
571 if (!NT_STATUS_IS_OK(status)) {
575 b = samr_pipe->binding_handle;
577 status = rpc_enum_local_groups(mem_ctx,
582 if (!NT_STATUS_IS_OK(status)) {
587 *pnum_info = num_info;
591 *pinfo = talloc_move(mem_ctx, &info);
595 if (b && is_valid_policy_hnd(&dom_pol)) {
596 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
599 TALLOC_FREE(tmp_ctx);
603 /* convert a single name to a sid in a domain */
604 static NTSTATUS sam_name_to_sid(struct winbindd_domain *domain,
606 const char *domain_name,
609 struct dom_sid *psid,
610 enum lsa_SidType *ptype)
612 struct rpc_pipe_client *lsa_pipe;
613 struct policy_handle lsa_policy;
615 enum lsa_SidType type;
617 NTSTATUS status, result;
618 struct dcerpc_binding_handle *b = NULL;
620 DEBUG(3,("sam_name_to_sid\n"));
622 ZERO_STRUCT(lsa_policy);
624 tmp_ctx = talloc_stackframe();
625 if (tmp_ctx == NULL) {
626 return NT_STATUS_NO_MEMORY;
629 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
630 if (!NT_STATUS_IS_OK(status)) {
634 b = lsa_pipe->binding_handle;
636 status = rpc_name_to_sid(tmp_ctx,
644 if (!NT_STATUS_IS_OK(status)) {
649 sid_copy(psid, &sid);
656 if (b && is_valid_policy_hnd(&lsa_policy)) {
657 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
660 TALLOC_FREE(tmp_ctx);
664 /* convert a domain SID to a user or group name */
665 static NTSTATUS sam_sid_to_name(struct winbindd_domain *domain,
667 const struct dom_sid *sid,
670 enum lsa_SidType *ptype)
672 struct rpc_pipe_client *lsa_pipe;
673 struct policy_handle lsa_policy;
674 char *domain_name = NULL;
676 enum lsa_SidType type;
678 NTSTATUS status, result;
679 struct dcerpc_binding_handle *b = NULL;
681 DEBUG(3,("sam_sid_to_name\n"));
683 ZERO_STRUCT(lsa_policy);
686 if (!sid_check_is_in_builtin(sid) &&
687 !sid_check_is_in_our_domain(sid) &&
688 !sid_check_is_in_unix_users(sid) &&
689 !sid_check_is_unix_users(sid) &&
690 !sid_check_is_in_unix_groups(sid) &&
691 !sid_check_is_unix_groups(sid) &&
692 !sid_check_is_in_wellknown_domain(sid)) {
693 DEBUG(0, ("sam_sid_to_name: possible deadlock - trying to "
694 "lookup SID %s\n", sid_string_dbg(sid)));
695 return NT_STATUS_NONE_MAPPED;
698 tmp_ctx = talloc_stackframe();
699 if (tmp_ctx == NULL) {
700 return NT_STATUS_NO_MEMORY;
703 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
704 if (!NT_STATUS_IS_OK(status)) {
708 b = lsa_pipe->binding_handle;
710 status = rpc_sid_to_name(tmp_ctx,
724 *pname = talloc_move(mem_ctx, &name);
728 *pdomain_name = talloc_move(mem_ctx, &domain_name);
732 if (b && is_valid_policy_hnd(&lsa_policy)) {
733 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
736 TALLOC_FREE(tmp_ctx);
740 static NTSTATUS sam_rids_to_names(struct winbindd_domain *domain,
742 const struct dom_sid *domain_sid,
747 enum lsa_SidType **ptypes)
749 struct rpc_pipe_client *lsa_pipe;
750 struct policy_handle lsa_policy;
751 enum lsa_SidType *types = NULL;
752 char *domain_name = NULL;
755 NTSTATUS status, result;
756 struct dcerpc_binding_handle *b = NULL;
758 DEBUG(3,("sam_rids_to_names for %s\n", domain->name));
760 ZERO_STRUCT(lsa_policy);
763 if (!sid_check_is_builtin(domain_sid) &&
764 !sid_check_is_our_sam(domain_sid) &&
765 !sid_check_is_unix_users(domain_sid) &&
766 !sid_check_is_unix_groups(domain_sid) &&
767 !sid_check_is_in_wellknown_domain(domain_sid)) {
768 DEBUG(0, ("sam_rids_to_names: possible deadlock - trying to "
769 "lookup SID %s\n", sid_string_dbg(domain_sid)));
770 return NT_STATUS_NONE_MAPPED;
773 tmp_ctx = talloc_stackframe();
774 if (tmp_ctx == NULL) {
775 return NT_STATUS_NO_MEMORY;
778 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
779 if (!NT_STATUS_IS_OK(status)) {
783 b = lsa_pipe->binding_handle;
785 status = rpc_rids_to_names(tmp_ctx,
795 if (!NT_STATUS_IS_OK(status)) {
800 *pdomain_name = talloc_move(mem_ctx, &domain_name);
804 *ptypes = talloc_move(mem_ctx, &types);
808 *pnames = talloc_move(mem_ctx, &names);
812 if (b && is_valid_policy_hnd(&lsa_policy)) {
813 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
816 TALLOC_FREE(tmp_ctx);
820 static NTSTATUS sam_lockout_policy(struct winbindd_domain *domain,
822 struct samr_DomInfo12 *lockout_policy)
824 struct rpc_pipe_client *samr_pipe;
825 struct policy_handle dom_pol;
826 union samr_DomainInfo *info = NULL;
828 NTSTATUS status, result;
829 struct dcerpc_binding_handle *b = NULL;
831 DEBUG(3,("sam_lockout_policy\n"));
833 ZERO_STRUCT(dom_pol);
835 tmp_ctx = talloc_stackframe();
836 if (tmp_ctx == NULL) {
837 return NT_STATUS_NO_MEMORY;
840 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
841 if (!NT_STATUS_IS_OK(status)) {
845 b = samr_pipe->binding_handle;
847 status = dcerpc_samr_QueryDomainInfo(b,
850 DomainLockoutInformation,
853 if (!NT_STATUS_IS_OK(status)) {
856 if (!NT_STATUS_IS_OK(result)) {
861 *lockout_policy = info->info12;
864 if (b && is_valid_policy_hnd(&dom_pol)) {
865 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
868 TALLOC_FREE(tmp_ctx);
872 static NTSTATUS sam_password_policy(struct winbindd_domain *domain,
874 struct samr_DomInfo1 *passwd_policy)
876 struct rpc_pipe_client *samr_pipe;
877 struct policy_handle dom_pol;
878 union samr_DomainInfo *info = NULL;
880 NTSTATUS status, result;
881 struct dcerpc_binding_handle *b = NULL;
883 DEBUG(3,("sam_password_policy\n"));
885 ZERO_STRUCT(dom_pol);
887 tmp_ctx = talloc_stackframe();
888 if (tmp_ctx == NULL) {
889 return NT_STATUS_NO_MEMORY;
892 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
893 if (!NT_STATUS_IS_OK(status)) {
897 b = samr_pipe->binding_handle;
899 status = dcerpc_samr_QueryDomainInfo(b,
902 DomainPasswordInformation,
905 if (!NT_STATUS_IS_OK(status)) {
908 if (!NT_STATUS_IS_OK(result)) {
913 *passwd_policy = info->info1;
916 if (b && is_valid_policy_hnd(&dom_pol)) {
917 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
920 TALLOC_FREE(tmp_ctx);
924 /* Lookup groups a user is a member of. */
925 static NTSTATUS sam_lookup_usergroups(struct winbindd_domain *domain,
927 const struct dom_sid *user_sid,
928 uint32_t *pnum_groups,
929 struct dom_sid **puser_grpsids)
931 struct rpc_pipe_client *samr_pipe;
932 struct policy_handle dom_pol;
933 struct dom_sid *user_grpsids = NULL;
934 uint32_t num_groups = 0;
936 NTSTATUS status, result;
937 struct dcerpc_binding_handle *b = NULL;
939 DEBUG(3,("sam_lookup_usergroups\n"));
941 ZERO_STRUCT(dom_pol);
947 tmp_ctx = talloc_stackframe();
948 if (tmp_ctx == NULL) {
949 return NT_STATUS_NO_MEMORY;
952 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
953 if (!NT_STATUS_IS_OK(status)) {
957 b = samr_pipe->binding_handle;
959 status = rpc_lookup_usergroups(tmp_ctx,
966 if (!NT_STATUS_IS_OK(status)) {
971 *pnum_groups = num_groups;
975 *puser_grpsids = talloc_move(mem_ctx, &user_grpsids);
979 if (b && is_valid_policy_hnd(&dom_pol)) {
980 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
983 TALLOC_FREE(tmp_ctx);
987 static NTSTATUS sam_lookup_useraliases(struct winbindd_domain *domain,
990 const struct dom_sid *sids,
991 uint32_t *pnum_aliases,
992 uint32_t **palias_rids)
994 struct rpc_pipe_client *samr_pipe;
995 struct policy_handle dom_pol;
996 uint32_t num_aliases = 0;
997 uint32_t *alias_rids = NULL;
999 NTSTATUS status, result;
1000 struct dcerpc_binding_handle *b = NULL;
1002 DEBUG(3,("sam_lookup_useraliases\n"));
1004 ZERO_STRUCT(dom_pol);
1010 tmp_ctx = talloc_stackframe();
1011 if (tmp_ctx == NULL) {
1012 return NT_STATUS_NO_MEMORY;
1015 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
1016 if (!NT_STATUS_IS_OK(status)) {
1020 b = samr_pipe->binding_handle;
1022 status = rpc_lookup_useraliases(tmp_ctx,
1029 if (!NT_STATUS_IS_OK(status)) {
1034 *pnum_aliases = num_aliases;
1038 *palias_rids = talloc_move(mem_ctx, &alias_rids);
1042 if (b && is_valid_policy_hnd(&dom_pol)) {
1043 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
1046 TALLOC_FREE(tmp_ctx);
1050 /* find the sequence number for a domain */
1051 static NTSTATUS sam_sequence_number(struct winbindd_domain *domain,
1054 struct rpc_pipe_client *samr_pipe;
1055 struct policy_handle dom_pol;
1057 TALLOC_CTX *tmp_ctx;
1058 NTSTATUS status, result;
1059 struct dcerpc_binding_handle *b = NULL;
1061 DEBUG(3,("samr: sequence number\n"));
1063 ZERO_STRUCT(dom_pol);
1066 *pseq = DOM_SEQUENCE_NONE;
1069 tmp_ctx = talloc_stackframe();
1070 if (tmp_ctx == NULL) {
1071 return NT_STATUS_NO_MEMORY;
1074 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
1075 if (!NT_STATUS_IS_OK(status)) {
1079 b = samr_pipe->binding_handle;
1081 status = rpc_sequence_number(tmp_ctx,
1086 if (!NT_STATUS_IS_OK(status)) {
1094 if (b && is_valid_policy_hnd(&dom_pol)) {
1095 dcerpc_samr_Close(b, tmp_ctx, &dom_pol, &result);
1098 TALLOC_FREE(tmp_ctx);
1102 /* the rpc backend methods are exposed via this structure */
1103 struct winbindd_methods builtin_passdb_methods = {
1104 .consistent = false,
1106 .query_user_list = builtin_query_user_list,
1107 .enum_dom_groups = builtin_enum_dom_groups,
1108 .enum_local_groups = sam_enum_local_groups,
1109 .name_to_sid = sam_name_to_sid,
1110 .sid_to_name = sam_sid_to_name,
1111 .rids_to_names = sam_rids_to_names,
1112 .query_user = builtin_query_user,
1113 .lookup_usergroups = sam_lookup_usergroups,
1114 .lookup_useraliases = sam_lookup_useraliases,
1115 .lookup_groupmem = sam_lookup_groupmem,
1116 .sequence_number = sam_sequence_number,
1117 .lockout_policy = sam_lockout_policy,
1118 .password_policy = sam_password_policy,
1119 .trusted_domains = builtin_trusted_domains
1122 /* the rpc backend methods are exposed via this structure */
1123 struct winbindd_methods sam_passdb_methods = {
1124 .consistent = false,
1126 .query_user_list = sam_query_user_list,
1127 .enum_dom_groups = sam_enum_dom_groups,
1128 .enum_local_groups = sam_enum_local_groups,
1129 .name_to_sid = sam_name_to_sid,
1130 .sid_to_name = sam_sid_to_name,
1131 .rids_to_names = sam_rids_to_names,
1132 .query_user = sam_query_user,
1133 .lookup_usergroups = sam_lookup_usergroups,
1134 .lookup_useraliases = sam_lookup_useraliases,
1135 .lookup_groupmem = sam_lookup_groupmem,
1136 .sequence_number = sam_sequence_number,
1137 .lockout_policy = sam_lockout_policy,
1138 .password_policy = sam_password_policy,
1139 .trusted_domains = sam_trusted_domains