2012-10-29 04:55:19 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/winpr.h>
|
|
|
|
#include <winpr/tchar.h>
|
|
|
|
#include <winpr/dsparse.h>
|
|
|
|
|
|
|
|
LPCTSTR testServiceClass = _T("HTTP");
|
|
|
|
LPCTSTR testServiceName = _T("LAB1-W2K8R2-GW.lab1.awake.local");
|
2012-10-29 06:16:21 +04:00
|
|
|
LPCTSTR testSpn = _T("HTTP/LAB1-W2K8R2-GW.lab1.awake.local");
|
2012-10-29 04:55:19 +04:00
|
|
|
|
|
|
|
int TestDsMakeSpn(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
LPTSTR Spn;
|
|
|
|
DWORD status;
|
|
|
|
DWORD SpnLength;
|
|
|
|
|
|
|
|
SpnLength = -1;
|
|
|
|
status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
|
|
|
|
|
|
|
|
if (status != ERROR_INVALID_PARAMETER)
|
|
|
|
{
|
|
|
|
_tprintf(_T("DsMakeSpn: expected ERROR_INVALID_PARAMETER\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SpnLength = 0;
|
|
|
|
status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
|
|
|
|
|
|
|
|
if (status != ERROR_BUFFER_OVERFLOW)
|
|
|
|
{
|
|
|
|
_tprintf(_T("DsMakeSpn: expected ERROR_BUFFER_OVERFLOW\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SpnLength != 37)
|
|
|
|
{
|
2014-05-09 02:02:02 +04:00
|
|
|
_tprintf(_T("DsMakeSpn: SpnLength mismatch: Actual: %d, Expected: %d\n"), SpnLength, 37);
|
2012-10-29 04:55:19 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SpnLength includes null terminator */
|
|
|
|
Spn = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
|
|
|
|
|
|
|
|
status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, Spn);
|
|
|
|
|
|
|
|
if (status != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
_tprintf(_T("DsMakeSpn: expected ERROR_SUCCESS\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-29 06:16:21 +04:00
|
|
|
if (_tcscmp(Spn, testSpn) != 0)
|
|
|
|
{
|
|
|
|
_tprintf(_T("DsMakeSpn: SPN mismatch: Actual: %s, Expected: %s\n"), Spn, testSpn);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-29 04:55:19 +04:00
|
|
|
_tprintf(_T("DsMakeSpn: %s\n"), Spn);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|