summaryrefslogtreecommitdiff
path: root/source4/winbind
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-03-29 01:42:06 +0100
committerKai Blin <kai@samba.org>2008-04-02 23:06:27 +0200
commit6ce078141326a41278bbb8c6854c4cacc7cefd99 (patch)
tree311460d8ed17637b26d3063ec73b50fece8e160b /source4/winbind
parent6ae76e5cdc0c87eb0ff46f3f1818be0cf70a5a75 (diff)
downloadsamba-6ce078141326a41278bbb8c6854c4cacc7cefd99.tar.gz
samba-6ce078141326a41278bbb8c6854c4cacc7cefd99.tar.bz2
samba-6ce078141326a41278bbb8c6854c4cacc7cefd99.zip
wbclient: Add an async winbind client library.
(This used to be commit 3e3563f2840e7cd795f5fc157003af3c932cb4d1)
Diffstat (limited to 'source4/winbind')
-rw-r--r--source4/winbind/idmap.h20
-rw-r--r--source4/winbind/wb_irpc.c70
2 files changed, 72 insertions, 18 deletions
diff --git a/source4/winbind/idmap.h b/source4/winbind/idmap.h
index 045d50c568..6eae92cc68 100644
--- a/source4/winbind/idmap.h
+++ b/source4/winbind/idmap.h
@@ -22,6 +22,8 @@
#ifndef _IDMAP_H_
#define _IDMAP_H_
+#include "librpc/gen_ndr/winbind.h"
+
struct idmap_context {
struct loadparm_context *lp_ctx;
struct ldb_context *ldb_ctx;
@@ -29,24 +31,6 @@ struct idmap_context {
struct dom_sid *unix_users_sid;
};
-enum id_type {
- ID_TYPE_NOT_SPECIFIED = 0,
- ID_TYPE_UID,
- ID_TYPE_GID,
- ID_TYPE_BOTH
-};
-
-struct unixid {
- uint32_t id;
- enum id_type type;
-};
-
-struct id_mapping {
- struct unixid *unixid;
- struct dom_sid *sid;
- NTSTATUS status;
-};
-
#include "winbind/idmap_proto.h"
#endif
diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c
index 5d7f7fd7a6..0535045adb 100644
--- a/source4/winbind/wb_irpc.c
+++ b/source4/winbind/wb_irpc.c
@@ -22,6 +22,7 @@
#include "winbind/wb_server.h"
#include "lib/messaging/irpc.h"
#include "libcli/composite/composite.h"
+#include "libcli/security/proto.h"
#include "librpc/gen_ndr/ndr_winbind.h"
#include "smbd/service_task.h"
@@ -71,6 +72,71 @@ static void wb_irpc_SamLogon_callback(struct composite_context *ctx)
irpc_send_reply(s->msg, status);
}
+struct wb_irpc_get_idmap_state {
+ struct irpc_message *msg;
+ struct winbind_get_idmap *req;
+ int level;
+};
+
+static void wb_irpc_get_idmap_callback(struct composite_context *ctx);
+
+static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg,
+ struct winbind_get_idmap *req)
+{
+ struct wbsrv_service *service = talloc_get_type(msg->private,
+ struct wbsrv_service);
+ struct wb_irpc_get_idmap_state *s;
+ struct composite_context *ctx;
+
+ DEBUG(5, ("wb_irpc_get_idmap called\n"));
+
+ s = talloc(msg, struct wb_irpc_get_idmap_state);
+ NT_STATUS_HAVE_NO_MEMORY(s);
+
+ s->msg = msg;
+ s->req = req;
+ s->level = req->in.level;
+
+ switch(s->level) {
+ case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
+ ctx = wb_sids2xids_send(msg, service, req->in.count,
+ req->in.ids);
+ break;
+ case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
+ ctx = wb_xids2sids_send(msg, service, req->in.count,
+ req->in.ids);
+ break;
+ }
+ NT_STATUS_HAVE_NO_MEMORY(ctx);
+
+ composite_continue(ctx, ctx, wb_irpc_get_idmap_callback, s);
+ msg->defer_reply = true;
+
+ return NT_STATUS_OK;
+}
+
+static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
+{
+ struct wb_irpc_get_idmap_state *s;
+ NTSTATUS status;
+
+ DEBUG(5, ("wb_irpc_get_idmap_callback called\n"));
+
+ s = talloc_get_type(ctx->async.private_data,
+ struct wb_irpc_get_idmap_state);
+
+ switch(s->level) {
+ case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
+ status = wb_sids2xids_recv(ctx, &s->req->out.ids);
+ break;
+ case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
+ status = wb_xids2sids_recv(ctx, &s->req->out.ids);
+ break;
+ }
+
+ irpc_send_reply(s->msg, status);
+}
+
NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
{
NTSTATUS status;
@@ -81,5 +147,9 @@ NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
wb_irpc_SamLogon, service);
NT_STATUS_NOT_OK_RETURN(status);
+ status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP,
+ wb_irpc_get_idmap, service);
+ NT_STATUS_NOT_OK_RETURN(status);
+
return NT_STATUS_OK;
}