1c2c66affSColin Finck /*
2c2c66affSColin Finck * Copyright (C) 2006 Dmitry Timoshkov
3c2c66affSColin Finck *
4c2c66affSColin Finck * This library is free software; you can redistribute it and/or
5c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
6c2c66affSColin Finck * License as published by the Free Software Foundation; either
7c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
8c2c66affSColin Finck *
9c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
10c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
11c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12c2c66affSColin Finck * Lesser General Public License for more details.
13c2c66affSColin Finck *
14c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
15c2c66affSColin Finck * License along with this library; if not, write to the Free Software
16c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17c2c66affSColin Finck */
18c2c66affSColin Finck
19c2c66affSColin Finck #include <stdarg.h>
20c2c66affSColin Finck
21f76b348cSAmine Khaldi #include "windef.h"
22f76b348cSAmine Khaldi #include "winbase.h"
23f76b348cSAmine Khaldi #include "winerror.h"
24f76b348cSAmine Khaldi #include "winuser.h"
25f76b348cSAmine Khaldi #include "ntdsapi.h"
26f76b348cSAmine Khaldi #include "wine/debug.h"
27c2c66affSColin Finck
28c2c66affSColin Finck WINE_DEFAULT_DEBUG_CHANNEL(ntdsapi);
29c2c66affSColin Finck
30c2c66affSColin Finck /*****************************************************
31c2c66affSColin Finck * DllMain
32c2c66affSColin Finck */
DllMain(HINSTANCE hinst,DWORD reason,LPVOID reserved)33c2c66affSColin Finck BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
34c2c66affSColin Finck {
35c2c66affSColin Finck TRACE("(%p, %d, %p)\n", hinst, reason, reserved);
36c2c66affSColin Finck
37c2c66affSColin Finck switch(reason)
38c2c66affSColin Finck {
39c2c66affSColin Finck case DLL_WINE_PREATTACH:
40c2c66affSColin Finck return FALSE; /* prefer native version */
41c2c66affSColin Finck
42c2c66affSColin Finck case DLL_PROCESS_ATTACH:
43c2c66affSColin Finck DisableThreadLibraryCalls( hinst );
44c2c66affSColin Finck break;
45c2c66affSColin Finck }
46c2c66affSColin Finck return TRUE;
47c2c66affSColin Finck }
48c2c66affSColin Finck
49c2c66affSColin Finck /***********************************************************************
50c2c66affSColin Finck * DsBindA (NTDSAPI.@)
51c2c66affSColin Finck */
DsBindA(LPCSTR controller,LPCSTR domain,HANDLE * handle)52c2c66affSColin Finck DWORD WINAPI DsBindA(LPCSTR controller, LPCSTR domain, HANDLE *handle)
53c2c66affSColin Finck {
54c2c66affSColin Finck FIXME("(%s,%s, %p): stub!\n", debugstr_a(controller), debugstr_a(domain), handle);
55c2c66affSColin Finck return ERROR_CALL_NOT_IMPLEMENTED;
56c2c66affSColin Finck }
57c2c66affSColin Finck
58c2c66affSColin Finck /***********************************************************************
59c2c66affSColin Finck * DsBindW (NTDSAPI.@)
60c2c66affSColin Finck */
DsBindW(LPCWSTR controller,LPCWSTR domain,HANDLE * handle)61c2c66affSColin Finck DWORD WINAPI DsBindW(LPCWSTR controller, LPCWSTR domain, HANDLE *handle)
62c2c66affSColin Finck {
63c2c66affSColin Finck FIXME("(%s,%s, %p): stub!\n", debugstr_w(controller), debugstr_w(domain), handle);
64c2c66affSColin Finck return ERROR_CALL_NOT_IMPLEMENTED;
65c2c66affSColin Finck }
66c2c66affSColin Finck
67c2c66affSColin Finck /***********************************************************************
68c2c66affSColin Finck * DsMakeSpnW (NTDSAPI.@)
69c2c66affSColin Finck */
DsMakeSpnW(LPCWSTR svc_class,LPCWSTR svc_name,LPCWSTR inst_name,USHORT inst_port,LPCWSTR ref,DWORD * spn_length,LPWSTR spn)70c2c66affSColin Finck DWORD WINAPI DsMakeSpnW(LPCWSTR svc_class, LPCWSTR svc_name,
71c2c66affSColin Finck LPCWSTR inst_name, USHORT inst_port,
72c2c66affSColin Finck LPCWSTR ref, DWORD *spn_length, LPWSTR spn)
73c2c66affSColin Finck {
74c2c66affSColin Finck DWORD new_spn_length;
75c2c66affSColin Finck INT len;
76c2c66affSColin Finck LPWSTR p;
77c2c66affSColin Finck
78c2c66affSColin Finck TRACE("(%s,%s,%s,%d,%s,%p,%p)\n", debugstr_w(svc_class),
79c2c66affSColin Finck debugstr_w(svc_name), debugstr_w(inst_name), inst_port,
80c2c66affSColin Finck debugstr_w(ref), spn_length, spn);
81c2c66affSColin Finck
82c2c66affSColin Finck if (!svc_class || !svc_name)
83c2c66affSColin Finck return ERROR_INVALID_PARAMETER;
84c2c66affSColin Finck
85*4cf1f80aSAmine Khaldi new_spn_length = lstrlenW(svc_class) + 1 /* for '/' */ + 1 /* for terminating '\0' */;
86c2c66affSColin Finck if (inst_name)
87*4cf1f80aSAmine Khaldi new_spn_length += lstrlenW(inst_name);
88c2c66affSColin Finck else
89*4cf1f80aSAmine Khaldi new_spn_length += lstrlenW(svc_name);
90c2c66affSColin Finck if (inst_port)
91c2c66affSColin Finck {
92c2c66affSColin Finck USHORT n = inst_port;
93c2c66affSColin Finck new_spn_length += 1 /* for ':' */;
94c2c66affSColin Finck do
95c2c66affSColin Finck {
96c2c66affSColin Finck n /= 10;
97c2c66affSColin Finck new_spn_length++;
98c2c66affSColin Finck } while (n != 0);
99c2c66affSColin Finck }
100c2c66affSColin Finck if (inst_name)
101*4cf1f80aSAmine Khaldi new_spn_length += 1 /* for '/' */ + lstrlenW(svc_name);
102c2c66affSColin Finck
103c2c66affSColin Finck if (*spn_length < new_spn_length)
104c2c66affSColin Finck {
105c2c66affSColin Finck *spn_length = new_spn_length;
106c2c66affSColin Finck return ERROR_BUFFER_OVERFLOW;
107c2c66affSColin Finck }
108c2c66affSColin Finck *spn_length = new_spn_length;
109c2c66affSColin Finck
110c2c66affSColin Finck p = spn;
111*4cf1f80aSAmine Khaldi len = lstrlenW(svc_class);
112c2c66affSColin Finck memcpy(p, svc_class, len * sizeof(WCHAR));
113c2c66affSColin Finck p += len;
114c2c66affSColin Finck *p = '/';
115c2c66affSColin Finck p++;
116c2c66affSColin Finck if (inst_name)
117c2c66affSColin Finck {
118*4cf1f80aSAmine Khaldi len = lstrlenW(inst_name);
119c2c66affSColin Finck memcpy(p, inst_name, len * sizeof(WCHAR));
120c2c66affSColin Finck p += len;
121c2c66affSColin Finck *p = '\0';
122c2c66affSColin Finck }
123c2c66affSColin Finck else
124c2c66affSColin Finck {
125*4cf1f80aSAmine Khaldi len = lstrlenW(svc_name);
126c2c66affSColin Finck memcpy(p, svc_name, len * sizeof(WCHAR));
127c2c66affSColin Finck p += len;
128c2c66affSColin Finck *p = '\0';
129c2c66affSColin Finck }
130c2c66affSColin Finck
131c2c66affSColin Finck if (inst_port)
132c2c66affSColin Finck {
133c2c66affSColin Finck static const WCHAR percentU[] = {'%','u',0};
134c2c66affSColin Finck *p = ':';
135c2c66affSColin Finck p++;
136c2c66affSColin Finck wsprintfW(p, percentU, inst_port);
137*4cf1f80aSAmine Khaldi p += lstrlenW(p);
138c2c66affSColin Finck }
139c2c66affSColin Finck
140c2c66affSColin Finck if (inst_name)
141c2c66affSColin Finck {
142c2c66affSColin Finck *p = '/';
143c2c66affSColin Finck p++;
144*4cf1f80aSAmine Khaldi len = lstrlenW(svc_name);
145c2c66affSColin Finck memcpy(p, svc_name, len * sizeof(WCHAR));
146c2c66affSColin Finck p += len;
147c2c66affSColin Finck *p = '\0';
148c2c66affSColin Finck }
149c2c66affSColin Finck
150c2c66affSColin Finck TRACE("spn = %s\n", debugstr_w(spn));
151c2c66affSColin Finck
152c2c66affSColin Finck return ERROR_SUCCESS;
153c2c66affSColin Finck }
154c2c66affSColin Finck
155c2c66affSColin Finck /***********************************************************************
156c2c66affSColin Finck * DsMakeSpnA (NTDSAPI.@)
157c2c66affSColin Finck *
158c2c66affSColin Finck * See DsMakeSpnW.
159c2c66affSColin Finck */
DsMakeSpnA(LPCSTR svc_class,LPCSTR svc_name,LPCSTR inst_name,USHORT inst_port,LPCSTR ref,DWORD * spn_length,LPSTR spn)160c2c66affSColin Finck DWORD WINAPI DsMakeSpnA(LPCSTR svc_class, LPCSTR svc_name,
161c2c66affSColin Finck LPCSTR inst_name, USHORT inst_port,
162c2c66affSColin Finck LPCSTR ref, DWORD *spn_length, LPSTR spn)
163c2c66affSColin Finck {
164c2c66affSColin Finck FIXME("(%s,%s,%s,%d,%s,%p,%p): stub!\n", debugstr_a(svc_class),
165c2c66affSColin Finck debugstr_a(svc_name), debugstr_a(inst_name), inst_port,
166c2c66affSColin Finck debugstr_a(ref), spn_length, spn);
167c2c66affSColin Finck
168c2c66affSColin Finck return ERROR_CALL_NOT_IMPLEMENTED;
169c2c66affSColin Finck }
170c2c66affSColin Finck
171c2c66affSColin Finck /***********************************************************************
172c2c66affSColin Finck * DsMakeSpnA (NTDSAPI.@)
173c2c66affSColin Finck */
DsGetSpnA(DS_SPN_NAME_TYPE ServType,LPCSTR Servlass,LPCSTR ServName,USHORT InstPort,USHORT nInstanceNames,LPCSTR * pInstanceNames,const USHORT * pInstancePorts,DWORD * pSpn,LPSTR ** pszSpn)174c2c66affSColin Finck DWORD WINAPI DsGetSpnA(DS_SPN_NAME_TYPE ServType, LPCSTR Servlass, LPCSTR ServName,
175c2c66affSColin Finck USHORT InstPort, USHORT nInstanceNames,
176c2c66affSColin Finck LPCSTR *pInstanceNames, const USHORT *pInstancePorts,
177c2c66affSColin Finck DWORD *pSpn, LPSTR **pszSpn)
178c2c66affSColin Finck {
179c2c66affSColin Finck FIXME("(%d,%s,%s,%d,%d,%p,%p,%p,%p): stub!\n", ServType,
180c2c66affSColin Finck debugstr_a(Servlass), debugstr_a(ServName), InstPort,
181c2c66affSColin Finck nInstanceNames, pInstanceNames, pInstancePorts, pSpn, pszSpn);
182c2c66affSColin Finck
183c2c66affSColin Finck return ERROR_CALL_NOT_IMPLEMENTED;
184c2c66affSColin Finck }
185c2c66affSColin Finck
186c2c66affSColin Finck /***********************************************************************
187c2c66affSColin Finck * DsServerRegisterSpnA (NTDSAPI.@)
188c2c66affSColin Finck */
DsServerRegisterSpnA(DS_SPN_WRITE_OP operation,LPCSTR ServiceClass,LPCSTR UserObjectDN)189c2c66affSColin Finck DWORD WINAPI DsServerRegisterSpnA(DS_SPN_WRITE_OP operation, LPCSTR ServiceClass, LPCSTR UserObjectDN)
190c2c66affSColin Finck {
191c2c66affSColin Finck FIXME("(%d,%s,%s): stub!\n", operation,
192c2c66affSColin Finck debugstr_a(ServiceClass), debugstr_a(UserObjectDN));
193c2c66affSColin Finck return ERROR_CALL_NOT_IMPLEMENTED;
194c2c66affSColin Finck }
195c2c66affSColin Finck
196c2c66affSColin Finck /***********************************************************************
197c2c66affSColin Finck * DsServerRegisterSpnW (NTDSAPI.@)
198c2c66affSColin Finck */
DsServerRegisterSpnW(DS_SPN_WRITE_OP operation,LPCWSTR ServiceClass,LPCWSTR UserObjectDN)199c2c66affSColin Finck DWORD WINAPI DsServerRegisterSpnW(DS_SPN_WRITE_OP operation, LPCWSTR ServiceClass, LPCWSTR UserObjectDN)
200c2c66affSColin Finck {
201c2c66affSColin Finck FIXME("(%d,%s,%s): stub!\n", operation,
202c2c66affSColin Finck debugstr_w(ServiceClass), debugstr_w(UserObjectDN));
203c2c66affSColin Finck return ERROR_CALL_NOT_IMPLEMENTED;
204c2c66affSColin Finck }
205c2c66affSColin Finck
20633bcb8c5SAmine Khaldi /***********************************************************************
20733bcb8c5SAmine Khaldi * DsClientMakeSpnForTargetServerW (NTDSAPI.@)
20833bcb8c5SAmine Khaldi */
DsClientMakeSpnForTargetServerW(LPCWSTR class,LPCWSTR name,DWORD * buflen,LPWSTR buf)209c2c66affSColin Finck DWORD WINAPI DsClientMakeSpnForTargetServerW(LPCWSTR class, LPCWSTR name, DWORD *buflen, LPWSTR buf)
210c2c66affSColin Finck {
211c2c66affSColin Finck DWORD len;
212c2c66affSColin Finck WCHAR *p;
213c2c66affSColin Finck
214c2c66affSColin Finck TRACE("(%s,%s,%p,%p)\n", debugstr_w(class), debugstr_w(name), buflen, buf);
215c2c66affSColin Finck
216c2c66affSColin Finck if (!class || !name || !buflen) return ERROR_INVALID_PARAMETER;
217c2c66affSColin Finck
218*4cf1f80aSAmine Khaldi len = lstrlenW(class) + 1 + lstrlenW(name) + 1;
219c2c66affSColin Finck if (*buflen < len)
220c2c66affSColin Finck {
221c2c66affSColin Finck *buflen = len;
222c2c66affSColin Finck return ERROR_BUFFER_OVERFLOW;
223c2c66affSColin Finck }
224c2c66affSColin Finck *buflen = len;
225c2c66affSColin Finck
226*4cf1f80aSAmine Khaldi memcpy(buf, class, lstrlenW(class) * sizeof(WCHAR));
227*4cf1f80aSAmine Khaldi p = buf + lstrlenW(class);
228c2c66affSColin Finck *p++ = '/';
229*4cf1f80aSAmine Khaldi memcpy(p, name, lstrlenW(name) * sizeof(WCHAR));
230c2c66affSColin Finck buf[len - 1] = 0;
231c2c66affSColin Finck
232c2c66affSColin Finck return ERROR_SUCCESS;
233c2c66affSColin Finck }
23433bcb8c5SAmine Khaldi
23533bcb8c5SAmine Khaldi /***********************************************************************
23633bcb8c5SAmine Khaldi * DsCrackNamesA (NTDSAPI.@)
23733bcb8c5SAmine Khaldi */
DsCrackNamesA(HANDLE handle,DS_NAME_FLAGS flags,DS_NAME_FORMAT offered,DS_NAME_FORMAT desired,DWORD num,const CHAR ** names,PDS_NAME_RESULTA * result)23833bcb8c5SAmine Khaldi DWORD WINAPI DsCrackNamesA(HANDLE handle, DS_NAME_FLAGS flags, DS_NAME_FORMAT offered, DS_NAME_FORMAT desired,
23933bcb8c5SAmine Khaldi DWORD num, const CHAR **names, PDS_NAME_RESULTA *result)
24033bcb8c5SAmine Khaldi {
24133bcb8c5SAmine Khaldi FIXME("(%p %u %u %u %u %p %p stub\n", handle, flags, offered, desired, num, names, result);
24233bcb8c5SAmine Khaldi return ERROR_CALL_NOT_IMPLEMENTED;
24333bcb8c5SAmine Khaldi }
24433bcb8c5SAmine Khaldi
24533bcb8c5SAmine Khaldi /***********************************************************************
24633bcb8c5SAmine Khaldi * DsCrackNamesW (NTDSAPI.@)
24733bcb8c5SAmine Khaldi */
DsCrackNamesW(HANDLE handle,DS_NAME_FLAGS flags,DS_NAME_FORMAT offered,DS_NAME_FORMAT desired,DWORD num,const WCHAR ** names,PDS_NAME_RESULTW * result)24833bcb8c5SAmine Khaldi DWORD WINAPI DsCrackNamesW(HANDLE handle, DS_NAME_FLAGS flags, DS_NAME_FORMAT offered, DS_NAME_FORMAT desired,
24933bcb8c5SAmine Khaldi DWORD num, const WCHAR **names, PDS_NAME_RESULTW *result)
25033bcb8c5SAmine Khaldi {
25133bcb8c5SAmine Khaldi FIXME("(%p %u %u %u %u %p %p stub\n", handle, flags, offered, desired, num, names, result);
25233bcb8c5SAmine Khaldi return ERROR_CALL_NOT_IMPLEMENTED;
25333bcb8c5SAmine Khaldi }
254