summaryrefslogtreecommitdiff
path: root/source4/libnet
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2005-10-02 19:59:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:17 -0500
commitbc651bd7a49ce266a7e0b12d473abda788035fef (patch)
tree132f4fd3aa05140263b7bfbe906a076eb7c142e0 /source4/libnet
parente264c8b6dd207862a618627ef288e3ca0a33fe0f (diff)
downloadsamba-bc651bd7a49ce266a7e0b12d473abda788035fef.tar.gz
samba-bc651bd7a49ce266a7e0b12d473abda788035fef.tar.bz2
samba-bc651bd7a49ce266a7e0b12d473abda788035fef.zip
r10679: Monitor messages should be issued from usermod functions.
Also a bit of formatting. rafal (This used to be commit 1fefca2c172085d6bc05bfac1c10e52066e42606)
Diffstat (limited to 'source4/libnet')
-rw-r--r--source4/libnet/composite.h1
-rw-r--r--source4/libnet/userman.c59
2 files changed, 52 insertions, 8 deletions
diff --git a/source4/libnet/composite.h b/source4/libnet/composite.h
index 0500e19f5a..515db2a792 100644
--- a/source4/libnet/composite.h
+++ b/source4/libnet/composite.h
@@ -37,6 +37,7 @@
#define rpc_close_user (0x00000004) /* userinfo.h */
#define rpc_lookup_name (0x00000005) /* userman.h */
#define rpc_delete_user (0x00000006) /* userman.h */
+#define rpc_set_user (0x00000007) /* userman.h */
struct monitor_msg {
uint32_t type;
diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c
index 2a76b55ef1..cd632602ff 100644
--- a/source4/libnet/userman.c
+++ b/source4/libnet/userman.c
@@ -30,7 +30,7 @@
#include "libnet/userinfo.h"
/*
- * Composite user add function
+ * Composite USER ADD functionality
*/
static void useradd_handler(struct rpc_request*);
@@ -45,6 +45,7 @@ struct useradd_state {
struct samr_CreateUser createuser;
struct policy_handle user_handle;
uint32_t user_rid;
+
/* information about the progress */
void (*monitor_fn)(struct monitor_msg *);
};
@@ -201,8 +202,9 @@ NTSTATUS libnet_rpc_useradd(struct dcerpc_pipe *pipe,
}
+
/*
- * Composite user delete function
+ * Composite USER DELETE functionality
*/
static void userdel_handler(struct rpc_request*);
@@ -218,6 +220,7 @@ struct userdel_state {
struct samr_LookupNames lookupname;
struct samr_OpenUser openuser;
struct samr_DeleteUser deleteuser;
+
/* information about the progress */
void (*monitor_fn)(struct monitor_msg *);
};
@@ -315,7 +318,8 @@ static void userdel_handler(struct rpc_request *req)
msg.type = rpc_lookup_name;
msg_lookup = talloc(s, struct msg_rpc_lookup_name);
- msg_lookup->rid = s->lookupname.out.rids.ids;
+
+ msg_lookup->rid = s->lookupname.out.rids.ids;
msg_lookup->count = s->lookupname.out.rids.count;
msg.data = (void*)msg_lookup;
msg.data_size = sizeof(*msg_lookup);
@@ -326,7 +330,8 @@ static void userdel_handler(struct rpc_request *req)
msg.type = rpc_open_user;
msg_open = talloc(s, struct msg_rpc_open_user);
- msg_open->rid = s->openuser.in.rid;
+
+ msg_open->rid = s->openuser.in.rid;
msg_open->access_mask = s->openuser.in.rid;
msg.data = (void*)msg_open;
msg.data_size = sizeof(*msg_open);
@@ -375,9 +380,9 @@ struct composite_context *libnet_rpc_userdel_send(struct dcerpc_pipe *p,
s = talloc_zero(c, struct userdel_state);
if (s == NULL) goto failure;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->private_data= s;
- c->event_ctx = dcerpc_event_context(p);
+ c->state = COMPOSITE_STATE_IN_PROGRESS;
+ c->private_data = s;
+ c->event_ctx = dcerpc_event_context(p);
s->pipe = p;
s->domain_handle = io->in.domain_handle;
@@ -405,7 +410,7 @@ failure:
/**
-1 * Waits for and receives results of asynchronous userdel call
+ * Waits for and receives results of asynchronous userdel call
*
* @param c composite context returned by asynchronous userdel call
* @param mem_ctx memory context of the call
@@ -449,6 +454,10 @@ NTSTATUS libnet_rpc_userdel(struct dcerpc_pipe *pipe,
}
+/*
+ * USER MODIFY functionality
+ */
+
static void usermod_handler(struct rpc_request*);
enum usermod_stage { USERMOD_LOOKUP, USERMOD_OPEN, USERMOD_QUERY, USERMOD_MODIFY };
@@ -465,6 +474,9 @@ struct usermod_state {
struct samr_OpenUser openuser;
struct samr_SetUserInfo setuser;
struct samr_QueryUserInfo queryuser;
+
+ /* information about the progress */
+ void (*monitor_fn)(struct monitor_msg *);
};
@@ -691,22 +703,49 @@ static void usermod_handler(struct rpc_request *req)
{
struct composite_context *c = req->async.private;
struct usermod_state *s = talloc_get_type(c->private_data, struct usermod_state);
+ struct monitor_msg msg;
+ struct msg_rpc_lookup_name *msg_lookup;
+ struct msg_rpc_open_user *msg_open;
switch (s->stage) {
case USERMOD_LOOKUP:
c->status = usermod_lookup(c, s);
+
+ msg.type = rpc_lookup_name;
+ msg_lookup = talloc(s, struct msg_rpc_lookup_name);
+
+ msg_lookup->rid = s->lookupname.out.rids.ids;
+ msg_lookup->count = s->lookupname.out.rids.count;
+ msg.data = (void*)msg_lookup;
+ msg.data_size = sizeof(*msg_lookup);
break;
case USERMOD_OPEN:
c->status = usermod_open(c, s);
+
+ msg.type = rpc_open_user;
+ msg_open = talloc(s, struct msg_rpc_open_user);
+
+ msg_open->rid = s->openuser.in.rid;
+ msg_open->access_mask = s->openuser.in.rid;
+ msg.data = (void*)msg_open;
+ msg.data_size = sizeof(*msg_open);
break;
case USERMOD_QUERY:
c->status = usermod_query(c, s);
+
+ msg.type = rpc_query_user;
+ msg.data = NULL;
+ msg.data_size = 0;
break;
case USERMOD_MODIFY:
c->status = usermod_modify(c, s);
+
+ msg.type = rpc_set_user;
+ msg.data = NULL;
+ msg.data_size = 0;
break;
}
@@ -714,6 +753,10 @@ static void usermod_handler(struct rpc_request *req)
c->state = COMPOSITE_STATE_ERROR;
}
+ if (s->monitor_fn) {
+ s->monitor_fn(&msg);
+ }
+
if (c->state >= COMPOSITE_STATE_DONE &&
c->async.fn) {
c->async.fn(c);