summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-17 15:51:58 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:10 +0200
commit89c8ef97c4141e748e5c566a4c25981c31fba507 (patch)
tree9f2205932f0a6d300f6b4be3e9cf21f74ef507cb /source3
parent8159b1281be6ebbad0626c71070ddf457f2558e0 (diff)
downloadsamba-89c8ef97c4141e748e5c566a4c25981c31fba507.tar.gz
samba-89c8ef97c4141e748e5c566a4c25981c31fba507.tar.bz2
samba-89c8ef97c4141e748e5c566a4c25981c31fba507.zip
s3-winbind: Added a common rpc_enum_local_groups function.
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/winbindd_rpc.c54
-rw-r--r--source3/winbindd/winbindd_rpc.h7
2 files changed, 61 insertions, 0 deletions
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index 48d177057f..eddd1882d4 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -193,3 +193,57 @@ NTSTATUS rpc_enum_dom_groups(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+
+NTSTATUS rpc_enum_local_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 num_info = 0;
+ NTSTATUS status;
+
+ *pnum_info = 0;
+
+ do {
+ struct samr_SamArray *sam_array = NULL;
+ uint32_t count = 0;
+ uint32_t start = num_info;
+ uint32_t g;
+
+ status = rpccli_samr_EnumDomainAliases(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)) {
+ 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
index c5ee1cc72e..5ba5bf4ce5 100644
--- a/source3/winbindd/winbindd_rpc.h
+++ b/source3/winbindd/winbindd_rpc.h
@@ -40,4 +40,11 @@ NTSTATUS rpc_enum_dom_groups(TALLOC_CTX *mem_ctx,
uint32_t *pnum_info,
struct acct_info **pinfo);
+/* List all domain groups */
+NTSTATUS rpc_enum_local_groups(TALLOC_CTX *mem_ctx,
+ struct rpc_pipe_client *samr_pipe,
+ struct policy_handle *samr_policy,
+ uint32_t *pnum_info,
+ struct acct_info **pinfo);
+
#endif /* _WINBINDD_RPC_H_ */