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 "librpc/gen_ndr/cli_samr.h"
31 #include "librpc/gen_ndr/srv_samr.h"
32 #include "librpc/gen_ndr/cli_lsa.h"
33 #include "librpc/gen_ndr/srv_lsa.h"
34 #include "rpc_client/cli_samr.h"
35 #include "rpc_client/cli_lsarpc.h"
37 /* List all domain groups */
38 NTSTATUS rpc_enum_dom_groups(TALLOC_CTX *mem_ctx,
39 struct rpc_pipe_client *samr_pipe,
40 struct policy_handle *samr_policy,
42 struct acct_info **pinfo)
44 struct acct_info *info = NULL;
46 uint32_t num_info = 0;
52 struct samr_SamArray *sam_array = NULL;
56 /* start is updated by this call. */
57 status = rpccli_samr_EnumDomainGroups(samr_pipe,
62 0xFFFF, /* buffer size? */
64 if (!NT_STATUS_IS_OK(status)) {
65 if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
66 DEBUG(2,("query_user_list: failed to enum domain groups: %s\n",
72 info = TALLOC_REALLOC_ARRAY(mem_ctx,
77 return NT_STATUS_NO_MEMORY;
80 for (g = 0; g < count; g++) {
81 fstrcpy(info[num_info + g].acct_name,
82 sam_array->entries[g].name.string);
84 info[num_info + g].rid = sam_array->entries[g].idx;
88 } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
90 *pnum_info = num_info;