Hans Leidekker : ntdsapi: Implement DsClientMakeSpnForTargetServerW.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Aug 6 10:15:43 CDT 2015


Module: wine
Branch: master
Commit: 2655ca253825775ea2164bef5a35979ad2c047bc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2655ca253825775ea2164bef5a35979ad2c047bc

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Aug  5 17:13:08 2015 +0200

ntdsapi: Implement DsClientMakeSpnForTargetServerW.

---

 dlls/ntdsapi/ntdsapi.c       | 26 ++++++++++++++++++++++++++
 dlls/ntdsapi/ntdsapi.spec    |  2 +-
 dlls/ntdsapi/tests/ntdsapi.c | 31 +++++++++++++++++++++++++++++++
 include/ntdsapi.h            |  4 ++++
 4 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdsapi/ntdsapi.c b/dlls/ntdsapi/ntdsapi.c
index 4ca3b09..2a313ec 100644
--- a/dlls/ntdsapi/ntdsapi.c
+++ b/dlls/ntdsapi/ntdsapi.c
@@ -203,3 +203,29 @@ DWORD WINAPI DsServerRegisterSpnW(DS_SPN_WRITE_OP operation, LPCWSTR ServiceClas
             debugstr_w(ServiceClass), debugstr_w(UserObjectDN));
     return ERROR_CALL_NOT_IMPLEMENTED;
 }
+
+DWORD WINAPI DsClientMakeSpnForTargetServerW(LPCWSTR class, LPCWSTR name, DWORD *buflen, LPWSTR buf)
+{
+    DWORD len;
+    WCHAR *p;
+
+    TRACE("(%s,%s,%p,%p)\n", debugstr_w(class), debugstr_w(name), buflen, buf);
+
+    if (!class || !name || !buflen) return ERROR_INVALID_PARAMETER;
+
+    len = strlenW(class) + 1 + strlenW(name) + 1;
+    if (*buflen < len)
+    {
+        *buflen = len;
+        return ERROR_BUFFER_OVERFLOW;
+    }
+    *buflen = len;
+
+    memcpy(buf, class, strlenW(class) * sizeof(WCHAR));
+    p = buf + strlenW(class);
+    *p++ = '/';
+    memcpy(p, name, strlenW(name) * sizeof(WCHAR));
+    buf[len] = 0;
+
+    return ERROR_SUCCESS;
+}
diff --git a/dlls/ntdsapi/ntdsapi.spec b/dlls/ntdsapi/ntdsapi.spec
index b3ed8be..925cb71 100644
--- a/dlls/ntdsapi/ntdsapi.spec
+++ b/dlls/ntdsapi/ntdsapi.spec
@@ -7,7 +7,7 @@
 @ stub DsBindWithSpnA
 @ stub DsBindWithSpnW
 @ stub DsClientMakeSpnForTargetServerA
-@ stub DsClientMakeSpnForTargetServerW
+@ stdcall DsClientMakeSpnForTargetServerW(wstr wstr ptr ptr)
 @ stub DsCrackNamesA
 @ stub DsCrackNamesW
 @ stub DsCrackSpn2A
diff --git a/dlls/ntdsapi/tests/ntdsapi.c b/dlls/ntdsapi/tests/ntdsapi.c
index 8290ed2..3d95d1b 100644
--- a/dlls/ntdsapi/tests/ntdsapi.c
+++ b/dlls/ntdsapi/tests/ntdsapi.c
@@ -84,7 +84,38 @@ static void test_DsMakeSpn(void)
     ok(spn_length == lstrlenW(wszSpn5) + 1, "DsMakeSpnW should have returned spn_length of %d instead of %d\n", lstrlenW(wszSpn5) + 1, spn_length);
 }
 
+static void test_DsClientMakeSpnForTargetServer(void)
+{
+    static const WCHAR classW[] = {'c','l','a','s','s',0};
+    static const WCHAR hostW[] = {'h','o','s','t','.','d','o','m','a','i','n',0};
+    static const WCHAR resultW[] = {'c','l','a','s','s','/','h','o','s','t','.','d','o','m','a','i','n',0};
+    DWORD ret, len;
+    WCHAR buf[256];
+
+    ret = DsClientMakeSpnForTargetServerW( NULL, NULL, NULL, NULL );
+    ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
+
+    ret = DsClientMakeSpnForTargetServerW( classW, NULL, NULL, NULL );
+    ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
+
+    ret = DsClientMakeSpnForTargetServerW( classW, hostW, NULL, NULL );
+    ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
+
+    len = 0;
+    ret = DsClientMakeSpnForTargetServerW( classW, hostW, &len, NULL );
+    ok( ret == ERROR_BUFFER_OVERFLOW, "got %u\n", ret );
+    ok( len == lstrlenW(resultW) + 1, "got %u\n", len );
+
+    len = sizeof(buf)/sizeof(buf[0]);
+    buf[0] = 0;
+    ret = DsClientMakeSpnForTargetServerW( classW, hostW, &len, buf );
+    ok( ret == ERROR_SUCCESS, "got %u\n", ret );
+    ok( len == lstrlenW(resultW) + 1, "got %u\n", len );
+    ok( !lstrcmpW( buf, resultW ), "wrong data\n" );
+}
+
 START_TEST( ntdsapi )
 {
     test_DsMakeSpn();
+    test_DsClientMakeSpnForTargetServer();
 }
diff --git a/include/ntdsapi.h b/include/ntdsapi.h
index 6d2902f3..672ea63 100644
--- a/include/ntdsapi.h
+++ b/include/ntdsapi.h
@@ -25,6 +25,10 @@
 extern "C" {
 #endif
 
+DWORD WINAPI DsClientMakeSpnForTargetServerA(LPCSTR, LPCSTR, DWORD*, LPSTR);
+DWORD WINAPI DsClientMakeSpnForTargetServerW(LPCWSTR, LPCWSTR, DWORD*, LPWSTR);
+#define DsClientMakeSpnForTargetServer WINELIB_NAME_AW(DsClientMakeSpnForTargetServer)
+
 DWORD WINAPI DsMakeSpnA(LPCSTR, LPCSTR, LPCSTR, USHORT, LPCSTR, DWORD*, LPSTR);
 DWORD WINAPI DsMakeSpnW(LPCWSTR, LPCWSTR, LPCWSTR, USHORT, LPCWSTR, DWORD*, LPWSTR);
 #define DsMakeSpn WINELIB_NAME_AW(DsMakeSpn)




More information about the wine-cvs mailing list