With an AD DC, wbcListUsers returns the users in the DOMAIN SEPARATOR
USERNAME format. The test then calls wbcLookupName with the domain name
and the previous string (including domain and separator) as username.
Fix this by passing the correct username and adding some additional
checks.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13312
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
char *name = NULL;
char *sid_string = NULL;
wbcErr ret = false;
char *name = NULL;
char *sid_string = NULL;
wbcErr ret = false;
torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
"%s", "wbcInterfaceDetails failed");
torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
"%s", "wbcInterfaceDetails failed");
ret,
fail,
"Failed to allocate domain_name");
ret,
fail,
"Failed to allocate domain_name");
+ separator = details->winbind_separator;
wbcFreeMemory(details);
details = NULL;
wbcFreeMemory(details);
details = NULL;
struct wbcDomainSid sid;
enum wbcSidType name_type;
uint32_t num_sids;
struct wbcDomainSid sid;
enum wbcSidType name_type;
uint32_t num_sids;
+ const char *user;
+ char *c;
+
+ c = strchr(users[i], separator);
+
+ if (c == NULL) {
+ /*
+ * NT4 DC
+ * user name does not contain DOMAIN SEPARATOR prefix.
+ */
+
+ user = users[i];
+ } else {
+ /*
+ * AD DC
+ * user name starts with DOMAIN SEPARATOR prefix.
+ */
+ const char *dom;
+
+ *c = '\0';
+ dom = users[i];
+ user = c + 1;
+
+ torture_assert_str_equal_goto(tctx, dom, domain_name,
+ ret, fail, "Domain part "
+ "of user name does not "
+ "match domain name.\n");
+ }
torture_assert_wbc_ok_goto_fail(tctx,
torture_assert_wbc_ok_goto_fail(tctx,
- wbcLookupName(domain_name, users[i], &sid, &name_type),
+ wbcLookupName(domain_name, user,
+ &sid, &name_type),
"wbcLookupName of %s failed",
users[i]);
torture_assert_int_equal_goto(tctx,
"wbcLookupName of %s failed",
users[i]);
torture_assert_int_equal_goto(tctx,