s4: Use same function signature for convert_* as s3.
[jra/samba/.git] / source4 / libnet / userman.c
index fd2f75bc6467bd3742c0ad0a8516fb49d8968d12..62d4e0edd21d9928a2905333e5e1fbed4f7039ea 100644 (file)
@@ -23,9 +23,7 @@
 
 #include "includes.h"
 #include "libcli/composite/composite.h"
-#include "libnet/composite.h"
-#include "libnet/userman.h"
-#include "libnet/userinfo.h"
+#include "libnet/libnet.h"
 #include "librpc/gen_ndr/ndr_samr_c.h"
 
 /*
@@ -235,12 +233,12 @@ static void continue_userdel_name_found(struct rpc_request *req)
 
        /* what to do when there's no user account to delete
           and what if there's more than one rid resolved */
-       if (!s->lookupname.out.rids.count) {
+       if (!s->lookupname.out.rids->count) {
                c->status = NT_STATUS_NO_SUCH_USER;
                composite_error(c, c->status);
                return;
 
-       } else if (!s->lookupname.out.rids.count > 1) {
+       } else if (!s->lookupname.out.rids->count > 1) {
                c->status = NT_STATUS_INVALID_ACCOUNT_NAME;
                composite_error(c, c->status);
                return;
@@ -250,8 +248,8 @@ static void continue_userdel_name_found(struct rpc_request *req)
        if (s->monitor_fn) {
                struct msg_rpc_lookup_name msg_lookup;
 
-               msg_lookup.rid   = s->lookupname.out.rids.ids;
-               msg_lookup.count = s->lookupname.out.rids.count;
+               msg_lookup.rid   = s->lookupname.out.rids->ids;
+               msg_lookup.count = s->lookupname.out.rids->count;
 
                msg.type      = mon_SamrLookupName;
                msg.data      = (void*)&msg_lookup;
@@ -261,7 +259,7 @@ static void continue_userdel_name_found(struct rpc_request *req)
 
        /* prepare the arguments for rpc call */
        s->openuser.in.domain_handle = &s->domain_handle;
-       s->openuser.in.rid           = s->lookupname.out.rids.ids[0];
+       s->openuser.in.rid           = s->lookupname.out.rids->ids[0];
        s->openuser.in.access_mask   = SEC_FLAG_MAXIMUM_ALLOWED;
        s->openuser.out.user_handle  = &s->user_handle;
 
@@ -392,6 +390,10 @@ struct composite_context *libnet_rpc_userdel_send(struct dcerpc_pipe *p,
        s->lookupname.in.num_names     = 1;
        s->lookupname.in.names         = talloc_zero(s, struct lsa_String);
        s->lookupname.in.names->string = io->in.username;
+       s->lookupname.out.rids         = talloc_zero(s, struct samr_Ids);
+       s->lookupname.out.types        = talloc_zero(s, struct samr_Ids);
+       if (composite_nomem(s->lookupname.out.rids, c)) return c;
+       if (composite_nomem(s->lookupname.out.types, c)) return c;
 
        /* send the request */
        lookup_req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname);
@@ -499,12 +501,12 @@ static void continue_usermod_name_found(struct rpc_request *req)
 
        /* what to do when there's no user account to delete
           and what if there's more than one rid resolved */
-       if (!s->lookupname.out.rids.count) {
+       if (!s->lookupname.out.rids->count) {
                c->status = NT_STATUS_NO_SUCH_USER;
                composite_error(c, c->status);
                return;
 
-       } else if (!s->lookupname.out.rids.count > 1) {
+       } else if (!s->lookupname.out.rids->count > 1) {
                c->status = NT_STATUS_INVALID_ACCOUNT_NAME;
                composite_error(c, c->status);
                return;
@@ -514,8 +516,8 @@ static void continue_usermod_name_found(struct rpc_request *req)
        if (s->monitor_fn) {
                struct msg_rpc_lookup_name msg_lookup;
 
-               msg_lookup.rid   = s->lookupname.out.rids.ids;
-               msg_lookup.count = s->lookupname.out.rids.count;
+               msg_lookup.rid   = s->lookupname.out.rids->ids;
+               msg_lookup.count = s->lookupname.out.rids->count;
 
                msg.type      = mon_SamrLookupName;
                msg.data      = (void*)&msg_lookup;
@@ -525,7 +527,7 @@ static void continue_usermod_name_found(struct rpc_request *req)
 
        /* prepare the next rpc call */
        s->openuser.in.domain_handle = &s->domain_handle;
-       s->openuser.in.rid           = s->lookupname.out.rids.ids[0];
+       s->openuser.in.rid           = s->lookupname.out.rids->ids[0];
        s->openuser.in.access_mask   = SEC_FLAG_MAXIMUM_ALLOWED;
        s->openuser.out.user_handle  = &s->user_handle;
 
@@ -662,7 +664,7 @@ static NTSTATUS usermod_change(struct composite_context *c,
        uint16_t level = 27;
 
        /* prepare UserInfo level and data based on bitmask field */
-       do_set = usermod_setfields(s, &level, i, False);
+       do_set = usermod_setfields(s, &level, i, false);
 
        if (level < 1 || level > 26) {
                /* apparently there's a field that the setfields routine
@@ -678,6 +680,9 @@ static NTSTATUS usermod_change(struct composite_context *c,
        if (!do_set) {
                s->queryuser.in.user_handle = &s->user_handle;
                s->queryuser.in.level       = level;
+               s->queryuser.out.info       = talloc(s, union samr_UserInfo *);
+               if (composite_nomem(s->queryuser.out.info, c)) return NT_STATUS_NO_MEMORY;
+
 
                /* send query user info request to retrieve complete data of
                   a particular info level */
@@ -750,9 +755,9 @@ static void continue_usermod_user_queried(struct rpc_request *req)
 
        /* get returned user data and make a change (potentially one
           of many) */
-       s->info = *s->queryuser.out.info;
+       s->info = *(*s->queryuser.out.info);
 
-       usermod_setfields(s, &level, i, True);
+       usermod_setfields(s, &level, i, true);
 
        /* prepare rpc call arguments */
        s->setuser.in.user_handle  = &s->user_handle;
@@ -833,6 +838,10 @@ struct composite_context *libnet_rpc_usermod_send(struct dcerpc_pipe *p,
        s->lookupname.in.num_names     = 1;
        s->lookupname.in.names         = talloc_zero(s, struct lsa_String);
        s->lookupname.in.names->string = io->in.username;
+       s->lookupname.out.rids         = talloc_zero(s, struct samr_Ids);
+       s->lookupname.out.types        = talloc_zero(s, struct samr_Ids);
+       if (composite_nomem(s->lookupname.out.rids, c)) return c;
+       if (composite_nomem(s->lookupname.out.types, c)) return c;
 
        /* send the rpc request */
        lookup_req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname);