libwine: Remove __wine_main_arg* from the public header.
[wine/zf.git] / dlls / activeds / activeds_main.c
blob1b22da676530c789a5bab36e58657f2cae2a3e8d
1 /*
2 * Implementation of the Active Directory Service Interface
4 * Copyright 2005 Detlef Riekenberg
5 * Copyright 2019 Dmitry Timoshkov
7 * This file contains only stubs to get the printui.dll up and running
8 * activeds.dll is much much more than this
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include <stdarg.h>
27 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
33 #include "objbase.h"
34 #include "initguid.h"
35 #include "iads.h"
36 #include "adshlp.h"
37 #include "adserr.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(activeds);
43 /*****************************************************
44 * DllMain
46 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
48 TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
50 switch(fdwReason)
52 case DLL_WINE_PREATTACH:
53 return FALSE; /* prefer native version */
54 case DLL_PROCESS_ATTACH:
55 DisableThreadLibraryCalls( hinstDLL );
56 break;
58 return TRUE;
61 /*****************************************************
62 * ADsGetObject [ACTIVEDS.3]
64 HRESULT WINAPI ADsGetObject(LPCWSTR path, REFIID riid, void **obj)
66 HRESULT hr;
68 hr = ADsOpenObject(path, NULL, NULL, ADS_SECURE_AUTHENTICATION, riid, obj);
69 if (hr != S_OK)
70 hr = ADsOpenObject(path, NULL, NULL, 0, riid, obj);
71 return hr;
74 /*****************************************************
75 * ADsBuildEnumerator [ACTIVEDS.4]
77 HRESULT WINAPI ADsBuildEnumerator(IADsContainer * pADsContainer, IEnumVARIANT** ppEnumVariant)
79 FIXME("(%p)->(%p)!stub\n",pADsContainer, ppEnumVariant);
80 return E_NOTIMPL;
83 /*****************************************************
84 * ADsFreeEnumerator [ACTIVEDS.5]
86 HRESULT WINAPI ADsFreeEnumerator(IEnumVARIANT* pEnumVariant)
88 FIXME("(%p)!stub\n",pEnumVariant);
89 return E_NOTIMPL;
92 /*****************************************************
93 * ADsEnumerateNext [ACTIVEDS.6]
95 HRESULT WINAPI ADsEnumerateNext(IEnumVARIANT* pEnumVariant, ULONG cElements, VARIANT* pvar, ULONG * pcElementsFetched)
97 FIXME("(%p)->(%u, %p, %p)!stub\n",pEnumVariant, cElements, pvar, pcElementsFetched);
98 return E_NOTIMPL;
101 /*****************************************************
102 * ADsBuildVarArrayStr [ACTIVEDS.7]
104 HRESULT WINAPI ADsBuildVarArrayStr(LPWSTR *str, DWORD count, VARIANT *var)
106 HRESULT hr;
107 SAFEARRAY *sa;
108 LONG idx, end = count;
110 TRACE("(%p, %u, %p)\n", str, count, var);
112 if (!var) return E_ADS_BAD_PARAMETER;
114 sa = SafeArrayCreateVector(VT_VARIANT, 0, count);
115 if (!sa) return E_OUTOFMEMORY;
117 VariantInit(var);
118 for (idx = 0; idx < end; idx++)
120 VARIANT item;
122 V_VT(&item) = VT_BSTR;
123 V_BSTR(&item) = SysAllocString(str[idx]);
124 if (!V_BSTR(&item))
126 hr = E_OUTOFMEMORY;
127 goto fail;
130 hr = SafeArrayPutElement(sa, &idx, &item);
131 SysFreeString(V_BSTR(&item));
132 if (hr != S_OK) goto fail;
135 V_VT(var) = VT_ARRAY | VT_VARIANT;
136 V_ARRAY(var) = sa;
137 return S_OK;
139 fail:
140 SafeArrayDestroy(sa);
141 return hr;
144 /*****************************************************
145 * ADsBuildVarArrayInt [ACTIVEDS.8]
147 HRESULT WINAPI ADsBuildVarArrayInt(LPDWORD lpdwObjectTypes, DWORD dwObjectTypes, VARIANT* pvar)
149 FIXME("(%p, %d, %p)!stub\n",lpdwObjectTypes, dwObjectTypes, pvar);
150 return E_NOTIMPL;
153 /*****************************************************
154 * ADsOpenObject [ACTIVEDS.9]
156 HRESULT WINAPI ADsOpenObject(LPCWSTR path, LPCWSTR user, LPCWSTR password, DWORD reserved, REFIID riid, void **obj)
158 HRESULT hr;
159 HKEY hkey, hprov;
160 WCHAR provider[MAX_PATH], progid[MAX_PATH];
161 DWORD idx = 0;
163 TRACE("(%s,%s,%u,%s,%p)\n", debugstr_w(path), debugstr_w(user), reserved, debugstr_guid(riid), obj);
165 if (!path || !riid || !obj)
166 return E_INVALIDARG;
168 hr = E_FAIL;
170 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\ADs\\Providers", 0, KEY_READ, &hkey))
171 return hr;
173 for (;;)
175 if (RegEnumKeyW(hkey, idx++, provider, ARRAY_SIZE(provider)))
176 break;
178 TRACE("provider %s\n", debugstr_w(provider));
180 if (!wcsnicmp(path, provider, wcslen(provider)) && path[wcslen(provider)] == ':')
182 LONG size;
184 if (RegOpenKeyExW(hkey, provider, 0, KEY_READ, &hprov))
185 break;
187 size = ARRAY_SIZE(progid);
188 if (!RegQueryValueW(hprov, NULL, progid, &size))
190 CLSID clsid;
192 if (CLSIDFromProgID(progid, &clsid) == S_OK)
194 IADsOpenDSObject *adsopen;
195 IDispatch *disp;
197 TRACE("ns %s => clsid %s\n", debugstr_w(progid), wine_dbgstr_guid(&clsid));
198 if (CoCreateInstance(&clsid, 0, CLSCTX_INPROC_SERVER, &IID_IADsOpenDSObject, (void **)&adsopen) == S_OK)
200 BSTR bpath, buser, bpassword;
202 bpath = SysAllocString(path);
203 buser = SysAllocString(user);
204 bpassword = SysAllocString(password);
206 hr = IADsOpenDSObject_OpenDSObject(adsopen, bpath, buser, bpassword, reserved, &disp);
207 if (hr == S_OK)
209 hr = IDispatch_QueryInterface(disp, riid, obj);
210 IDispatch_Release(disp);
213 SysFreeString(bpath);
214 SysFreeString(buser);
215 SysFreeString(bpassword);
217 IADsOpenDSObject_Release(adsopen);
222 RegCloseKey(hprov);
223 break;
227 RegCloseKey(hkey);
229 return hr;
232 /*****************************************************
233 * ADsSetLastError [ACTIVEDS.12]
235 VOID WINAPI ADsSetLastError(DWORD dwErr, LPWSTR pszError, LPWSTR pszProvider)
237 FIXME("(%d,%p,%p)!stub\n", dwErr, pszError, pszProvider);
240 /*****************************************************
241 * ADsGetLastError [ACTIVEDS.13]
243 HRESULT WINAPI ADsGetLastError(LPDWORD perror, LPWSTR errorbuf, DWORD errorbuflen, LPWSTR namebuf, DWORD namebuflen)
245 FIXME("(%p,%p,%d,%p,%d)!stub\n", perror, errorbuf, errorbuflen, namebuf, namebuflen);
246 return E_NOTIMPL;
249 /*****************************************************
250 * AllocADsMem [ACTIVEDS.14]
252 LPVOID WINAPI AllocADsMem(DWORD cb)
254 return HeapAlloc(GetProcessHeap(), 0, cb);
257 /*****************************************************
258 * FreeADsMem [ACTIVEDS.15]
260 BOOL WINAPI FreeADsMem(LPVOID pMem)
262 return HeapFree(GetProcessHeap(), 0, pMem);
265 /*****************************************************
266 * ReallocADsMem [ACTIVEDS.16]
268 LPVOID WINAPI ReallocADsMem(LPVOID pOldMem, DWORD cbOld, DWORD cbNew)
270 return HeapReAlloc(GetProcessHeap(), 0, pOldMem, cbNew);
273 /*****************************************************
274 * AllocADsStr [ACTIVEDS.17]
276 LPWSTR WINAPI AllocADsStr(LPWSTR pStr)
278 LPWSTR ret;
279 SIZE_T len;
281 TRACE("(%p)\n", pStr);
283 if (!pStr) return NULL;
285 len = (wcslen(pStr) + 1) * sizeof(WCHAR);
286 ret = AllocADsMem(len);
287 if (ret) memcpy(ret, pStr, len);
289 return ret;
292 /*****************************************************
293 * FreeADsStr [ACTIVEDS.18]
295 BOOL WINAPI FreeADsStr(LPWSTR pStr)
297 TRACE("(%p)\n", pStr);
299 return FreeADsMem(pStr);
302 /*****************************************************
303 * ReallocADsStr [ACTIVEDS.19]
305 BOOL WINAPI ReallocADsStr(LPWSTR *ppStr, LPWSTR pStr)
307 FIXME("(%p,%p)!stub\n",*ppStr, pStr);
308 return FALSE;
311 /*****************************************************
312 * ADsEncodeBinaryData [ACTIVEDS.20]
314 HRESULT WINAPI ADsEncodeBinaryData(PBYTE pbSrcData, DWORD dwSrcLen, LPWSTR *ppszDestData)
316 FIXME("(%p,%d,%p)!stub\n", pbSrcData, dwSrcLen, *ppszDestData);
317 return E_NOTIMPL;