credui: Implement CredUIParseUserName.

This commit is contained in:
Rob Shearman 2007-01-26 19:54:19 +00:00 committed by Alexandre Julliard
parent 4ca5d44ce5
commit c9c328c122
2 changed files with 56 additions and 1 deletions

View File

@ -4,7 +4,7 @@
@ stdcall CredUIConfirmCredentialsW(wstr long)
@ stub CredUIInitControls
@ stub CredUIParseUserNameA
@ stub CredUIParseUserNameW
@ stdcall CredUIParseUserNameW(wstr ptr long ptr long)
@ stub CredUIPromptForCredentialsA
@ stdcall CredUIPromptForCredentialsW(ptr wstr ptr long ptr long ptr long ptr long)
@ stub CredUIReadSSOCredA

View File

@ -29,6 +29,7 @@
#include "credui_resources.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(credui);
@ -177,3 +178,57 @@ DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR pszTargetName, BOOL bConfirm)
bConfirm ? "TRUE" : "FALSE");
return ERROR_SUCCESS;
}
/******************************************************************************
* CredUIParseUserNameW [CREDUI.@]
*/
DWORD WINAPI CredUIParseUserNameW(PCWSTR pszUserName, PWSTR pszUser,
ULONG ulMaxUserChars, PWSTR pszDomain,
ULONG ulMaxDomainChars)
{
PWSTR p;
TRACE("(%s, %p, %d, %p, %d)\n", debugstr_w(pszUserName), pszUser,
ulMaxUserChars, pszDomain, ulMaxDomainChars);
if (!pszUserName || !pszUser || !ulMaxUserChars || !pszDomain ||
!ulMaxDomainChars)
return ERROR_INVALID_PARAMETER;
/* FIXME: handle marshaled credentials */
p = strchrW(pszUserName, '\\');
if (p)
{
if (p - pszUserName > ulMaxDomainChars - 1)
return ERROR_INSUFFICIENT_BUFFER;
if (strlenW(p + 1) > ulMaxUserChars - 1)
return ERROR_INSUFFICIENT_BUFFER;
strcpyW(pszUser, p + 1);
memcpy(pszDomain, pszUserName, (p - pszUserName)*sizeof(WCHAR));
pszDomain[p - pszUserName] = '\0';
return ERROR_SUCCESS;
}
p = strrchrW(pszUserName, '@');
if (p)
{
if (p + 1 - pszUserName > ulMaxUserChars - 1)
return ERROR_INSUFFICIENT_BUFFER;
if (strlenW(p + 1) > ulMaxDomainChars - 1)
return ERROR_INSUFFICIENT_BUFFER;
strcpyW(pszDomain, p + 1);
memcpy(pszUser, pszUserName, (p - pszUserName)*sizeof(WCHAR));
pszUser[p - pszUserName] = '\0';
return ERROR_SUCCESS;
}
if (strlenW(pszUserName) > ulMaxUserChars - 1)
return ERROR_INSUFFICIENT_BUFFER;
strcpyW(pszUser, pszUserName);
pszDomain[0] = '\0';
return ERROR_SUCCESS;
}