advapi32: Only require a domain in the username for CRED_PERSIST_ENTERPRISE credentials.
This commit is contained in:
parent
9d95d33118
commit
860c335b22
|
@ -1804,13 +1804,19 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
TRACE("Credential->Flags = 0x%08x\n", Credential->Flags);
|
||||
TRACE("Credential->Type = %u\n", Credential->Type);
|
||||
TRACE("Credential->TargetName = %s\n", debugstr_w(Credential->TargetName));
|
||||
TRACE("Credential->Comment = %s\n", debugstr_w(Credential->Comment));
|
||||
TRACE("Credential->Persist = %u\n", Credential->Persist);
|
||||
TRACE("Credential->TargetAlias = %s\n", debugstr_w(Credential->TargetAlias));
|
||||
TRACE("Credential->UserName = %s\n", debugstr_w(Credential->UserName));
|
||||
|
||||
if (Credential->Type == CRED_TYPE_DOMAIN_PASSWORD)
|
||||
{
|
||||
if (!Credential->UserName ||
|
||||
(!strchrW(Credential->UserName, '\\') && !strchrW(Credential->UserName, '@')))
|
||||
(Credential->Persist == CRED_PERSIST_ENTERPRISE &&
|
||||
(!strchrW(Credential->UserName, '\\') && !strchrW(Credential->UserName, '@'))))
|
||||
{
|
||||
ERR("bad username %s\n", debugstr_w(Credential->UserName));
|
||||
SetLastError(ERROR_BAD_USERNAME);
|
||||
|
|
|
@ -121,6 +121,47 @@ static void test_CredWriteA(void)
|
|||
ok(!ret && GetLastError() == ERROR_BAD_USERNAME,
|
||||
"CredWriteA with NULL username should have failed with ERROR_BAD_USERNAME instead of %d\n",
|
||||
GetLastError());
|
||||
|
||||
new_cred.UserName = (char *)"winetest";
|
||||
new_cred.Persist = CRED_PERSIST_LOCAL_MACHINE;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %u\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_DOMAIN_PASSWORD, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
}
|
||||
new_cred.Type = CRED_TYPE_GENERIC;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %u\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
}
|
||||
new_cred.Persist = CRED_PERSIST_SESSION;
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret, "CredWriteA failed with error %u\n", GetLastError());
|
||||
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_GENERIC, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
|
||||
new_cred.Type = CRED_TYPE_DOMAIN_PASSWORD;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(ret || broken(!ret), "CredWriteA failed with error %u\n", GetLastError());
|
||||
if (ret)
|
||||
{
|
||||
ret = pCredDeleteA(TEST_TARGET_NAME, CRED_TYPE_DOMAIN_PASSWORD, 0);
|
||||
ok(ret, "CredDeleteA failed with error %u\n", GetLastError());
|
||||
}
|
||||
new_cred.UserName = NULL;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pCredWriteA(&new_cred, 0);
|
||||
ok(!ret, "CredWriteA succeeded\n");
|
||||
ok(GetLastError() == ERROR_BAD_USERNAME, "got %u\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_CredDeleteA(void)
|
||||
|
|
Loading…
Reference in New Issue