s3-winbind: Added a common rpc_enum_dom_groups function.
authorAndreas Schneider <asn@samba.org>
Wed, 16 Jun 2010 19:15:54 +0000 (21:15 +0200)
committerAndreas Schneider <asn@samba.org>
Mon, 5 Jul 2010 13:59:09 +0000 (15:59 +0200)
source3/Makefile.in
source3/winbindd/winbindd_rpc.c [new file with mode: 0644]
source3/winbindd/winbindd_rpc.h [new file with mode: 0644]
source3/wscript_build

index 9a24b9257256c753973f507e350a0f8bbe90ddf7..69f3425ede082e691edeb102a14b0d7b860481f2 100644 (file)
@@ -1176,7 +1176,8 @@ WINBINDD_OBJ1 = \
                winbindd/winbindd_misc.o  \
                winbindd/winbindd_cm.o    \
                winbindd/winbindd_wins.o  \
-               winbindd/winbindd_msrpc.o   \
+               winbindd/winbindd_msrpc.o \
+               winbindd/winbindd_rpc.o   \
                winbindd/winbindd_reconnect.o \
                winbindd/winbindd_ads.o   \
                winbindd/winbindd_samr.o \
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
new file mode 100644 (file)
index 0000000..fda5c91
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Winbind rpc backend functions
+ *
+ * Copyright (c) 2000-2003 Tim Potter
+ * Copyright (c) 2001      Andrew Tridgell
+ * Copyright (c) 2005      Volker Lendecke
+ * Copyright (c) 2008      Guenther Deschner (pidl conversion)
+ * Copyright (c) 2010      Andreas Schneider <asn@samba.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "winbindd.h"
+#include "winbindd_rpc.h"
+
+#include "librpc/gen_ndr/cli_samr.h"
+#include "librpc/gen_ndr/srv_samr.h"
+#include "librpc/gen_ndr/cli_lsa.h"
+#include "librpc/gen_ndr/srv_lsa.h"
+#include "rpc_client/cli_samr.h"
+#include "rpc_client/cli_lsarpc.h"
+
+/* List all domain groups */
+NTSTATUS rpc_enum_dom_groups(TALLOC_CTX *mem_ctx,
+                            struct rpc_pipe_client *samr_pipe,
+                            struct policy_handle *samr_policy,
+                            uint32_t *pnum_info,
+                            struct acct_info **pinfo)
+{
+       struct acct_info *info = NULL;
+       uint32_t start = 0;
+       uint32_t num_info = 0;
+       NTSTATUS status;
+
+       *pnum_info = 0;
+
+       do {
+               struct samr_SamArray *sam_array = NULL;
+               uint32_t count = 0;
+               uint32_t g;
+
+               /* start is updated by this call. */
+               status = rpccli_samr_EnumDomainGroups(samr_pipe,
+                                                     mem_ctx,
+                                                     samr_policy,
+                                                     &start,
+                                                     &sam_array,
+                                                     0xFFFF, /* buffer size? */
+                                                     &count);
+               if (!NT_STATUS_IS_OK(status)) {
+                       if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
+                               DEBUG(2,("query_user_list: failed to enum domain groups: %s\n",
+                                        nt_errstr(status)));
+                               return status;
+                       }
+               }
+
+               info = TALLOC_REALLOC_ARRAY(mem_ctx,
+                                           info,
+                                           struct acct_info,
+                                           num_info + count);
+               if (info == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               for (g = 0; g < count; g++) {
+                       fstrcpy(info[num_info + g].acct_name,
+                               sam_array->entries[g].name.string);
+
+                       info[num_info + g].rid = sam_array->entries[g].idx;
+               }
+
+               num_info += count;
+       } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
+
+       *pnum_info = num_info;
+       *pinfo = info;
+
+       return NT_STATUS_OK;
+}
diff --git a/source3/winbindd/winbindd_rpc.h b/source3/winbindd/winbindd_rpc.h
new file mode 100644 (file)
index 0000000..d327e16
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Winbind rpc backend functions
+ *
+ * Copyright (c) 2000-2003 Tim Potter
+ * Copyright (c) 2001      Andrew Tridgell
+ * Copyright (c) 2005      Volker Lendecke
+ * Copyright (c) 2008      Guenther Deschner (pidl conversion)
+ * Copyright (c) 2010      Andreas Schneider <asn@samba.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _WINBINDD_RPC_H_
+#define _WINBINDD_RPC_H_
+
+NTSTATUS rpc_enum_dom_groups(TALLOC_CTX *mem_ctx,
+                            struct rpc_pipe_client *samr_pipe,
+                            struct policy_handle *sam_policy,
+                            uint32_t *pnum_info,
+                            struct acct_info **pinfo);
+
+#endif /* _WINBINDD_RPC_H_ */
index 980acc32eaa2bd4d487619f1597c8647cd574c44..0a6b509b5b2472b36249e994b193310eda1919ff 100644 (file)
@@ -562,6 +562,7 @@ WINBINDD_SRC1 = '''winbindd/winbindd.c
                    winbindd/winbindd_cm.c
                    winbindd/winbindd_wins.c
                    winbindd/winbindd_msrpc.c
+                   winbindd/winbindd_rpc.c
                    winbindd/winbindd_reconnect.c
                    winbindd/winbindd_ads.c
                    winbindd/winbindd_samr.c