secur32/tests: Use importlib for functions available since Windows XP.
[wine.git] / dlls / ntdsapi / ntdsapi.c
blobee0c8379c3e932b3fa427f0f54b476a2130c9749
1 /*
2 * Copyright (C) 2006 Dmitry Timoshkov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winerror.h"
24 #include "winuser.h"
25 #include "ntdsapi.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ntdsapi);
31 /*****************************************************
32 * DllMain
34 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
36 TRACE("(%p, %d, %p)\n", hinst, reason, reserved);
38 switch(reason)
40 case DLL_WINE_PREATTACH:
41 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 DisableThreadLibraryCalls( hinst );
45 break;
47 return TRUE;
50 /***********************************************************************
51 * DsBindA (NTDSAPI.@)
53 DWORD WINAPI DsBindA(LPCSTR controller, LPCSTR domain, HANDLE *handle)
55 FIXME("(%s,%s, %p): stub!\n", debugstr_a(controller), debugstr_a(domain), handle);
56 return ERROR_CALL_NOT_IMPLEMENTED;
59 /***********************************************************************
60 * DsBindW (NTDSAPI.@)
62 DWORD WINAPI DsBindW(LPCWSTR controller, LPCWSTR domain, HANDLE *handle)
64 FIXME("(%s,%s, %p): stub!\n", debugstr_w(controller), debugstr_w(domain), handle);
65 return ERROR_CALL_NOT_IMPLEMENTED;
68 /***********************************************************************
69 * DsMakeSpnW (NTDSAPI.@)
71 DWORD WINAPI DsMakeSpnW(LPCWSTR svc_class, LPCWSTR svc_name,
72 LPCWSTR inst_name, USHORT inst_port,
73 LPCWSTR ref, DWORD *spn_length, LPWSTR spn)
75 DWORD new_spn_length;
76 INT len;
77 LPWSTR p;
79 TRACE("(%s,%s,%s,%d,%s,%p,%p)\n", debugstr_w(svc_class),
80 debugstr_w(svc_name), debugstr_w(inst_name), inst_port,
81 debugstr_w(ref), spn_length, spn);
83 if (!svc_class || !svc_name)
84 return ERROR_INVALID_PARAMETER;
86 new_spn_length = strlenW(svc_class) + 1 /* for '/' */ + 1 /* for terminating '\0' */;
87 if (inst_name)
88 new_spn_length += strlenW(inst_name);
89 else
90 new_spn_length += strlenW(svc_name);
91 if (inst_port)
93 USHORT n = inst_port;
94 new_spn_length += 1 /* for ':' */;
97 n /= 10;
98 new_spn_length++;
99 } while (n != 0);
101 if (inst_name)
102 new_spn_length += 1 /* for '/' */ + strlenW(svc_name);
104 if (*spn_length < new_spn_length)
106 *spn_length = new_spn_length;
107 return ERROR_BUFFER_OVERFLOW;
109 *spn_length = new_spn_length;
111 p = spn;
112 len = strlenW(svc_class);
113 memcpy(p, svc_class, len * sizeof(WCHAR));
114 p += len;
115 *p = '/';
116 p++;
117 if (inst_name)
119 len = strlenW(inst_name);
120 memcpy(p, inst_name, len * sizeof(WCHAR));
121 p += len;
122 *p = '\0';
124 else
126 len = strlenW(svc_name);
127 memcpy(p, svc_name, len * sizeof(WCHAR));
128 p += len;
129 *p = '\0';
132 if (inst_port)
134 static const WCHAR percentU[] = {'%','u',0};
135 *p = ':';
136 p++;
137 wsprintfW(p, percentU, inst_port);
138 p += strlenW(p);
141 if (inst_name)
143 *p = '/';
144 p++;
145 len = strlenW(svc_name);
146 memcpy(p, svc_name, len * sizeof(WCHAR));
147 p += len;
148 *p = '\0';
151 TRACE("spn = %s\n", debugstr_w(spn));
153 return ERROR_SUCCESS;
156 /***********************************************************************
157 * DsMakeSpnA (NTDSAPI.@)
159 * See DsMakeSpnW.
161 DWORD WINAPI DsMakeSpnA(LPCSTR svc_class, LPCSTR svc_name,
162 LPCSTR inst_name, USHORT inst_port,
163 LPCSTR ref, DWORD *spn_length, LPSTR spn)
165 FIXME("(%s,%s,%s,%d,%s,%p,%p): stub!\n", debugstr_a(svc_class),
166 debugstr_a(svc_name), debugstr_a(inst_name), inst_port,
167 debugstr_a(ref), spn_length, spn);
169 return ERROR_CALL_NOT_IMPLEMENTED;
172 /***********************************************************************
173 * DsMakeSpnA (NTDSAPI.@)
175 DWORD WINAPI DsGetSpnA(DS_SPN_NAME_TYPE ServType, LPCSTR Servlass, LPCSTR ServName,
176 USHORT InstPort, USHORT nInstanceNames,
177 LPCSTR *pInstanceNames, const USHORT *pInstancePorts,
178 DWORD *pSpn, LPSTR **pszSpn)
180 FIXME("(%d,%s,%s,%d,%d,%p,%p,%p,%p): stub!\n", ServType,
181 debugstr_a(Servlass), debugstr_a(ServName), InstPort,
182 nInstanceNames, pInstanceNames, pInstancePorts, pSpn, pszSpn);
184 return ERROR_CALL_NOT_IMPLEMENTED;
187 /***********************************************************************
188 * DsServerRegisterSpnA (NTDSAPI.@)
190 DWORD WINAPI DsServerRegisterSpnA(DS_SPN_WRITE_OP operation, LPCSTR ServiceClass, LPCSTR UserObjectDN)
192 FIXME("(%d,%s,%s): stub!\n", operation,
193 debugstr_a(ServiceClass), debugstr_a(UserObjectDN));
194 return ERROR_CALL_NOT_IMPLEMENTED;
197 /***********************************************************************
198 * DsServerRegisterSpnW (NTDSAPI.@)
200 DWORD WINAPI DsServerRegisterSpnW(DS_SPN_WRITE_OP operation, LPCWSTR ServiceClass, LPCWSTR UserObjectDN)
202 FIXME("(%d,%s,%s): stub!\n", operation,
203 debugstr_w(ServiceClass), debugstr_w(UserObjectDN));
204 return ERROR_CALL_NOT_IMPLEMENTED;
207 DWORD WINAPI DsClientMakeSpnForTargetServerW(LPCWSTR class, LPCWSTR name, DWORD *buflen, LPWSTR buf)
209 DWORD len;
210 WCHAR *p;
212 TRACE("(%s,%s,%p,%p)\n", debugstr_w(class), debugstr_w(name), buflen, buf);
214 if (!class || !name || !buflen) return ERROR_INVALID_PARAMETER;
216 len = strlenW(class) + 1 + strlenW(name) + 1;
217 if (*buflen < len)
219 *buflen = len;
220 return ERROR_BUFFER_OVERFLOW;
222 *buflen = len;
224 memcpy(buf, class, strlenW(class) * sizeof(WCHAR));
225 p = buf + strlenW(class);
226 *p++ = '/';
227 memcpy(p, name, strlenW(name) * sizeof(WCHAR));
228 buf[len - 1] = 0;
230 return ERROR_SUCCESS;