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)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
_tprintf(_T("DsMakeSpn: SpnLength mismatch: Actual: %")_T(PRIu32)_T(", Expected: 37\n"), SpnLength);
|
2012-10-29 04:55:19 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SpnLength includes null terminator */
|
2017-05-30 11:46:43 +03:00
|
|
|
Spn = (LPTSTR) calloc(SpnLength, sizeof(TCHAR));
|
2015-04-03 17:21:01 +03:00
|
|
|
if (!Spn)
|
|
|
|
{
|
|
|
|
_tprintf(_T("DsMakeSpn: Unable to allocate memroy\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-29 04:55:19 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|