s4-idmap: Add mapping using uidNumber and gidNumber like idmap_ad
[samba.git] / source4 / winbind / wb_cmd_list_users.c
index f67f13348887fc31e0b4d8f6ad224f1ab6b25791..03544f6585b20191642a547d7c7dd5aa25f57028 100644 (file)
 #include "includes.h"
 #include "libcli/composite/composite.h"
 #include "winbind/wb_server.h"
-#include "winbind/wb_async_helpers.h"
-#include "winbind/wb_helper.h"
 #include "smbd/service_task.h"
-#include "libnet/libnet_proto.h"
 
 struct cmd_list_users_state {
        struct composite_context *ctx;
@@ -33,8 +30,9 @@ struct cmd_list_users_state {
 
        struct wbsrv_domain *domain;
        char *domain_name;
-       uint resume_index;
+       uint32_t resume_index;
        char *result;
+       uint32_t num_users;
 };
 
 static void cmd_list_users_recv_domain(struct composite_context *ctx);
@@ -58,6 +56,7 @@ struct composite_context *wb_cmd_list_users_send(TALLOC_CTX *mem_ctx,
        result->private_data = state;
        state->service = service;
        state->resume_index = 0;
+       state->num_users = 0;
        state->result = talloc_strdup(state, "");
        if (composite_nomem(state->result, state->ctx)) return result;
 
@@ -136,7 +135,8 @@ static void cmd_list_users_recv_user_list(struct composite_context *ctx)
 
        /* If NTSTATUS is neither OK nor MORE_ENTRIES, something broke */
        if (!NT_STATUS_IS_OK(status) &&
-            !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
+           !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) &&
+           !NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
                composite_error(state->ctx, status);
                return;
        }
@@ -145,6 +145,7 @@ static void cmd_list_users_recv_user_list(struct composite_context *ctx)
                DEBUG(5, ("Appending user '%s'\n", user_list->out.users[i].username));
                state->result = talloc_asprintf_append_buffer(state->result, "%s,",
                                        user_list->out.users[i].username);
+               state->num_users++;
        }
 
        /* If the status is OK, we're finished, there's no more users.
@@ -177,7 +178,7 @@ static void cmd_list_users_recv_user_list(struct composite_context *ctx)
 
 NTSTATUS wb_cmd_list_users_recv(struct composite_context *ctx,
                TALLOC_CTX *mem_ctx, uint32_t *extra_data_len,
-               char **extra_data)
+               char **extra_data, uint32_t *num_users)
 {
        NTSTATUS status = composite_wait(ctx);
 
@@ -189,6 +190,7 @@ NTSTATUS wb_cmd_list_users_recv(struct composite_context *ctx,
 
                *extra_data_len = strlen(state->result);
                *extra_data = talloc_steal(mem_ctx, state->result);
+               *num_users = state->num_users;
        }
 
        talloc_free(ctx);