ntdsapi: Implement DsMakeSpnW.

This commit is contained in:
Rob Shearman 2008-01-24 18:37:10 +00:00 committed by Alexandre Julliard
parent 5db45041c6
commit dbcac92819
3 changed files with 79 additions and 15 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = ntdsapi.dll
IMPORTLIB = libntdsapi.$(IMPLIBEXT)
IMPORTS = kernel32
IMPORTS = user32 kernel32
C_SRCS = \
ntdsapi.c

View File

@ -21,8 +21,10 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winuser.h"
#include "ntdsapi.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(ntdsapi);
@ -52,11 +54,85 @@ DWORD WINAPI DsMakeSpnW(LPCWSTR svc_class, LPCWSTR svc_name,
LPCWSTR inst_name, USHORT inst_port,
LPCWSTR ref, DWORD *spn_length, LPWSTR spn)
{
FIXME("(%s,%s,%s,%d,%s,%p,%p): stub!\n", debugstr_w(svc_class),
DWORD new_spn_length;
INT len;
LPWSTR p;
TRACE("(%s,%s,%s,%d,%s,%p,%p)\n", debugstr_w(svc_class),
debugstr_w(svc_name), debugstr_w(inst_name), inst_port,
debugstr_w(ref), spn_length, spn);
return ERROR_CALL_NOT_IMPLEMENTED;
if (!svc_class || !svc_name)
return ERROR_INVALID_PARAMETER;
new_spn_length = strlenW(svc_class) + 1 /* for '/' */ + 1 /* for terminating '\0' */;
if (inst_name)
new_spn_length += strlenW(inst_name);
else
new_spn_length += strlenW(svc_name);
if (inst_port)
{
USHORT n = inst_port;
new_spn_length += 1 /* for ':' */;
do
{
n /= 10;
new_spn_length++;
} while (n != 0);
}
if (inst_name)
new_spn_length += 1 /* for '/' */ + strlenW(svc_name);
if (*spn_length < new_spn_length)
{
*spn_length = new_spn_length;
return ERROR_BUFFER_OVERFLOW;
}
*spn_length = new_spn_length;
p = spn;
len = strlenW(svc_class);
memcpy(p, svc_class, len * sizeof(WCHAR));
p += len;
*p = '/';
p++;
if (inst_name)
{
len = strlenW(inst_name);
memcpy(p, inst_name, len * sizeof(WCHAR));
p += len;
*p = '\0';
}
else
{
len = strlenW(svc_name);
memcpy(p, svc_name, len * sizeof(WCHAR));
p += len;
*p = '\0';
}
if (inst_port)
{
static const WCHAR percentU[] = {'%','u',0};
*p = ':';
p++;
wsprintfW(p, percentU, inst_port);
p += strlenW(p);
}
if (inst_name)
{
*p = '/';
p++;
len = strlenW(svc_name);
memcpy(p, svc_name, len * sizeof(WCHAR));
p += len;
*p = '\0';
}
TRACE("spn = %s\n", debugstr_w(spn));
return ERROR_SUCCESS;
}
DWORD WINAPI DsMakeSpnA(LPCSTR svc_class, LPCSTR svc_name,

View File

@ -54,53 +54,41 @@ static void test_DsMakeSpn(void)
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(NULL, NULL, NULL, 0, NULL, &spn_length, spn);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "DsMakeSpnW should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret);
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(NULL, wszServiceHost, NULL, 0, NULL, &spn_length, spn);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "DsMakeSpnW should have failed with ERROR_INVALID_PARAMETER instead of %d\n", ret);
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(wszServiceClass, wszServiceHost, NULL, 0, NULL, &spn_length, spn);
todo_wine {
ok(ret == ERROR_SUCCESS, "DsMakeSpnW should have succeeded instead of failing with %d\n", ret);
ok(!lstrcmpW(spn, wszSpn1), "DsMakeSpnW returned unexpected SPN %s\n", wine_dbgstr_w(spn));
ok(spn_length == lstrlenW(wszSpn1) + 1, "DsMakeSpnW should have returned spn_length of %d instead of %d\n", lstrlenW(wszSpn1) + 1, spn_length);
}
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(wszServiceClass, wszServiceHost, wszInstanceName, 0, NULL, &spn_length, spn);
todo_wine {
ok(ret == ERROR_SUCCESS, "DsMakeSpnW should have succeeded instead of failing with %d\n", ret);
ok(!lstrcmpW(spn, wszSpn2), "DsMakeSpnW returned unexpected SPN %s\n", wine_dbgstr_w(spn));
ok(spn_length == lstrlenW(wszSpn2) + 1, "DsMakeSpnW should have returned spn_length of %d instead of %d\n", lstrlenW(wszSpn2) + 1, spn_length);
}
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(wszServiceClass, wszServiceHost, wszInstanceName, 555, NULL, &spn_length, spn);
todo_wine {
ok(ret == ERROR_SUCCESS, "DsMakeSpnW should have succeeded instead of failing with %d\n", ret);
ok(!lstrcmpW(spn, wszSpn3), "DsMakeSpnW returned unexpected SPN %s\n", wine_dbgstr_w(spn));
ok(spn_length == lstrlenW(wszSpn3) + 1, "DsMakeSpnW should have returned spn_length of %d instead of %d\n", lstrlenW(wszSpn3) + 1, spn_length);
}
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(wszServiceClass, wszServiceHost, wszInstanceName, 555, wszReferrer, &spn_length, spn);
todo_wine {
ok(ret == ERROR_SUCCESS, "DsMakeSpnW should have succeeded instead of failing with %d\n", ret);
ok(!lstrcmpW(spn, wszSpn4), "DsMakeSpnW returned unexpected SPN %s\n", wine_dbgstr_w(spn));
ok(spn_length == lstrlenW(wszSpn4) + 1, "DsMakeSpnW should have returned spn_length of %d instead of %d\n", lstrlenW(wszSpn4) + 1, spn_length);
}
spn_length = sizeof(spn)/sizeof(spn[0]);
ret = DsMakeSpnW(wszServiceClass, wszServiceHost, NULL, 555, wszReferrer, &spn_length, spn);
todo_wine {
ok(ret == ERROR_SUCCESS, "DsMakeSpnW should have succeeded instead of failing with %d\n", ret);
ok(!lstrcmpW(spn, wszSpn5), "DsMakeSpnW returned unexpected SPN %s\n", wine_dbgstr_w(spn));
ok(spn_length == lstrlenW(wszSpn5) + 1, "DsMakeSpnW should have returned spn_length of %d instead of %d\n", lstrlenW(wszSpn5) + 1, spn_length);
}
}
START_TEST( ntdsapi )