summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-04-28 13:15:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:37 -0500
commit932b0ff5f5f5ce861a45df4a986b0db73a52e510 (patch)
treef0deb58a80e3fd5bd24b1dbef84b371af70ae258 /source4/torture/rpc
parent24be9ddf0a59a0de436b38279172217f1d1798c0 (diff)
downloadsamba-932b0ff5f5f5ce861a45df4a986b0db73a52e510.tar.gz
samba-932b0ff5f5f5ce861a45df4a986b0db73a52e510.tar.bz2
samba-932b0ff5f5f5ce861a45df4a986b0db73a52e510.zip
r389: added a test for set user info level 26 (set password extended)
thanks to Luke Howard for this test (This used to be commit 891653e7d40f581016085e2c32e2802eea7e7ade)
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/samr.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index d4f125234f..d77beccf98 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -332,7 +332,7 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
union samr_UserInfo u;
BOOL ret = True;
uint8 session_key[16];
- char *newpass = samr_rand_pass(mem_ctx);
+ char *newpass = samr_rand_pass(mem_ctx);
s.in.handle = handle;
s.in.info = &u;
@@ -364,6 +364,57 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return ret;
}
+
+static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle, char **password)
+{
+ NTSTATUS status;
+ struct samr_SetUserInfo s;
+ union samr_UserInfo u;
+ BOOL ret = True;
+ uint8 session_key[16];
+ uint8 confounder[16];
+ char *newpass = samr_rand_pass(mem_ctx);
+ struct MD5Context ctx;
+
+ s.in.handle = handle;
+ s.in.info = &u;
+ s.in.level = 26;
+
+ encode_pw_buffer(u.info26.password.data, newpass, STR_UNICODE);
+ u.info26.pw_len = strlen(newpass);
+
+ status = dcerpc_fetch_session_key(p, session_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("SetUserInfo level %u - no session key - %s\n",
+ s.in.level, nt_errstr(status));
+ return False;
+ }
+
+ generate_random_buffer((unsigned char *)confounder, 16, False);
+
+ MD5Init(&ctx);
+ MD5Update(&ctx, confounder, 16);
+ MD5Update(&ctx, session_key, 16);
+ MD5Final(session_key, &ctx);
+
+ SamOEMhash(u.info26.password.data, session_key, 516);
+ memcpy(&u.info26.password.data[516], confounder, 16);
+
+ printf("Testing SetUserInfo level 26 (set password ex)\n");
+
+ status = dcerpc_samr_SetUserInfo(p, mem_ctx, &s);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("SetUserInfo level %u failed - %s\n",
+ s.in.level, nt_errstr(status));
+ ret = False;
+ } else {
+ *password = newpass;
+ }
+
+ return ret;
+}
+
static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -1199,6 +1250,10 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret = False;
}
+ if (!test_SetUserPassEx(p, mem_ctx, user_handle, &password)) {
+ ret = False;
+ }
+
/* we change passwords twice - this has the effect of verifying
they were changed correctly */
if (!test_ChangePassword(p, mem_ctx, domain_handle, &password)) {