s4-idmap: Add mapping using uidNumber and gidNumber like idmap_ad
[samba.git] / source4 / winbind / wb_cmd_usersids.c
index 1aebeae91361d9aee555a1f92acb99df64b5e926..da4cb80c7bb4defafdbb9d2ffd26cc2909ae8002 100644 (file)
@@ -7,7 +7,7 @@
    
    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 2 of the License, or
+   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,
@@ -16,8 +16,7 @@
    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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -35,20 +34,20 @@ struct cmd_usersids_state {
        struct composite_context *ctx;
        struct wbsrv_service *service;
        struct dom_sid *user_sid;
-       int num_domgroups;
+       uint32_t num_domgroups;
        struct dom_sid **domgroups;
 
        struct lsa_SidArray lsa_sids;
        struct samr_Ids rids;
        struct samr_GetAliasMembership r;
 
-       int num_sids;
+       uint32_t num_sids;
        struct dom_sid **sids;
 };
 
 static void usersids_recv_domgroups(struct composite_context *ctx);
 static void usersids_recv_domain(struct composite_context *ctx);
-static void usersids_recv_aliases(struct rpc_request *req);
+static void usersids_recv_aliases(struct tevent_req *subreq);
 
 struct composite_context *wb_cmd_usersids_send(TALLOC_CTX *mem_ctx,
                                               struct wbsrv_service *service,
@@ -57,11 +56,9 @@ struct composite_context *wb_cmd_usersids_send(TALLOC_CTX *mem_ctx,
        struct composite_context *result, *ctx;
        struct cmd_usersids_state *state;
 
-       result = talloc(mem_ctx, struct composite_context);
+
+       result = composite_create(mem_ctx, service->task->event_ctx);
        if (result == NULL) goto failed;
-       result->state = COMPOSITE_STATE_IN_PROGRESS;
-       result->async.fn = NULL;
-       result->event_ctx = service->task->event_ctx;
 
        state = talloc(result, struct cmd_usersids_state);
        if (state == NULL) goto failed;
@@ -105,9 +102,9 @@ static void usersids_recv_domain(struct composite_context *ctx)
         struct cmd_usersids_state *state =
                 talloc_get_type(ctx->async.private_data,
                                 struct cmd_usersids_state);
-       struct rpc_request *req;
+       struct tevent_req *subreq;
        struct wbsrv_domain *domain;
-       int i;
+       uint32_t i;
 
        state->ctx->status = wb_sid2domain_recv(ctx, &domain);
        if (!composite_is_ok(state->ctx)) return;
@@ -125,23 +122,27 @@ static void usersids_recv_domain(struct composite_context *ctx)
        state->rids.count = 0;
        state->rids.ids = NULL;
 
-       state->r.in.domain_handle = domain->domain_handle;
+       state->r.in.domain_handle = &domain->libnet_ctx->samr.handle;
        state->r.in.sids = &state->lsa_sids;
        state->r.out.rids = &state->rids;
 
-       req = dcerpc_samr_GetAliasMembership_send(domain->samr_pipe, state,
-                                                 &state->r);
-       composite_continue_rpc(state->ctx, req, usersids_recv_aliases, state);
+       subreq = dcerpc_samr_GetAliasMembership_r_send(state,
+                                                      state->ctx->event_ctx,
+                                                      domain->libnet_ctx->samr.pipe->binding_handle,
+                                                      &state->r);
+       if (composite_nomem(subreq, state->ctx)) return;
+       tevent_req_set_callback(subreq, usersids_recv_aliases, state);
 }
 
-static void usersids_recv_aliases(struct rpc_request *req)
+static void usersids_recv_aliases(struct tevent_req *subreq)
 {
        struct cmd_usersids_state *state =
-               talloc_get_type(req->async.private,
-                               struct cmd_usersids_state);
-       int i;
+               tevent_req_callback_data(subreq,
+               struct cmd_usersids_state);
+       uint32_t i;
 
-       state->ctx->status = dcerpc_ndr_request_recv(req);
+       state->ctx->status = dcerpc_samr_GetAliasMembership_r_recv(subreq, state);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(state->ctx)) return;
        state->ctx->status = state->r.out.result;
        if (!composite_is_ok(state->ctx)) return;
@@ -171,7 +172,7 @@ static void usersids_recv_aliases(struct rpc_request *req)
 
 NTSTATUS wb_cmd_usersids_recv(struct composite_context *ctx,
                              TALLOC_CTX *mem_ctx,
-                             int *num_sids, struct dom_sid ***sids)
+                             uint32_t *num_sids, struct dom_sid ***sids)
 {
        NTSTATUS status = composite_wait(ctx);
        if (NT_STATUS_IS_OK(status)) {
@@ -187,7 +188,7 @@ NTSTATUS wb_cmd_usersids_recv(struct composite_context *ctx,
 
 NTSTATUS wb_cmd_usersids(TALLOC_CTX *mem_ctx, struct wbsrv_service *service,
                         const struct dom_sid *sid,
-                        int *num_sids, struct dom_sid ***sids)
+                        uint32_t *num_sids, struct dom_sid ***sids)
 {
        struct composite_context *c =
                wb_cmd_usersids_send(mem_ctx, service, sid);