summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/libnet/libnet_user.c97
-rw-r--r--source4/libnet/libnet_user.h11
-rw-r--r--source4/scripting/ejs/ejsnet/net_user.c5
-rw-r--r--source4/torture/libnet/libnet_user.c6
-rw-r--r--source4/winbind/wb_cmd_getpwnam.c3
-rw-r--r--source4/winbind/wb_cmd_getpwuid.c9
6 files changed, 98 insertions, 33 deletions
diff --git a/source4/libnet/libnet_user.c b/source4/libnet/libnet_user.c
index 678c7a226e..dce7320c73 100644
--- a/source4/libnet/libnet_user.c
+++ b/source4/libnet/libnet_user.c
@@ -597,7 +597,9 @@ NTSTATUS libnet_ModifyUser(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
struct user_info_state {
struct libnet_context *ctx;
const char *domain_name;
+ enum libnet_UserInfo_level level;
const char *user_name;
+ const char *sid_string;
struct libnet_LookupName lookup;
struct libnet_DomainOpen domopen;
struct libnet_rpc_userinfo userinfo;
@@ -628,7 +630,7 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
{
struct composite_context *c;
struct user_info_state *s;
- struct composite_context *lookup_req;
+ struct composite_context *lookup_req, *info_req;
bool prereq_met = false;
/* composite context allocation and setup */
@@ -644,23 +646,54 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
s->monitor_fn = monitor;
s->ctx = ctx;
s->domain_name = talloc_strdup(c, r->in.domain_name);
- s->user_name = talloc_strdup(c, r->in.user_name);
+ s->level = r->in.level;
+ switch (s->level) {
+ case USER_INFO_BY_NAME:
+ s->user_name = talloc_strdup(c, r->in.data.user_name);
+ s->sid_string = NULL;
+ break;
+ case USER_INFO_BY_SID:
+ s->user_name = NULL;
+ s->sid_string = dom_sid_string(c, r->in.data.user_sid);
+ break;
+ }
/* prerequisite: make sure the domain is opened */
prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,
continue_domain_open_info, monitor);
if (!prereq_met) return c;
- /* prepare arguments for LookupName call */
- s->lookup.in.domain_name = s->domain_name;
- s->lookup.in.name = s->user_name;
-
- /* send the request */
- lookup_req = libnet_LookupName_send(ctx, c, &s->lookup, s->monitor_fn);
- if (composite_nomem(lookup_req, c)) return c;
+ switch (s->level) {
+ case USER_INFO_BY_NAME:
+ /* prepare arguments for LookupName call */
+ s->lookup.in.domain_name = s->domain_name;
+ s->lookup.in.name = s->user_name;
+
+ /* send the request */
+ lookup_req = libnet_LookupName_send(ctx, c, &s->lookup,
+ s->monitor_fn);
+ if (composite_nomem(lookup_req, c)) return c;
+
+ /* set the next stage */
+ composite_continue(c, lookup_req, continue_name_found, c);
+ break;
+ case USER_INFO_BY_SID:
+ /* prepare arguments for UserInfo call */
+ s->userinfo.in.domain_handle = s->ctx->samr.handle;
+ s->userinfo.in.sid = s->sid_string;
+ s->userinfo.in.level = 21;
+
+ /* send the request */
+ info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe,
+ &s->userinfo,
+ s->monitor_fn);
+ if (composite_nomem(info_req, c)) return c;
+
+ /* set the next stage */
+ composite_continue(c, info_req, continue_info_received, c);
+ break;
+ }
- /* set the next stage */
- composite_continue(c, lookup_req, continue_name_found, c);
return c;
}
@@ -673,7 +706,7 @@ static void continue_domain_open_info(struct composite_context *ctx)
{
struct composite_context *c;
struct user_info_state *s;
- struct composite_context *lookup_req;
+ struct composite_context *lookup_req, *info_req;
struct monitor_msg msg;
c = talloc_get_type(ctx->async.private_data, struct composite_context);
@@ -686,16 +719,36 @@ static void continue_domain_open_info(struct composite_context *ctx)
/* send monitor message */
if (s->monitor_fn) s->monitor_fn(&msg);
- /* prepare arguments for LookupName call */
- s->lookup.in.domain_name = s->domain_name;
- s->lookup.in.name = s->user_name;
-
- /* send the request */
- lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
- if (composite_nomem(lookup_req, c)) return;
-
- /* set the next stage */
- composite_continue(c, lookup_req, continue_name_found, c);
+ switch (s->level) {
+ case USER_INFO_BY_NAME:
+ /* prepare arguments for LookupName call */
+ s->lookup.in.domain_name = s->domain_name;
+ s->lookup.in.name = s->user_name;
+
+ /* send the request */
+ lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
+ if (composite_nomem(lookup_req, c)) return;
+
+ /* set the next stage */
+ composite_continue(c, lookup_req, continue_name_found, c);
+ break;
+
+ case USER_INFO_BY_SID:
+ /* prepare arguments for UserInfo call */
+ s->userinfo.in.domain_handle = s->ctx->samr.handle;
+ s->userinfo.in.sid = s->sid_string;
+ s->userinfo.in.level = 21;
+
+ /* send the request */
+ info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe,
+ &s->userinfo,
+ s->monitor_fn);
+ if (composite_nomem(info_req, c)) return;
+
+ /* set the next stage */
+ composite_continue(c, info_req, continue_info_received, c);
+ break;
+ }
}
diff --git a/source4/libnet/libnet_user.h b/source4/libnet/libnet_user.h
index 94aa38464f..7095160004 100644
--- a/source4/libnet/libnet_user.h
+++ b/source4/libnet/libnet_user.h
@@ -99,11 +99,19 @@ struct libnet_ModifyUser {
} \
}
+enum libnet_UserInfo_level {
+ USER_INFO_BY_NAME=0,
+ USER_INFO_BY_SID
+};
struct libnet_UserInfo {
struct {
- const char *user_name;
const char *domain_name;
+ enum libnet_UserInfo_level level;
+ union {
+ const char *user_name;
+ const struct dom_sid *user_sid;
+ } data;
} in;
struct {
struct dom_sid *user_sid;
@@ -123,7 +131,6 @@ struct libnet_UserInfo {
struct timeval *last_logoff;
struct timeval *last_password_change;
uint32_t acct_flags;
-
const char *error_string;
} out;
};
diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c
index 57e538d3b4..0c32035c6c 100644
--- a/source4/scripting/ejs/ejsnet/net_user.c
+++ b/source4/scripting/ejs/ejsnet/net_user.c
@@ -268,8 +268,9 @@ static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
/* call the libnet function */
req.in.domain_name = userman_domain;
- req.in.user_name = username;
-
+ req.in.data.user_name = username;
+ req.in.level = USER_INFO_BY_NAME;
+
status = libnet_UserInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
ejsSetErrorMsg(eid, "%s", req.out.error_string);
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 15e3f03506..6d3e682976 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -530,7 +530,8 @@ bool torture_modifyuser(struct torture_context *torture)
ZERO_STRUCT(user_req);
user_req.in.domain_name = lp_workgroup(torture->lp_ctx);
- user_req.in.user_name = name;
+ user_req.in.data.user_name = name;
+ user_req.in.level = USER_INFO_BY_NAME;
status = libnet_UserInfo(ctx, torture, &user_req);
if (!NT_STATUS_IS_OK(status)) {
@@ -642,7 +643,8 @@ bool torture_userinfo_api(struct torture_context *torture)
ZERO_STRUCT(req);
req.in.domain_name = domain_name.string;
- req.in.user_name = name;
+ req.in.data.user_name = name;
+ req.in.level = USER_INFO_BY_NAME;
status = libnet_UserInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/winbind/wb_cmd_getpwnam.c b/source4/winbind/wb_cmd_getpwnam.c
index fb2dc197c9..7d821537f0 100644
--- a/source4/winbind/wb_cmd_getpwnam.c
+++ b/source4/winbind/wb_cmd_getpwnam.c
@@ -92,7 +92,8 @@ static void cmd_getpwnam_recv_domain(struct composite_context *ctx)
return;
}
- user_info->in.user_name = user_name;
+ user_info->in.level = USER_INFO_BY_NAME;
+ user_info->in.data.user_name = user_name;
user_info->in.domain_name = domain->libnet_ctx->samr.name;
state->workgroup_name = talloc_strdup(state,
domain->libnet_ctx->samr.name);
diff --git a/source4/winbind/wb_cmd_getpwuid.c b/source4/winbind/wb_cmd_getpwuid.c
index c250af1b56..15cc592cf6 100644
--- a/source4/winbind/wb_cmd_getpwuid.c
+++ b/source4/winbind/wb_cmd_getpwuid.c
@@ -34,6 +34,7 @@ struct cmd_getpwuid_state {
struct composite_context *ctx;
struct wbsrv_service *service;
uid_t uid;
+ struct dom_sid *sid;
char *workgroup;
struct wbsrv_domain *domain;
@@ -81,14 +82,13 @@ static void cmd_getpwuid_recv_sid(struct composite_context *ctx)
struct cmd_getpwuid_state *state =
talloc_get_type(ctx->async.private_data,
struct cmd_getpwuid_state);
- struct dom_sid *sid;
DEBUG(5, ("cmd_getpwuid_recv_sid called %p\n", ctx->private_data));
- state->ctx->status = wb_uid2sid_recv(ctx, state, &sid);
+ state->ctx->status = wb_uid2sid_recv(ctx, state, &state->sid);
if (!composite_is_ok(state->ctx)) return;
- ctx = wb_sid2domain_send(state, state->service, sid);
+ ctx = wb_sid2domain_send(state, state->service, state->sid);
composite_continue(state->ctx, ctx, cmd_getpwuid_recv_domain, state);
}
@@ -110,7 +110,8 @@ static void cmd_getpwuid_recv_domain(struct composite_context *ctx)
user_info = talloc(state, struct libnet_UserInfo);
if (composite_nomem(user_info, state->ctx)) return;
- user_info->in.user_name = state->domain->libnet_ctx->cred->username;
+ user_info->in.level = USER_INFO_BY_SID;
+ user_info->in.data.user_sid = state->sid;
user_info->in.domain_name = state->domain->libnet_ctx->samr.name;
/* We need the workgroup later, so copy it */