s3-winbind: Added a common rpc_enum_local_groups function.
authorAndreas Schneider <asn@samba.org>
Thu, 17 Jun 2010 13:51:58 +0000 (15:51 +0200)
committerAndreas Schneider <asn@samba.org>
Mon, 5 Jul 2010 13:59:10 +0000 (15:59 +0200)
source3/winbindd/winbindd_rpc.c
source3/winbindd/winbindd_rpc.h

index 48d177057f477f8649b87308d68fd86691a8c096..eddd1882d4055736fee9af93051927aa79d7a454 100644 (file)
@@ -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;
+}
index c5ee1cc72e117b242aaec74506c7415853d8d210..5ba5bf4ce5558b0b0ec0f9c22b5ef2d35542861d 100644 (file)
@@ -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_ */