[winpr,sspi] remove sspi_SetAuthIdentityWithUnicodePassword
the function is useless as we always use the SetAuthIdentityW API now
This commit is contained in:
parent
91056dc96c
commit
13c025e04c
@ -385,10 +385,19 @@ static BOOL nla_client_setup_identity(rdpNla* nla)
|
||||
|
||||
if (settings->RedirectionPassword && (settings->RedirectionPasswordLength > 0))
|
||||
{
|
||||
if (sspi_SetAuthIdentityWithUnicodePassword(
|
||||
nla->identity, settings->Username, settings->Domain,
|
||||
size_t userLength = 0;
|
||||
size_t domainLength = 0;
|
||||
WCHAR* user =
|
||||
freerdp_settings_get_string_as_utf16(settings, FreeRDP_Username, &userLength);
|
||||
WCHAR* domain =
|
||||
freerdp_settings_get_string_as_utf16(settings, FreeRDP_Domain, &domainLength);
|
||||
const int rc = sspi_SetAuthIdentityWithLengthW(
|
||||
nla->identity, user, userLength, domain, domainLength,
|
||||
(const WCHAR*)settings->RedirectionPassword,
|
||||
settings->RedirectionPasswordLength / sizeof(WCHAR) - 1) < 0)
|
||||
settings->RedirectionPasswordLength / sizeof(WCHAR) - 1);
|
||||
free(user);
|
||||
free(domain);
|
||||
if (rc < 0)
|
||||
return FALSE;
|
||||
|
||||
usePassword = FALSE;
|
||||
|
@ -1421,9 +1421,6 @@ extern "C"
|
||||
const WCHAR* user, size_t userLen,
|
||||
const WCHAR* domain, size_t domainLen,
|
||||
const WCHAR* password, size_t passwordLen);
|
||||
WINPR_API int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity,
|
||||
const char* user, const char* domain,
|
||||
LPCWSTR password, ULONG passwordLength);
|
||||
WINPR_API UINT32 sspi_GetAuthIdentityVersion(const void* identity);
|
||||
WINPR_API UINT32 sspi_GetAuthIdentityFlags(const void* identity);
|
||||
WINPR_API BOOL sspi_GetAuthIdentityUserDomainW(const void* identity, const WCHAR** pUser,
|
||||
|
@ -333,9 +333,9 @@ static BOOL copy(WCHAR** dst, UINT32* dstLen, const WCHAR* what, size_t len)
|
||||
{
|
||||
WINPR_ASSERT(dst);
|
||||
WINPR_ASSERT(dstLen);
|
||||
WINPR_ASSERT(what);
|
||||
WINPR_ASSERT(len > 0);
|
||||
WINPR_ASSERT(_wcsnlen(what, len) == len);
|
||||
|
||||
*dst = NULL;
|
||||
*dstLen = 0;
|
||||
|
||||
*dst = calloc(sizeof(WCHAR), len + 1);
|
||||
if (!*dst)
|
||||
@ -353,75 +353,46 @@ int sspi_SetAuthIdentityWithLengthW(SEC_WINNT_AUTH_IDENTITY* identity, const WCH
|
||||
sspi_FreeAuthIdentity(identity);
|
||||
identity->Flags &= ~SEC_WINNT_AUTH_IDENTITY_ANSI;
|
||||
identity->Flags |= SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||
if (user && userLen > 0)
|
||||
{
|
||||
|
||||
if (!copy(&identity->User, &identity->UserLength, user, userLen))
|
||||
return -1;
|
||||
}
|
||||
if (domain && domainLen > 0)
|
||||
{
|
||||
|
||||
if (!copy(&identity->Domain, &identity->DomainLength, domain, domainLen))
|
||||
return -1;
|
||||
}
|
||||
if (password && passwordLen > 0)
|
||||
{
|
||||
|
||||
if (!copy(&identity->Password, &identity->PasswordLength, password, passwordLen))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void zfree(WCHAR* str, size_t len)
|
||||
{
|
||||
if (str)
|
||||
memset(str, 0, len * sizeof(WCHAR));
|
||||
free(str);
|
||||
}
|
||||
|
||||
int sspi_SetAuthIdentityA(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, const char* domain,
|
||||
const char* password)
|
||||
{
|
||||
int rc;
|
||||
size_t unicodeUserLenW = 0;
|
||||
size_t unicodeDomainLenW = 0;
|
||||
size_t unicodePasswordLenW = 0;
|
||||
LPWSTR unicodeUser = ConvertUtf8ToWCharAlloc(user, &unicodeUserLenW);
|
||||
LPWSTR unicodeDomain = ConvertUtf8ToWCharAlloc(domain, &unicodeDomainLenW);
|
||||
LPWSTR unicodePassword = ConvertUtf8ToWCharAlloc(password, &unicodePasswordLenW);
|
||||
|
||||
const int rc = sspi_SetAuthIdentityWithUnicodePassword(identity, user, domain, unicodePassword,
|
||||
(ULONG)(unicodePasswordLenW));
|
||||
free(unicodePassword);
|
||||
rc = sspi_SetAuthIdentityWithLengthW(identity, unicodeUser, unicodeUserLenW, unicodeDomain,
|
||||
unicodeDomainLenW, unicodePassword, unicodePasswordLenW);
|
||||
|
||||
zfree(unicodeUser, unicodeUserLenW);
|
||||
zfree(unicodeDomain, unicodeDomainLenW);
|
||||
zfree(unicodePassword, unicodePasswordLenW);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int sspi_SetAuthIdentityWithUnicodePassword(SEC_WINNT_AUTH_IDENTITY* identity, const char* user,
|
||||
const char* domain, LPCWSTR password,
|
||||
ULONG passwordLength)
|
||||
{
|
||||
sspi_FreeAuthIdentity(identity);
|
||||
identity->Flags &= ~SEC_WINNT_AUTH_IDENTITY_ANSI;
|
||||
identity->Flags |= SEC_WINNT_AUTH_IDENTITY_UNICODE;
|
||||
|
||||
if (user && (strlen(user) > 0))
|
||||
{
|
||||
size_t len = 0;
|
||||
identity->User = ConvertUtf8ToWCharAlloc(user, &len);
|
||||
if (!identity->User || (len == 0) || (len > ULONG_MAX))
|
||||
return -1;
|
||||
|
||||
identity->UserLength = (ULONG)len;
|
||||
}
|
||||
|
||||
if (domain && (strlen(domain) > 0))
|
||||
{
|
||||
size_t len = 0;
|
||||
identity->Domain = ConvertUtf8ToWCharAlloc(domain, &len);
|
||||
if (!identity->Domain || (len == 0) || (len > ULONG_MAX))
|
||||
return -1;
|
||||
|
||||
identity->DomainLength = len;
|
||||
}
|
||||
|
||||
identity->Password = (UINT16*)calloc(1, (passwordLength + 1) * sizeof(WCHAR));
|
||||
|
||||
if (!identity->Password)
|
||||
return -1;
|
||||
|
||||
CopyMemory(identity->Password, password, passwordLength * sizeof(WCHAR));
|
||||
identity->PasswordLength = passwordLength;
|
||||
return 1;
|
||||
}
|
||||
|
||||
UINT32 sspi_GetAuthIdentityVersion(const void* identity)
|
||||
{
|
||||
UINT32 version;
|
||||
|
Loading…
Reference in New Issue
Block a user