summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2006-06-26 21:18:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:33 -0500
commit7d1533f616dd2695fb89d2562b2b49c08f57d0fe (patch)
tree22bfb9a34f20649bc13d831e0d6b01256f4f546d /source4
parent3ef6f35ddee6a48ea04358c180772bb040f64652 (diff)
downloadsamba-7d1533f616dd2695fb89d2562b2b49c08f57d0fe.tar.gz
samba-7d1533f616dd2695fb89d2562b2b49c08f57d0fe.tar.bz2
samba-7d1533f616dd2695fb89d2562b2b49c08f57d0fe.zip
r16531: Add a function preparing argument for modify user routine.
rafal (This used to be commit d91cbec2644030a6e7978dd2e2c854e9d7a3d313)
Diffstat (limited to 'source4')
-rw-r--r--source4/libnet/libnet_user.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/source4/libnet/libnet_user.c b/source4/libnet/libnet_user.c
index 22cd44d81a..7f6c54bcca 100644
--- a/source4/libnet/libnet_user.c
+++ b/source4/libnet/libnet_user.c
@@ -24,6 +24,7 @@
#include "libcli/composite/composite.h"
#include "auth/credentials/credentials.h"
#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/samr.h"
#include "librpc/gen_ndr/ndr_samr.h"
@@ -348,6 +349,8 @@ struct modify_user_state {
static void continue_rpc_usermod(struct composite_context *ctx);
static void continue_domain_open_modify(struct composite_context *ctx);
+static NTSTATUS set_user_changes(TALLOC_CTX *mem_ctx, struct usermod_change *mod,
+ struct libnet_rpc_userinfo *info, struct libnet_ModifyUser *r);
static void continue_rpc_userinfo(struct composite_context *ctx);
@@ -428,8 +431,10 @@ static void continue_rpc_userinfo(struct composite_context *ctx)
c->status = libnet_rpc_userinfo_recv(ctx, c, &s->user_info);
if (!composite_is_ok(c)) return;
- /* TODO: prepare arguments based on requested changes
- and received current user info */
+ s->user_mod.in.domain_handle = s->ctx->domain.handle;
+ s->user_mod.in.username = s->r.in.user_name;
+
+ c->status = set_user_changes(c, &s->user_mod.in.change, &s->user_info, &s->r);
usermod_req = libnet_rpc_usermod_send(s->ctx->samr_pipe, &s->user_mod, s->monitor_fn);
if (composite_nomem(usermod_req, c)) return;
@@ -438,6 +443,40 @@ static void continue_rpc_userinfo(struct composite_context *ctx)
}
+static NTSTATUS set_user_changes(TALLOC_CTX *mem_ctx, struct usermod_change *mod,
+ struct libnet_rpc_userinfo *info, struct libnet_ModifyUser *r)
+{
+ struct samr_UserInfo21 *user;
+
+ if (mod == NULL || info == NULL || r == NULL || info->in.level != 21) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ user = &info->out.info.info21;
+ mod->fields = 0; /* reset flag field before setting individual flags */
+
+ if (r->in.account_name != NULL &&
+ !strequal_w(user->account_name.string, r->in.account_name)) {
+
+ mod->account_name = talloc_strdup(mem_ctx, r->in.account_name);
+ if (mod->account_name == NULL) return NT_STATUS_NO_MEMORY;
+
+ mod->fields |= USERMOD_FIELD_ACCOUNT_NAME;
+ }
+
+ if (r->in.full_name != NULL &&
+ !strequal_w(user->full_name.string, r->in.full_name)) {
+
+ mod->full_name = talloc_strdup(mem_ctx, r->in.full_name);
+ if (mod->full_name == NULL) return NT_STATUS_NO_MEMORY;
+
+ mod->fields |= USERMOD_FIELD_FULL_NAME;
+ }
+
+ return NT_STATUS_OK;
+}
+
+
static void continue_rpc_usermod(struct composite_context *ctx)
{
struct composite_context *c;