summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-03-13 06:43:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:11:03 -0500
commitd830fcd7d183c9c1756ffdf72cf28f0a90307b85 (patch)
treeb125df7c75f6fd18ae74a4cb005b2219088d6e16
parentd93d5f967f3f3e8c0061bcfc213be0a9278b0372 (diff)
downloadsamba-d830fcd7d183c9c1756ffdf72cf28f0a90307b85.tar.gz
samba-d830fcd7d183c9c1756ffdf72cf28f0a90307b85.tar.bz2
samba-d830fcd7d183c9c1756ffdf72cf28f0a90307b85.zip
r5783: Test renaming of accounts in the RPC-SAMR test, and add support into
the SAMR server. Andrew Bartlett (This used to be commit fd748f9d2f8f354f76587d92b94de83bffe1c6dc)
-rw-r--r--source4/librpc/idl/samr.idl3
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c16
-rw-r--r--source4/torture/rpc/samr.c48
3 files changed, 49 insertions, 18 deletions
diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl
index e8b269dc66..9815a897b7 100644
--- a/source4/librpc/idl/samr.idl
+++ b/source4/librpc/idl/samr.idl
@@ -665,7 +665,8 @@
/* this defines the bits used for fields_present in info21 */
typedef [bitmap32bit] bitmap {
- SAMR_FIELD_NAME = 0x00000002,
+ SAMR_FIELD_ACCOUNT_NAME = 0x00000001,
+ SAMR_FIELD_FULL_NAME = 0x00000002,
SAMR_FIELD_DESCRIPTION = 0x00000010,
SAMR_FIELD_COMMENT = 0x00000020,
SAMR_FIELD_LOGON_SCRIPT = 0x00000100,
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index 518ad02f4c..f8391aac7c 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -2635,6 +2635,10 @@ static NTSTATUS samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX
SET_STRING(msg, info6.full_name.string, "displayName");
break;
+ case 7:
+ SET_STRING(msg, info7.account_name.string, "samAccountName");
+ break;
+
case 8:
SET_STRING(msg, info8.full_name.string, "displayName");
break;
@@ -2674,7 +2678,9 @@ static NTSTATUS samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX
case 21:
#define IFSET(bit) if (bit & r->in.info->info21.fields_present)
- IFSET(SAMR_FIELD_NAME)
+ IFSET(SAMR_FIELD_ACCOUNT_NAME)
+ SET_STRING(msg, info21.account_name.string, "samAccountName");
+ IFSET(SAMR_FIELD_FULL_NAME)
SET_STRING(msg, info21.full_name.string, "displayName");
IFSET(SAMR_FIELD_DESCRIPTION)
SET_STRING(msg, info21.description.string, "description");
@@ -2704,7 +2710,9 @@ static NTSTATUS samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX
case 23:
#define IFSET(bit) if (bit & r->in.info->info23.info.fields_present)
- IFSET(SAMR_FIELD_NAME)
+ IFSET(SAMR_FIELD_ACCOUNT_NAME)
+ SET_STRING(msg, info23.info.account_name.string, "samAccountName");
+ IFSET(SAMR_FIELD_FULL_NAME)
SET_STRING(msg, info23.info.full_name.string, "displayName");
IFSET(SAMR_FIELD_DESCRIPTION)
SET_STRING(msg, info23.info.description.string, "description");
@@ -2756,7 +2764,9 @@ static NTSTATUS samr_SetUserInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX
case 25:
#define IFSET(bit) if (bit & r->in.info->info25.info.fields_present)
- IFSET(SAMR_FIELD_NAME)
+ IFSET(SAMR_FIELD_ACCOUNT_NAME)
+ SET_STRING(msg, info25.info.account_name.string, "samAccountName");
+ IFSET(SAMR_FIELD_FULL_NAME)
SET_STRING(msg, info25.info.full_name.string, "displayName");
IFSET(SAMR_FIELD_DESCRIPTION)
SET_STRING(msg, info25.info.description.string, "description");
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index 49c18ea0f4..95bbfe8681 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -28,8 +28,8 @@
#define TEST_ACCOUNT_NAME "samrtorturetest"
#define TEST_ALIASNAME "samrtorturetestalias"
#define TEST_GROUPNAME "samrtorturetestgroup"
-#define TEST_MACHINENAME "samrtorturetestmach$"
-#define TEST_DOMAINNAME "samrtorturetestdom$"
+#define TEST_MACHINENAME "samrtestmach$"
+#define TEST_DOMAINNAME "samrtestdom$"
static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
@@ -162,7 +162,8 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, uint32_t base_acct_flags)
+ struct policy_handle *handle, uint32_t base_acct_flags,
+ const char *base_account_name)
{
NTSTATUS status;
struct samr_SetUserInfo s;
@@ -171,6 +172,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_QueryUserInfo q0;
union samr_UserInfo u;
BOOL ret = True;
+ const char *test_account_name;
uint32_t user_extra_flags = 0;
if (base_acct_flags == ACB_NORMAL) {
@@ -191,24 +193,24 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
#define TESTCALL(call, r) \
status = dcerpc_samr_ ##call(p, mem_ctx, &r); \
if (!NT_STATUS_IS_OK(status)) { \
- printf(#call " level %u failed - %s (line %d)\n", \
- r.in.level, nt_errstr(status), __LINE__); \
+ printf(#call " level %u failed - %s (%s)\n", \
+ r.in.level, nt_errstr(status), __location__); \
ret = False; \
break; \
}
#define STRING_EQUAL(s1, s2, field) \
if ((s1 && !s2) || (s2 && !s1) || strcmp(s1, s2)) { \
- printf("Failed to set %s to '%s' (line %d)\n", \
- #field, s2, __LINE__); \
+ printf("Failed to set %s to '%s' (%s)\n", \
+ #field, s2, __location__); \
ret = False; \
break; \
}
#define INT_EQUAL(i1, i2, field) \
if (i1 != i2) { \
- printf("Failed to set %s to 0x%x - got 0x%x (line %d)\n", \
- #field, i2, i1, __LINE__); \
+ printf("Failed to set %s to 0x%x - got 0x%x (%s)\n", \
+ #field, i2, i1, __location__); \
ret = False; \
break; \
}
@@ -278,6 +280,22 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
TEST_USERINFO_STRING(21, comment, 21, comment, "xx21-21 comment",
SAMR_FIELD_COMMENT);
+ test_account_name = talloc_asprintf(mem_ctx, "%sxx7-1", base_account_name);
+ TEST_USERINFO_STRING(7, account_name, 1, account_name, base_account_name, 0);
+ test_account_name = talloc_asprintf(mem_ctx, "%sxx7-3", base_account_name);
+ TEST_USERINFO_STRING(7, account_name, 3, account_name, base_account_name, 0);
+ test_account_name = talloc_asprintf(mem_ctx, "%sxx7-5", base_account_name);
+ TEST_USERINFO_STRING(7, account_name, 5, account_name, base_account_name, 0);
+ test_account_name = talloc_asprintf(mem_ctx, "%sxx7-6", base_account_name);
+ TEST_USERINFO_STRING(7, account_name, 6, account_name, base_account_name, 0);
+ test_account_name = talloc_asprintf(mem_ctx, "%sxx7-7", base_account_name);
+ TEST_USERINFO_STRING(7, account_name, 7, account_name, base_account_name, 0);
+ test_account_name = talloc_asprintf(mem_ctx, "%sxx7-21", base_account_name);
+ TEST_USERINFO_STRING(7, account_name, 21, account_name, base_account_name, 0);
+ test_account_name = base_account_name;
+ TEST_USERINFO_STRING(21, account_name, 21, account_name, base_account_name,
+ SAMR_FIELD_ACCOUNT_NAME);
+
TEST_USERINFO_STRING(6, full_name, 1, full_name, "xx6-1 full_name", 0);
TEST_USERINFO_STRING(6, full_name, 3, full_name, "xx6-3 full_name", 0);
TEST_USERINFO_STRING(6, full_name, 5, full_name, "xx6-5 full_name", 0);
@@ -286,7 +304,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
TEST_USERINFO_STRING(6, full_name, 21, full_name, "xx6-21 full_name", 0);
TEST_USERINFO_STRING(8, full_name, 21, full_name, "xx8-21 full_name", 0);
TEST_USERINFO_STRING(21, full_name, 21, full_name, "xx21-21 full_name",
- SAMR_FIELD_NAME);
+ SAMR_FIELD_FULL_NAME);
TEST_USERINFO_STRING(11, logon_script, 3, logon_script, "xx11-3 logon_script", 0);
TEST_USERINFO_STRING(11, logon_script, 5, logon_script, "xx11-5 logon_script", 0);
@@ -1265,7 +1283,8 @@ static BOOL test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem
static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, uint32_t base_acct_flags)
+ struct policy_handle *handle, uint32_t base_acct_flags,
+ const char *base_acct_name)
{
BOOL ret = True;
@@ -1281,7 +1300,8 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret = False;
}
- if (!test_SetUserInfo(p, mem_ctx, handle, base_acct_flags)) {
+ if (!test_SetUserInfo(p, mem_ctx, handle, base_acct_flags,
+ base_acct_name)) {
ret = False;
}
@@ -1604,7 +1624,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
}
- if (!test_user_ops(p, mem_ctx, user_handle, acct_flags)) {
+ if (!test_user_ops(p, mem_ctx, user_handle, acct_flags, name.string)) {
ret = False;
}
@@ -1755,7 +1775,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
}
- if (!test_user_ops(p, mem_ctx, &user_handle, acct_flags)) {
+ if (!test_user_ops(p, mem_ctx, &user_handle, acct_flags, name.string)) {
ret = False;
}