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"
30 #include "rpc_client/rpc_client.h"
31 #include "../librpc/gen_ndr/ndr_samr_c.h"
32 #include "rpc_client/cli_samr.h"
33 #include "../librpc/gen_ndr/srv_samr.h"
34 #include "../librpc/gen_ndr/ndr_lsa_c.h"
35 #include "rpc_client/cli_lsarpc.h"
36 #include "../librpc/gen_ndr/srv_lsa.h"
37 #include "rpc_server/rpc_ncacn_np.h"
38 #include "../libcli/security/security.h"
39 #include "passdb/machine_sid.h"
43 #define DBGC_CLASS DBGC_WINBIND
45 static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx,
46 struct rpc_pipe_client **samr_pipe)
48 struct rpc_pipe_client *cli = NULL;
49 struct auth_serversupplied_info *session_info = NULL;
52 if (session_info == NULL) {
53 status = make_session_info_system(mem_ctx, &session_info);
54 if (!NT_STATUS_IS_OK(status)) {
55 DEBUG(0, ("open_samr_pipe: Could not create auth_serversupplied_info: %s\n",
61 /* create a samr connection */
62 status = rpc_pipe_open_interface(mem_ctx,
63 &ndr_table_samr.syntax_id,
66 winbind_messaging_context(),
68 if (!NT_STATUS_IS_OK(status)) {
69 DEBUG(0, ("open_samr_pipe: Could not connect to samr_pipe: %s\n",
81 NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
82 struct winbindd_domain *domain,
83 struct rpc_pipe_client **samr_pipe,
84 struct policy_handle *samr_domain_hnd)
86 NTSTATUS status, result;
87 struct policy_handle samr_connect_hnd;
88 struct dcerpc_binding_handle *b;
90 status = open_internal_samr_pipe(mem_ctx, samr_pipe);
91 if (!NT_STATUS_IS_OK(status)) {
95 b = (*samr_pipe)->binding_handle;
97 status = dcerpc_samr_Connect2(b, mem_ctx,
98 (*samr_pipe)->desthost,
99 SEC_FLAG_MAXIMUM_ALLOWED,
102 if (!NT_STATUS_IS_OK(status)) {
105 if (!NT_STATUS_IS_OK(result)) {
109 status = dcerpc_samr_OpenDomain(b, mem_ctx,
111 SEC_FLAG_MAXIMUM_ALLOWED,
115 if (!NT_STATUS_IS_OK(status)) {
122 static NTSTATUS open_internal_lsa_pipe(TALLOC_CTX *mem_ctx,
123 struct rpc_pipe_client **lsa_pipe)
125 struct rpc_pipe_client *cli = NULL;
126 struct auth_serversupplied_info *session_info = NULL;
129 if (session_info == NULL) {
130 status = make_session_info_system(mem_ctx, &session_info);
131 if (!NT_STATUS_IS_OK(status)) {
132 DEBUG(0, ("open_lsa_pipe: Could not create auth_serversupplied_info: %s\n",
138 /* create a lsa connection */
139 status = rpc_pipe_open_interface(mem_ctx,
140 &ndr_table_lsarpc.syntax_id,
143 winbind_messaging_context(),
145 if (!NT_STATUS_IS_OK(status)) {
146 DEBUG(0, ("open_lsa_pipe: Could not connect to lsa_pipe: %s\n",
158 static NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
159 struct rpc_pipe_client **lsa_pipe,
160 struct policy_handle *lsa_hnd)
164 status = open_internal_lsa_pipe(mem_ctx, lsa_pipe);
165 if (!NT_STATUS_IS_OK(status)) {
169 status = rpccli_lsa_open_policy((*lsa_pipe),
172 SEC_FLAG_MAXIMUM_ALLOWED,
178 /*********************************************************************
179 SAM specific functions.
180 *********************************************************************/
182 /* List all domain groups */
183 static NTSTATUS sam_enum_dom_groups(struct winbindd_domain *domain,
186 struct wb_acct_info **pinfo)
188 struct rpc_pipe_client *samr_pipe;
189 struct policy_handle dom_pol;
190 struct wb_acct_info *info = NULL;
191 uint32_t num_info = 0;
193 NTSTATUS status, result;
194 struct dcerpc_binding_handle *b = NULL;
196 DEBUG(3,("sam_enum_dom_groups\n"));
198 ZERO_STRUCT(dom_pol);
204 tmp_ctx = talloc_stackframe();
205 if (tmp_ctx == NULL) {
206 return NT_STATUS_NO_MEMORY;
209 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
210 if (!NT_STATUS_IS_OK(status)) {
214 b = samr_pipe->binding_handle;
216 status = rpc_enum_dom_groups(tmp_ctx,
221 if (!NT_STATUS_IS_OK(status)) {
226 *pnum_info = num_info;
230 *pinfo = talloc_move(mem_ctx, &info);
234 if (b && is_valid_policy_hnd(&dom_pol)) {
235 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
237 TALLOC_FREE(tmp_ctx);
241 /* Query display info for a domain */
242 static NTSTATUS sam_query_user_list(struct winbindd_domain *domain,
245 struct wbint_userinfo **pinfo)
247 struct rpc_pipe_client *samr_pipe = NULL;
248 struct policy_handle dom_pol;
249 struct wbint_userinfo *info = NULL;
250 uint32_t num_info = 0;
252 NTSTATUS status, result;
253 struct dcerpc_binding_handle *b = NULL;
255 DEBUG(3,("samr_query_user_list\n"));
257 ZERO_STRUCT(dom_pol);
263 tmp_ctx = talloc_stackframe();
264 if (tmp_ctx == NULL) {
265 return NT_STATUS_NO_MEMORY;
268 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
269 if (!NT_STATUS_IS_OK(status)) {
273 b = samr_pipe->binding_handle;
275 status = rpc_query_user_list(tmp_ctx,
281 if (!NT_STATUS_IS_OK(status)) {
286 *pnum_info = num_info;
290 *pinfo = talloc_move(mem_ctx, &info);
294 if (b && is_valid_policy_hnd(&dom_pol)) {
295 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
298 TALLOC_FREE(tmp_ctx);
302 /* Lookup user information from a rid or username. */
303 static NTSTATUS sam_query_user(struct winbindd_domain *domain,
305 const struct dom_sid *user_sid,
306 struct wbint_userinfo *user_info)
308 struct rpc_pipe_client *samr_pipe;
309 struct policy_handle dom_pol;
311 NTSTATUS status, result;
312 struct dcerpc_binding_handle *b = NULL;
314 DEBUG(3,("sam_query_user\n"));
316 ZERO_STRUCT(dom_pol);
319 if (!sid_check_is_in_our_domain(user_sid)) {
320 return NT_STATUS_NO_SUCH_USER;
324 user_info->homedir = NULL;
325 user_info->shell = NULL;
326 user_info->primary_gid = (gid_t) -1;
329 tmp_ctx = talloc_stackframe();
330 if (tmp_ctx == NULL) {
331 return NT_STATUS_NO_MEMORY;
334 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
335 if (!NT_STATUS_IS_OK(status)) {
339 b = samr_pipe->binding_handle;
341 status = rpc_query_user(tmp_ctx,
349 if (b && is_valid_policy_hnd(&dom_pol)) {
350 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
353 TALLOC_FREE(tmp_ctx);
357 /* get a list of trusted domains - builtin domain */
358 static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
360 struct netr_DomainTrustList *ptrust_list)
362 struct rpc_pipe_client *lsa_pipe;
363 struct policy_handle lsa_policy;
364 struct netr_DomainTrust *trusts = NULL;
365 uint32_t num_trusts = 0;
367 NTSTATUS status, result;
368 struct dcerpc_binding_handle *b = NULL;
370 DEBUG(3,("samr: trusted domains\n"));
372 ZERO_STRUCT(lsa_policy);
375 ZERO_STRUCTP(ptrust_list);
378 tmp_ctx = talloc_stackframe();
379 if (tmp_ctx == NULL) {
380 return NT_STATUS_NO_MEMORY;
383 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
384 if (!NT_STATUS_IS_OK(status)) {
388 b = lsa_pipe->binding_handle;
390 status = rpc_trusted_domains(tmp_ctx,
395 if (!NT_STATUS_IS_OK(status)) {
400 ptrust_list->count = num_trusts;
401 ptrust_list->array = talloc_move(mem_ctx, &trusts);
405 if (b && is_valid_policy_hnd(&lsa_policy)) {
406 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
409 TALLOC_FREE(tmp_ctx);
413 /* Lookup group membership given a rid. */
414 static NTSTATUS sam_lookup_groupmem(struct winbindd_domain *domain,
416 const struct dom_sid *group_sid,
417 enum lsa_SidType type,
418 uint32_t *pnum_names,
419 struct dom_sid **psid_mem,
421 uint32_t **pname_types)
423 struct rpc_pipe_client *samr_pipe;
424 struct policy_handle dom_pol;
426 uint32_t num_names = 0;
427 struct dom_sid *sid_mem = NULL;
429 uint32_t *name_types = NULL;
432 NTSTATUS status, result;
433 struct dcerpc_binding_handle *b = NULL;
435 DEBUG(3,("sam_lookup_groupmem\n"));
437 ZERO_STRUCT(dom_pol);
440 if (sid_check_is_in_builtin(group_sid) && (type != SID_NAME_ALIAS)) {
441 /* There's no groups, only aliases in BUILTIN */
442 return NT_STATUS_NO_SUCH_GROUP;
449 tmp_ctx = talloc_stackframe();
450 if (tmp_ctx == NULL) {
451 return NT_STATUS_NO_MEMORY;
454 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
455 if (!NT_STATUS_IS_OK(status)) {
459 b = samr_pipe->binding_handle;
461 status = rpc_lookup_groupmem(tmp_ctx,
474 *pnum_names = num_names;
478 *pnames = talloc_move(mem_ctx, &names);
482 *pname_types = talloc_move(mem_ctx, &name_types);
486 *psid_mem = talloc_move(mem_ctx, &sid_mem);
490 if (b && is_valid_policy_hnd(&dom_pol)) {
491 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
494 TALLOC_FREE(tmp_ctx);
498 /*********************************************************************
499 BUILTIN specific functions.
500 *********************************************************************/
502 /* List all domain groups */
503 static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain,
506 struct wb_acct_info **info)
508 /* BUILTIN doesn't have domain groups */
514 /* Query display info for a domain */
515 static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain,
518 struct wbint_userinfo **info)
520 /* We don't have users */
526 /* Lookup user information from a rid or username. */
527 static NTSTATUS builtin_query_user(struct winbindd_domain *domain,
529 const struct dom_sid *user_sid,
530 struct wbint_userinfo *user_info)
532 return NT_STATUS_NO_SUCH_USER;
535 /* get a list of trusted domains - builtin domain */
536 static NTSTATUS builtin_trusted_domains(struct winbindd_domain *domain,
538 struct netr_DomainTrustList *trusts)
540 ZERO_STRUCTP(trusts);
544 /*********************************************************************
546 *********************************************************************/
548 /* List all local groups (aliases) */
549 static NTSTATUS sam_enum_local_groups(struct winbindd_domain *domain,
552 struct wb_acct_info **pinfo)
554 struct rpc_pipe_client *samr_pipe;
555 struct policy_handle dom_pol;
556 struct wb_acct_info *info = NULL;
557 uint32_t num_info = 0;
559 NTSTATUS status, result;
560 struct dcerpc_binding_handle *b = NULL;
562 DEBUG(3,("samr: enum local groups\n"));
564 ZERO_STRUCT(dom_pol);
570 tmp_ctx = talloc_stackframe();
571 if (tmp_ctx == NULL) {
572 return NT_STATUS_NO_MEMORY;
575 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
576 if (!NT_STATUS_IS_OK(status)) {
580 b = samr_pipe->binding_handle;
582 status = rpc_enum_local_groups(mem_ctx,
587 if (!NT_STATUS_IS_OK(status)) {
592 *pnum_info = num_info;
596 *pinfo = talloc_move(mem_ctx, &info);
600 if (b && is_valid_policy_hnd(&dom_pol)) {
601 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
604 TALLOC_FREE(tmp_ctx);
608 /* convert a single name to a sid in a domain */
609 static NTSTATUS sam_name_to_sid(struct winbindd_domain *domain,
611 const char *domain_name,
614 struct dom_sid *psid,
615 enum lsa_SidType *ptype)
617 struct rpc_pipe_client *lsa_pipe;
618 struct policy_handle lsa_policy;
620 enum lsa_SidType type;
622 NTSTATUS status, result;
623 struct dcerpc_binding_handle *b = NULL;
625 DEBUG(3,("sam_name_to_sid\n"));
627 ZERO_STRUCT(lsa_policy);
629 tmp_ctx = talloc_stackframe();
630 if (tmp_ctx == NULL) {
631 return NT_STATUS_NO_MEMORY;
634 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
635 if (!NT_STATUS_IS_OK(status)) {
639 b = lsa_pipe->binding_handle;
641 status = rpc_name_to_sid(tmp_ctx,
649 if (!NT_STATUS_IS_OK(status)) {
654 sid_copy(psid, &sid);
661 if (b && is_valid_policy_hnd(&lsa_policy)) {
662 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
665 TALLOC_FREE(tmp_ctx);
669 /* convert a domain SID to a user or group name */
670 static NTSTATUS sam_sid_to_name(struct winbindd_domain *domain,
672 const struct dom_sid *sid,
675 enum lsa_SidType *ptype)
677 struct rpc_pipe_client *lsa_pipe;
678 struct policy_handle lsa_policy;
679 char *domain_name = NULL;
681 enum lsa_SidType type;
683 NTSTATUS status, result;
684 struct dcerpc_binding_handle *b = NULL;
686 DEBUG(3,("sam_sid_to_name\n"));
688 ZERO_STRUCT(lsa_policy);
691 if (!sid_check_is_in_builtin(sid) &&
692 !sid_check_is_in_our_domain(sid) &&
693 !sid_check_is_in_unix_users(sid) &&
694 !sid_check_is_unix_users(sid) &&
695 !sid_check_is_in_unix_groups(sid) &&
696 !sid_check_is_unix_groups(sid) &&
697 !sid_check_is_in_wellknown_domain(sid)) {
698 DEBUG(0, ("sam_sid_to_name: possible deadlock - trying to "
699 "lookup SID %s\n", sid_string_dbg(sid)));
700 return NT_STATUS_NONE_MAPPED;
703 tmp_ctx = talloc_stackframe();
704 if (tmp_ctx == NULL) {
705 return NT_STATUS_NO_MEMORY;
708 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
709 if (!NT_STATUS_IS_OK(status)) {
713 b = lsa_pipe->binding_handle;
715 status = rpc_sid_to_name(tmp_ctx,
729 *pname = talloc_move(mem_ctx, &name);
733 *pdomain_name = talloc_move(mem_ctx, &domain_name);
737 if (b && is_valid_policy_hnd(&lsa_policy)) {
738 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
741 TALLOC_FREE(tmp_ctx);
745 static NTSTATUS sam_rids_to_names(struct winbindd_domain *domain,
747 const struct dom_sid *domain_sid,
752 enum lsa_SidType **ptypes)
754 struct rpc_pipe_client *lsa_pipe;
755 struct policy_handle lsa_policy;
756 enum lsa_SidType *types = NULL;
757 char *domain_name = NULL;
760 NTSTATUS status, result;
761 struct dcerpc_binding_handle *b = NULL;
763 DEBUG(3,("sam_rids_to_names for %s\n", domain->name));
765 ZERO_STRUCT(lsa_policy);
768 if (!sid_check_is_builtin(domain_sid) &&
769 !sid_check_is_domain(domain_sid) &&
770 !sid_check_is_unix_users(domain_sid) &&
771 !sid_check_is_unix_groups(domain_sid) &&
772 !sid_check_is_in_wellknown_domain(domain_sid)) {
773 DEBUG(0, ("sam_rids_to_names: possible deadlock - trying to "
774 "lookup SID %s\n", sid_string_dbg(domain_sid)));
775 return NT_STATUS_NONE_MAPPED;
778 tmp_ctx = talloc_stackframe();
779 if (tmp_ctx == NULL) {
780 return NT_STATUS_NO_MEMORY;
783 status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy);
784 if (!NT_STATUS_IS_OK(status)) {
788 b = lsa_pipe->binding_handle;
790 status = rpc_rids_to_names(tmp_ctx,
800 if (!NT_STATUS_IS_OK(status)) {
805 *pdomain_name = talloc_move(mem_ctx, &domain_name);
809 *ptypes = talloc_move(mem_ctx, &types);
813 *pnames = talloc_move(mem_ctx, &names);
817 if (b && is_valid_policy_hnd(&lsa_policy)) {
818 dcerpc_lsa_Close(b, mem_ctx, &lsa_policy, &result);
821 TALLOC_FREE(tmp_ctx);
825 static NTSTATUS sam_lockout_policy(struct winbindd_domain *domain,
827 struct samr_DomInfo12 *lockout_policy)
829 struct rpc_pipe_client *samr_pipe;
830 struct policy_handle dom_pol;
831 union samr_DomainInfo *info = NULL;
833 NTSTATUS status, result;
834 struct dcerpc_binding_handle *b = NULL;
836 DEBUG(3,("sam_lockout_policy\n"));
838 ZERO_STRUCT(dom_pol);
840 tmp_ctx = talloc_stackframe();
841 if (tmp_ctx == NULL) {
842 return NT_STATUS_NO_MEMORY;
845 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
846 if (!NT_STATUS_IS_OK(status)) {
850 b = samr_pipe->binding_handle;
852 status = dcerpc_samr_QueryDomainInfo(b,
858 if (!NT_STATUS_IS_OK(status)) {
861 if (!NT_STATUS_IS_OK(result)) {
866 *lockout_policy = info->info12;
869 if (b && is_valid_policy_hnd(&dom_pol)) {
870 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
873 TALLOC_FREE(tmp_ctx);
877 static NTSTATUS sam_password_policy(struct winbindd_domain *domain,
879 struct samr_DomInfo1 *passwd_policy)
881 struct rpc_pipe_client *samr_pipe;
882 struct policy_handle dom_pol;
883 union samr_DomainInfo *info = NULL;
885 NTSTATUS status, result;
886 struct dcerpc_binding_handle *b = NULL;
888 DEBUG(3,("sam_password_policy\n"));
890 ZERO_STRUCT(dom_pol);
892 tmp_ctx = talloc_stackframe();
893 if (tmp_ctx == NULL) {
894 return NT_STATUS_NO_MEMORY;
897 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
898 if (!NT_STATUS_IS_OK(status)) {
902 b = samr_pipe->binding_handle;
904 status = dcerpc_samr_QueryDomainInfo(b,
910 if (!NT_STATUS_IS_OK(status)) {
913 if (!NT_STATUS_IS_OK(result)) {
918 *passwd_policy = info->info1;
921 if (b && is_valid_policy_hnd(&dom_pol)) {
922 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
925 TALLOC_FREE(tmp_ctx);
929 /* Lookup groups a user is a member of. */
930 static NTSTATUS sam_lookup_usergroups(struct winbindd_domain *domain,
932 const struct dom_sid *user_sid,
933 uint32_t *pnum_groups,
934 struct dom_sid **puser_grpsids)
936 struct rpc_pipe_client *samr_pipe;
937 struct policy_handle dom_pol;
938 struct dom_sid *user_grpsids = NULL;
939 uint32_t num_groups = 0;
941 NTSTATUS status, result;
942 struct dcerpc_binding_handle *b = NULL;
944 DEBUG(3,("sam_lookup_usergroups\n"));
946 ZERO_STRUCT(dom_pol);
952 tmp_ctx = talloc_stackframe();
953 if (tmp_ctx == NULL) {
954 return NT_STATUS_NO_MEMORY;
957 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
958 if (!NT_STATUS_IS_OK(status)) {
962 b = samr_pipe->binding_handle;
964 status = rpc_lookup_usergroups(tmp_ctx,
971 if (!NT_STATUS_IS_OK(status)) {
976 *pnum_groups = num_groups;
980 *puser_grpsids = talloc_move(mem_ctx, &user_grpsids);
984 if (b && is_valid_policy_hnd(&dom_pol)) {
985 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
988 TALLOC_FREE(tmp_ctx);
992 static NTSTATUS sam_lookup_useraliases(struct winbindd_domain *domain,
995 const struct dom_sid *sids,
996 uint32_t *pnum_aliases,
997 uint32_t **palias_rids)
999 struct rpc_pipe_client *samr_pipe;
1000 struct policy_handle dom_pol;
1001 uint32_t num_aliases = 0;
1002 uint32_t *alias_rids = NULL;
1003 TALLOC_CTX *tmp_ctx;
1004 NTSTATUS status, result;
1005 struct dcerpc_binding_handle *b = NULL;
1007 DEBUG(3,("sam_lookup_useraliases\n"));
1009 ZERO_STRUCT(dom_pol);
1015 tmp_ctx = talloc_stackframe();
1016 if (tmp_ctx == NULL) {
1017 return NT_STATUS_NO_MEMORY;
1020 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
1021 if (!NT_STATUS_IS_OK(status)) {
1025 b = samr_pipe->binding_handle;
1027 status = rpc_lookup_useraliases(tmp_ctx,
1034 if (!NT_STATUS_IS_OK(status)) {
1039 *pnum_aliases = num_aliases;
1043 *palias_rids = talloc_move(mem_ctx, &alias_rids);
1047 if (b && is_valid_policy_hnd(&dom_pol)) {
1048 dcerpc_samr_Close(b, mem_ctx, &dom_pol, &result);
1051 TALLOC_FREE(tmp_ctx);
1055 /* find the sequence number for a domain */
1056 static NTSTATUS sam_sequence_number(struct winbindd_domain *domain,
1059 struct rpc_pipe_client *samr_pipe;
1060 struct policy_handle dom_pol;
1062 TALLOC_CTX *tmp_ctx;
1063 NTSTATUS status, result;
1064 struct dcerpc_binding_handle *b = NULL;
1066 DEBUG(3,("samr: sequence number\n"));
1068 ZERO_STRUCT(dom_pol);
1071 *pseq = DOM_SEQUENCE_NONE;
1074 tmp_ctx = talloc_stackframe();
1075 if (tmp_ctx == NULL) {
1076 return NT_STATUS_NO_MEMORY;
1079 status = open_internal_samr_conn(tmp_ctx, domain, &samr_pipe, &dom_pol);
1080 if (!NT_STATUS_IS_OK(status)) {
1084 b = samr_pipe->binding_handle;
1086 status = rpc_sequence_number(tmp_ctx,
1091 if (!NT_STATUS_IS_OK(status)) {
1099 if (b && is_valid_policy_hnd(&dom_pol)) {
1100 dcerpc_samr_Close(b, tmp_ctx, &dom_pol, &result);
1103 TALLOC_FREE(tmp_ctx);
1107 /* the rpc backend methods are exposed via this structure */
1108 struct winbindd_methods builtin_passdb_methods = {
1109 .consistent = false,
1111 .query_user_list = builtin_query_user_list,
1112 .enum_dom_groups = builtin_enum_dom_groups,
1113 .enum_local_groups = sam_enum_local_groups,
1114 .name_to_sid = sam_name_to_sid,
1115 .sid_to_name = sam_sid_to_name,
1116 .rids_to_names = sam_rids_to_names,
1117 .query_user = builtin_query_user,
1118 .lookup_usergroups = sam_lookup_usergroups,
1119 .lookup_useraliases = sam_lookup_useraliases,
1120 .lookup_groupmem = sam_lookup_groupmem,
1121 .sequence_number = sam_sequence_number,
1122 .lockout_policy = sam_lockout_policy,
1123 .password_policy = sam_password_policy,
1124 .trusted_domains = builtin_trusted_domains
1127 /* the rpc backend methods are exposed via this structure */
1128 struct winbindd_methods sam_passdb_methods = {
1129 .consistent = false,
1131 .query_user_list = sam_query_user_list,
1132 .enum_dom_groups = sam_enum_dom_groups,
1133 .enum_local_groups = sam_enum_local_groups,
1134 .name_to_sid = sam_name_to_sid,
1135 .sid_to_name = sam_sid_to_name,
1136 .rids_to_names = sam_rids_to_names,
1137 .query_user = sam_query_user,
1138 .lookup_usergroups = sam_lookup_usergroups,
1139 .lookup_useraliases = sam_lookup_useraliases,
1140 .lookup_groupmem = sam_lookup_groupmem,
1141 .sequence_number = sam_sequence_number,
1142 .lockout_policy = sam_lockout_policy,
1143 .password_policy = sam_password_policy,
1144 .trusted_domains = sam_trusted_domains