Returns an XtfNetworkCredentials object that contains the list of credentials currently stored on the console.
HRESULT XtfGetCredentialInfoList(
LPCWSTR address,
XtfNetworkCredentials *credentialInfo
)
address
Type: LPCWSTR
[in] Address of the console.
credentialInfo
Type: XtfNetworkCredentials *
[out] An XtfNetworkCredentials object that contains the list of credentials currently stored on the console.
Type: HRESULT
A return value of S_OK indicates the function succeeded and that credential information can be retrieved from the credentialInfo object. Any other value indicates an unexpected error occurred.
Use XtfAddCredential to add credentials. Use XtfRemoveCredential to remove credentials. Use XtfGetCredentialInfoList, XtfGetCredentialCount, XtfGetCredentialServerName, and XtfGetCredentialUserName to enumerate the current list of stored credentials. Use XtfCloseCredentialInfoList to free the XtfNetworkCredentials returned by XtfGetCredentialInfoList.
Note XtfGetCredentialInfoList retrieves all of the information from the console. XtfGetCredentialServerName, and XtfGetCredentialUserName simply iterate across that retrieved information.
Note When you have retrieved the values you needed, use XtfCloseCredentialInfoList to free resources associated with the returned XtfNetworkCredentials object.
Note When the console is rebooted all stored credentials are lost and must be added again.
HRESULT hr = S_OK;
PCWSTR consoleAddress = L"190.167.10.182";
XtfNetworkCredentials credentialInfo = nullptr;
UINT32 count = 0;
PWSTR pServerNameBuffer = nullptr;
PWSTR pUserNameBuffer = nullptr;
UINT32 bufferSize = 0;
hr = XtfAddCredential(consoleAddress, L"devpc001", L"devpc001\\test", L"test");
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfAddCredential failed 0x%x", hr);
return hr;
}
hr = XtfAddCredential(consoleAddress, L"devpc002", L"devpc002\\test1", L"test1");
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfAddCredential failed 0x%x", hr);
return hr;
}
hr = XtfGetCredentialInfoList(consoleAddress, &credentialInfo);
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfGetCredentialInfoList failed 0x%x", hr);
return hr;
}
hr = XtfGetCredentialInfoCount(credentialInfo, &count);
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfGetCredentialInfoCount failed 0x%x", hr);
return hr;
}
wprintf(L"\n\n*** List of Users:");
wprintf(L"\n\t*** Number of users: %d", count);
for (UINT32 i=0; i < count ; i++)
{
bufferSize=0;
hr = XtfGetCredentialServerName(credentialInfo, i, nullptr, &bufferSize);
if (hr != HRESULT_FROM_WIN32(ERROR_MORE_DATA))
{
wprintf(L"\n\n*** XtfGetCredentialServerName failed 0x%x", hr);
return hr;
}
pServerNameBuffer = new WCHAR[bufferSize];
hr = XtfGetCredentialServerName(credentialInfo, i, pServerNameBuffer, &bufferSize);
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfGetCredentialServerName failed 0x%x", hr);
return hr;
}
bufferSize=0;
hr = XtfGetCredentialUserName(credentialInfo, i, nullptr, &bufferSize);
if (hr != HRESULT_FROM_WIN32(ERROR_MORE_DATA))
{
wprintf(L"\n\n*** XtfGetCredentialUserName failed 0x%x", hr);
return hr;
}
pUserNameBuffer = new WCHAR[bufferSize];
hr = XtfGetCredentialUserName(credentialInfo, i, pUserNameBuffer, &bufferSize);
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfGetCredentialUserName failed 0x%x", hr);
return hr;
}
wprintf(L"\n\t Server: %ls, User: %ls", pServerNameBuffer, pUserNameBuffer);
delete[] pServerNameBuffer;
delete[] pUserNameBuffer;
}
XtfCloseCredentialInfoList(credentialInfo);
hr = XtfRemoveCredential(consoleAddress, L"devpc001");
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfRemoveCredential failed 0x%x", hr);
return hr;
}
hr = XtfRemoveCredential(consoleAddress, L"devpc002");
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfRemoveCredential failed 0x%x", hr);
return hr;
}
hr = XtfGetCredentialInfoList(consoleAddress, &credentialInfo);
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfGetCredentialInfoList failed 0x%x", hr);
return hr;
}
hr = XtfGetCredentialInfoCount(credentialInfo, &count);
if (FAILED(hr))
{
wprintf(L"\n\n*** XtfGetCredentialInfoCount failed 0x%x", hr);
return hr;
}
wprintf(L"\n\n*** Number of users: %d", count);
XtfCloseCredentialInfoList(credentialInfo);
wprintf(L"\n\n");
return hr;
Header: Declared in XtfApi.h.
Library: Use XtfApi.lib.