summaryrefslogtreecommitdiffstats
path: root/source3/rpc_client/cli_samr.c
diff options
context:
space:
mode:
authorGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:34:30 -0500
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:34:30 -0500
commite5a951325a6cac8567af3a66de6d2df577508ae4 (patch)
tree34da9fe59f3c2d7f8edb072144443a9704197831 /source3/rpc_client/cli_samr.c
parent57482469b32645250e92a7ffd003aeeb4a42235e (diff)
downloadsamba-e5a951325a6cac8567af3a66de6d2df577508ae4.tar.gz
samba-e5a951325a6cac8567af3a66de6d2df577508ae4.tar.xz
samba-e5a951325a6cac8567af3a66de6d2df577508ae4.zip
[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
(This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab)
Diffstat (limited to 'source3/rpc_client/cli_samr.c')
-rw-r--r--source3/rpc_client/cli_samr.c297
1 files changed, 82 insertions, 215 deletions
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index b1b6623bcda..8eaf20aa1ec 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -51,6 +51,9 @@ NTSTATUS rpccli_samr_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(result = r.status)) {
*connect_pol = r.connect_pol;
+#ifdef __INSURE__
+ connect_pol->marker = malloc(1);
+#endif
}
return result;
@@ -84,6 +87,9 @@ NTSTATUS rpccli_samr_connect4(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(result = r.status)) {
*connect_pol = r.connect_pol;
+#ifdef __INSURE__
+ connect_pol->marker = malloc(1);
+#endif
}
return result;
@@ -118,6 +124,9 @@ NTSTATUS rpccli_samr_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
/* Return output parameters */
if (NT_STATUS_IS_OK(result = r.status)) {
+#ifdef __INSURE__
+ SAFE_FREE(connect_pol->marker);
+#endif
*connect_pol = r.pol;
}
@@ -156,6 +165,9 @@ NTSTATUS rpccli_samr_open_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
if (NT_STATUS_IS_OK(result = r.status)) {
*domain_pol = r.domain_pol;
+#ifdef __INSURE__
+ domain_pol->marker = malloc(1);
+#endif
}
return result;
@@ -191,6 +203,9 @@ NTSTATUS rpccli_samr_open_user(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*user_pol = r.user_pol;
+#ifdef __INSURE__
+ user_pol->marker = malloc(1);
+#endif
}
return result;
@@ -228,6 +243,9 @@ NTSTATUS rpccli_samr_open_group(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*group_pol = r.pol;
+#ifdef __INSURE__
+ group_pol->marker = malloc(1);
+#endif
}
return result;
@@ -921,6 +939,9 @@ NTSTATUS rpccli_samr_open_alias(struct rpc_pipe_client *cli,
if (NT_STATUS_IS_OK(result = r.status)) {
*alias_pol = r.pol;
+#ifdef __INSURE__
+ alias_pol->marker = malloc(1);
+#endif
}
return result;
@@ -1196,6 +1217,11 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
const char *newpassword,
const char *oldpassword )
{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_CHGPASSWD_USER q;
+ SAMR_R_CHGPASSWD_USER r;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
uchar new_nt_password[516];
uchar new_lm_password[516];
uchar old_nt_hash[16];
@@ -1206,8 +1232,13 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
uchar new_nt_hash[16];
uchar new_lanman_hash[16];
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
+
DEBUG(10,("rpccli_samr_chgpasswd_user\n"));
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
/* Calculate the MD4 hash (NT compatible) of the password */
E_md4hash(oldpassword, old_nt_hash);
E_md4hash(newpassword, new_nt_hash);
@@ -1234,35 +1265,50 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
SamOEMhash( new_nt_password, old_nt_hash, 516);
E_old_pw_hash( new_nt_hash, old_nt_hash, old_nt_hash_enc);
- return rpccli_samr_chng_pswd_auth_crap(cli, mem_ctx, username,
- data_blob_const(new_nt_password,sizeof(new_nt_password)),
- data_blob_const(old_nt_hash_enc,sizeof(old_nt_hash_enc)),
- data_blob_const(new_lm_password,sizeof(new_lm_password)),
- data_blob_const(old_lanman_hash_enc,sizeof(old_lanman_hash_enc)));
+ /* Marshall data and send request */
+
+ init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
+ new_nt_password,
+ old_nt_hash_enc,
+ new_lm_password,
+ old_lanman_hash_enc);
+
+ 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;
}
-/* User change passwd with auth crap */
+/* 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)
+ 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;
- char *srv_name_slash;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- if (!(srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s",
- cli->cli->desthost))) {
- return NT_STATUS_NO_MEMORY;
- }
+ char *srv_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", cli->cli->desthost);
- DEBUG(5,("rpccli_samr_chng_pswd_auth_crap on server: %s\n",
- srv_name_slash));
+ DEBUG(10,("rpccli_samr_chng_pswd_auth_crap\n"));
ZERO_STRUCT(q);
ZERO_STRUCT(r);
@@ -1272,19 +1318,28 @@ NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
init_samr_q_chgpasswd_user(&q, srv_name_slash, username,
new_nt_password.data,
old_nt_hash_enc.data,
- new_lm_password.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);
+ q, r,
+ qbuf, rbuf,
+ samr_io_q_chgpasswd_user,
+ samr_io_r_chgpasswd_user,
+ NT_STATUS_UNSUCCESSFUL);
- return r.status;
+ /* 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,
@@ -1433,59 +1488,7 @@ NTSTATUS rpccli_samr_query_dispinfo(struct rpc_pipe_client *cli,
/* Return output parameters */
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_entries = r.num_entries;
- *start_idx += r.num_entries; /* No next_idx in this structure! */
-
- done:
- return result;
-}
-
-
-/* Query display info2 */
-
-NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 *start_idx,
- uint16 switch_value, uint32 *num_entries,
- uint32 max_entries, uint32 max_size,
- SAM_DISPINFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DISPINFO q;
- SAMR_R_QUERY_DISPINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dispinfo2 for start_idx = %u\n", *start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- *num_entries = 0;
-
- /* Marshall data and send request */
-
- init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
- *start_idx, max_entries, max_size);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO2,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_dispinfo,
- samr_io_r_query_dispinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
+ result = r.status;
if (!NT_STATUS_IS_OK(result) &&
NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
@@ -1499,142 +1502,6 @@ NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
return result;
}
-/* Query display info */
-
-NTSTATUS rpccli_samr_query_dispinfo3(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol, uint32 *start_idx,
- uint16 switch_value, uint32 *num_entries,
- uint32 max_entries, uint32 max_size,
- SAM_DISPINFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_QUERY_DISPINFO q;
- SAMR_R_QUERY_DISPINFO r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_query_dispinfo3 for start_idx = %u\n", *start_idx));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- *num_entries = 0;
-
- /* Marshall data and send request */
-
- init_samr_q_query_dispinfo(&q, domain_pol, switch_value,
- *start_idx, max_entries, max_size);
-
- r.ctr = ctr;
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_QUERY_DISPINFO3,
- q, r,
- qbuf, rbuf,
- samr_io_q_query_dispinfo,
- samr_io_r_query_dispinfo,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- result = r.status;
-
- if (!NT_STATUS_IS_OK(result) &&
- NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
- goto done;
- }
-
- *num_entries = r.num_entries;
- *start_idx += r.num_entries; /* No next_idx in this structure! */
-
- done:
- return result;
-}
-
-/* Query display info index */
-
-NTSTATUS rpccli_samr_get_dispenum_index(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- const char *name,
- uint32 *idx)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_GET_DISPENUM_INDEX q;
- SAMR_R_GET_DISPENUM_INDEX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_get_dispenum_index for name = %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX,
- q, r,
- qbuf, rbuf,
- samr_io_q_get_dispenum_index,
- samr_io_r_get_dispenum_index,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- *idx = 0;
-
- result = r.status;
-
- if (!NT_STATUS_IS_ERR(result)) {
- *idx = r.idx;
- }
-
- return result;
-}
-
-NTSTATUS rpccli_samr_get_dispenum_index2(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *domain_pol,
- uint16 switch_value,
- const char *name,
- uint32 *idx)
-{
- prs_struct qbuf, rbuf;
- SAMR_Q_GET_DISPENUM_INDEX q;
- SAMR_R_GET_DISPENUM_INDEX r;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
- DEBUG(10,("cli_samr_get_dispenum_index2 for name = %s\n", name));
-
- ZERO_STRUCT(q);
- ZERO_STRUCT(r);
-
- /* Marshall data and send request */
-
- init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
-
- CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX2,
- q, r,
- qbuf, rbuf,
- samr_io_q_get_dispenum_index,
- samr_io_r_get_dispenum_index,
- NT_STATUS_UNSUCCESSFUL);
-
- /* Return output parameters */
-
- *idx = 0;
-
- result = r.status;
-
- if (!NT_STATUS_IS_ERR(result)) {
- *idx = r.idx;
- }
-
- return result;
-}
-
-
/* Lookup rids. Note that NT4 seems to crash if more than ~1000 rids are
looked up in one packet. */