This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
ZERO_STRUCT(q);
ZERO_STRUCT(r);
- sid_ptrs = TALLOC_ARRAY(mem_ctx, uint32, num_sids);
- if (sid_ptrs == NULL)
- return NT_STATUS_NO_MEMORY;
-
+ if (num_sids) {
+ sid_ptrs = TALLOC_ARRAY(mem_ctx, uint32, num_sids);
+ if (sid_ptrs == NULL)
+ return NT_STATUS_NO_MEMORY;
+ } else {
+ sid_ptrs = NULL;
+ }
+
for (i=0; i<num_sids; i++)
sid_ptrs[i] = 1;
fstring conv_buf;
(*rids)[i] = r.sam[i].rid;
- unistr2_to_ascii(conv_buf, &(r.uni_acct_name[i]), sizeof(conv_buf) - 1);
+ unistr2_to_ascii(conv_buf, &(r.uni_acct_name[i]), sizeof(conv_buf));
(*dom_users)[i] = talloc_strdup(mem_ctx, conv_buf);
}
}
if (r.sam[i].hdr_name.buffer) {
unistr2_to_ascii((*dom_groups)[i].acct_name,
&r.uni_grp_name[name_idx],
- sizeof(fstring) - 1);
+ sizeof((*dom_groups)[i].acct_name));
name_idx++;
}
if (r.sam[i].hdr_name.buffer) {
unistr2_to_ascii((*dom_aliases)[i].acct_name,
&r.uni_grp_name[name_idx],
- sizeof(fstring) - 1);
+ sizeof((*dom_aliases)[i].acct_name));
name_idx++;
}
return result;
}
+/* User change password given blobs */
+
+NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *username,
+ DATA_BLOB new_nt_password,
+ DATA_BLOB old_nt_hash_enc,
+ DATA_BLOB new_lm_password,
+ DATA_BLOB old_lm_hash_enc)
+{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_CHGPASSWD_USER q;
+ SAMR_R_CHGPASSWD_USER r;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
+
+ DEBUG(10,("rpccli_samr_chng_pswd_auth_crap\n"));
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Marshall data and send request */
+
+ init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
+ new_nt_password.data,
+ old_nt_hash_enc.data,
+ new_lm_password.data,
+ old_lm_hash_enc.data);
+
+ CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_CHGPASSWD_USER,
+ q, r,
+ qbuf, rbuf,
+ samr_io_q_chgpasswd_user,
+ samr_io_r_chgpasswd_user,
+ NT_STATUS_UNSUCCESSFUL);
+
+ /* Return output parameters */
+
+ if (!NT_STATUS_IS_OK(result = r.status)) {
+ goto done;
+ }
+
+ done:
+
+ return result;
+}
+
+
/* change password 3 */
NTSTATUS rpccli_samr_chgpasswd3(struct rpc_pipe_client *cli,
*names = TALLOC_ARRAY(mem_ctx, char *, r.num_names1);
*name_types = TALLOC_ARRAY(mem_ctx, uint32, r.num_names1);
+ if ((*names == NULL) || (*name_types == NULL)) {
+ TALLOC_FREE(*names);
+ TALLOC_FREE(*name_types);
+ return NT_STATUS_NO_MEMORY;
+ }
+
for (i = 0; i < r.num_names1; i++) {
fstring tmp;
- unistr2_to_ascii(tmp, &r.uni_name[i], sizeof(tmp) - 1);
+ unistr2_to_ascii(tmp, &r.uni_name[i], sizeof(tmp));
(*names)[i] = talloc_strdup(mem_ctx, tmp);
(*name_types)[i] = r.type[i];
}
*rids = TALLOC_ARRAY(mem_ctx, uint32, r.num_rids1);
*rid_types = TALLOC_ARRAY(mem_ctx, uint32, r.num_rids1);
+ if ((*rids == NULL) || (*rid_types == NULL)) {
+ TALLOC_FREE(*rids);
+ TALLOC_FREE(*rid_types);
+ return NT_STATUS_NO_MEMORY;
+ }
+
for (i = 0; i < r.num_rids1; i++) {
(*rids)[i] = r.rids[i];
(*rid_types)[i] = r.types[i];