s4-winbind: Add support for the WINBINDD_LIST_GROUPS command.
[gd/samba-autobuild/.git] / source4 / winbind / wb_samba3_cmd.c
index 6af92668a37ca5ffe81bbaf5f18d71caa66f08c9..2c273e517595f4bd82cbd2ebf1a296806ee21e21 100644 (file)
@@ -5,6 +5,7 @@
    Copyright (C) Stefan Metzmacher     2005
    Copyright (C) Volker Lendecke       2005
    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
    Copyright (C) Stefan Metzmacher     2005
    Copyright (C) Volker Lendecke       2005
    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+   Copyright (C) Kai Blin              2009
 
    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
 
    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
@@ -679,6 +680,50 @@ static void list_trustdom_recv_doms(struct composite_context *ctx)
        wbsrv_samba3_async_epilogue(status, s3call);
 }
 
        wbsrv_samba3_async_epilogue(status, s3call);
 }
 
+/* list groups */
+static void list_groups_recv(struct composite_context *ctx);
+
+NTSTATUS wbsrv_samba3_list_groups(struct wbsrv_samba3_call *s3call)
+{
+       struct composite_context *ctx;
+       struct wbsrv_service *service = s3call->wbconn->listen_socket->service;
+
+       DEBUG(5, ("wbsrv_samba4_list_groups called\n"));
+
+       ctx = wb_cmd_list_groups_send(s3call, service,
+                                     s3call->request.domain_name);
+       NT_STATUS_HAVE_NO_MEMORY(ctx);
+
+       ctx->async.fn = list_groups_recv;
+       ctx->async.private_data = s3call;
+       s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;
+       return NT_STATUS_OK;
+}
+
+static void list_groups_recv(struct composite_context *ctx)
+{
+       struct wbsrv_samba3_call *s3call = talloc_get_type_abort(
+                                               ctx->async.private_data,
+                                               struct wbsrv_samba3_call);
+       uint32_t extra_data_len;
+       char *extra_data;
+       NTSTATUS status;
+
+       DEBUG(5, ("list_groups_recv called\n"));
+
+       status = wb_cmd_list_groups_recv(ctx, s3call, &extra_data_len,
+                       &extra_data);
+
+       if (NT_STATUS_IS_OK(status)) {
+               s3call->response.extra_data.data = extra_data;
+               s3call->response.length += extra_data_len;
+               if (extra_data) {
+                       s3call->response.length += 1;
+               }
+       }
+
+       wbsrv_samba3_async_epilogue(status, s3call);
+}
 
 /* List users */
 
 
 /* List users */