From c1aac87d34a9596e449a4baa661b44009552b5b4 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Thu, 18 Jan 2007 23:21:59 +0000 Subject: r20885: - I forgot the page size passed to enumeration function is actually size of a buffer for result returned, not number of entries - pass libnet function returned status to UserListCtx creation to properly mark the last chunk of the list rafal (This used to be commit 05d307546f93794a0a981c3aa942669b9b18afd1) --- source4/scripting/ejs/ejsnet/mpr_user.c | 10 ++++++++-- source4/scripting/ejs/ejsnet/net_user.c | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/ejs/ejsnet/mpr_user.c b/source4/scripting/ejs/ejsnet/mpr_user.c index 9a49262dc6..efeb68ffc1 100644 --- a/source4/scripting/ejs/ejsnet/mpr_user.c +++ b/source4/scripting/ejs/ejsnet/mpr_user.c @@ -100,11 +100,13 @@ done: UserListCtx.Users[] UserListCtx.ResumeIndex UserListCtx.Count + UserListCtx.EndOfList */ -struct MprVar mprUserListCtx(TALLOC_CTX *mem_ctx, struct libnet_UserList *list) +struct MprVar mprUserListCtx(TALLOC_CTX *mem_ctx, struct libnet_UserList *list, NTSTATUS result) { const char *name = "UserListCtx"; NTSTATUS status; + bool endOfList; struct MprVar mprListCtx, mprUserList; struct MprVar mprUser, mprSid, mprUsername; int i; @@ -114,6 +116,9 @@ struct MprVar mprUserListCtx(TALLOC_CTX *mem_ctx, struct libnet_UserList *list) goto done; } + endOfList = (NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) || + NT_STATUS_IS_OK(result)); + mprUserList = mprArray("Users"); for (i = 0; i < list->out.count; i++) { struct userlist u = list->out.users[i]; @@ -128,7 +133,7 @@ struct MprVar mprUserListCtx(TALLOC_CTX *mem_ctx, struct libnet_UserList *list) mprSetVar(&mprUser, "SID", mprSid); /* add the object to the array being constructed */ - mprAddArray(&mprUserList, 0, mprUser); + mprAddArray(&mprUserList, i, mprUser); } mprListCtx = mprObject(name); @@ -138,6 +143,7 @@ struct MprVar mprUserListCtx(TALLOC_CTX *mem_ctx, struct libnet_UserList *list) if (!NT_STATUS_IS_OK(status)) goto done; status = mprSetVar(&mprListCtx, "ResumeIndex", mprCreateIntegerVar((int)list->out.resume_index)); if (!NT_STATUS_IS_OK(status)) goto done; + status = mprSetVar(&mprListCtx, "EndOfList", mprCreateBoolVar(endOfList)); done: return mprListCtx; diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c index 7563ef2e72..a13e84c147 100644 --- a/source4/scripting/ejs/ejsnet/net_user.c +++ b/source4/scripting/ejs/ejsnet/net_user.c @@ -299,7 +299,7 @@ static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv) NTSTATUS status; struct libnet_context *ctx; const char *userlist_domain; - int page_size = 10; /* TODO: this should be specified in a nicer way */ + int page_size = 512; /* TODO: this should be specified in a nicer way */ struct libnet_UserList req; struct MprVar mprListCtx, *mprInListCtx; @@ -359,7 +359,7 @@ static int ejs_net_userlist(MprVarHandle eid, int argc, struct MprVar **argv) goto done; } - mprListCtx = mprUserListCtx(mem_ctx, &req); + mprListCtx = mprUserListCtx(mem_ctx, &req, status); done: talloc_free(mem_ctx); -- cgit