cmd: DIR command outputs free space for the path.
[wine.git] / dlls / activeds / activeds_main.c
blob0f13a5629b6d85b48b5680f7567a1d951d005ef3
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 * ADsGetObject [ACTIVEDS.3]
46 HRESULT WINAPI ADsGetObject(LPCWSTR path, REFIID riid, void **obj)
48 HRESULT hr;
50 hr = ADsOpenObject(path, NULL, NULL, ADS_SECURE_AUTHENTICATION, riid, obj);
51 if (hr != S_OK)
52 hr = ADsOpenObject(path, NULL, NULL, 0, riid, obj);
53 return hr;
56 /*****************************************************
57 * ADsBuildEnumerator [ACTIVEDS.4]
59 HRESULT WINAPI ADsBuildEnumerator(IADsContainer * pADsContainer, IEnumVARIANT** ppEnumVariant)
61 FIXME("(%p)->(%p)!stub\n",pADsContainer, ppEnumVariant);
62 return E_NOTIMPL;
65 /*****************************************************
66 * ADsFreeEnumerator [ACTIVEDS.5]
68 HRESULT WINAPI ADsFreeEnumerator(IEnumVARIANT* pEnumVariant)
70 FIXME("(%p)!stub\n",pEnumVariant);
71 return E_NOTIMPL;
74 /*****************************************************
75 * ADsEnumerateNext [ACTIVEDS.6]
77 HRESULT WINAPI ADsEnumerateNext(IEnumVARIANT* pEnumVariant, ULONG cElements, VARIANT* pvar, ULONG * pcElementsFetched)
79 FIXME("(%p)->(%lu, %p, %p)!stub\n",pEnumVariant, cElements, pvar, pcElementsFetched);
80 return E_NOTIMPL;
83 /*****************************************************
84 * ADsBuildVarArrayStr [ACTIVEDS.7]
86 HRESULT WINAPI ADsBuildVarArrayStr(LPWSTR *str, DWORD count, VARIANT *var)
88 HRESULT hr;
89 SAFEARRAY *sa;
90 LONG idx, end = count;
92 TRACE("(%p, %lu, %p)\n", str, count, var);
94 if (!var) return E_ADS_BAD_PARAMETER;
96 sa = SafeArrayCreateVector(VT_VARIANT, 0, count);
97 if (!sa) return E_OUTOFMEMORY;
99 VariantInit(var);
100 for (idx = 0; idx < end; idx++)
102 VARIANT item;
104 V_VT(&item) = VT_BSTR;
105 V_BSTR(&item) = SysAllocString(str[idx]);
106 if (!V_BSTR(&item))
108 hr = E_OUTOFMEMORY;
109 goto fail;
112 hr = SafeArrayPutElement(sa, &idx, &item);
113 SysFreeString(V_BSTR(&item));
114 if (hr != S_OK) goto fail;
117 V_VT(var) = VT_ARRAY | VT_VARIANT;
118 V_ARRAY(var) = sa;
119 return S_OK;
121 fail:
122 SafeArrayDestroy(sa);
123 return hr;
126 /*****************************************************
127 * ADsBuildVarArrayInt [ACTIVEDS.8]
129 HRESULT WINAPI ADsBuildVarArrayInt(LPDWORD lpdwObjectTypes, DWORD dwObjectTypes, VARIANT* pvar)
131 FIXME("(%p, %ld, %p)!stub\n",lpdwObjectTypes, dwObjectTypes, pvar);
132 return E_NOTIMPL;
135 /*****************************************************
136 * ADsOpenObject [ACTIVEDS.9]
138 HRESULT WINAPI ADsOpenObject(LPCWSTR path, LPCWSTR user, LPCWSTR password, DWORD reserved, REFIID riid, void **obj)
140 HRESULT hr;
141 HKEY hkey, hprov;
142 WCHAR provider[MAX_PATH], progid[MAX_PATH];
143 DWORD idx = 0;
145 TRACE("(%s,%s,%lu,%s,%p)\n", debugstr_w(path), debugstr_w(user), reserved, debugstr_guid(riid), obj);
147 if (!path || !riid || !obj)
148 return E_INVALIDARG;
150 hr = E_FAIL;
152 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\ADs\\Providers", 0, KEY_READ, &hkey))
153 return hr;
155 for (;;)
157 if (RegEnumKeyW(hkey, idx++, provider, ARRAY_SIZE(provider)))
158 break;
160 TRACE("provider %s\n", debugstr_w(provider));
162 if (!wcsnicmp(path, provider, wcslen(provider)) && path[wcslen(provider)] == ':')
164 LONG size;
166 if (RegOpenKeyExW(hkey, provider, 0, KEY_READ, &hprov))
167 break;
169 size = ARRAY_SIZE(progid);
170 if (!RegQueryValueW(hprov, NULL, progid, &size))
172 CLSID clsid;
174 if (CLSIDFromProgID(progid, &clsid) == S_OK)
176 IADsOpenDSObject *adsopen;
177 IDispatch *disp;
179 TRACE("ns %s => clsid %s\n", debugstr_w(progid), wine_dbgstr_guid(&clsid));
180 if (CoCreateInstance(&clsid, 0, CLSCTX_INPROC_SERVER, &IID_IADsOpenDSObject, (void **)&adsopen) == S_OK)
182 BSTR bpath, buser, bpassword;
184 bpath = SysAllocString(path);
185 buser = SysAllocString(user);
186 bpassword = SysAllocString(password);
188 hr = IADsOpenDSObject_OpenDSObject(adsopen, bpath, buser, bpassword, reserved, &disp);
189 if (hr == S_OK)
191 hr = IDispatch_QueryInterface(disp, riid, obj);
192 IDispatch_Release(disp);
195 SysFreeString(bpath);
196 SysFreeString(buser);
197 SysFreeString(bpassword);
199 IADsOpenDSObject_Release(adsopen);
204 RegCloseKey(hprov);
205 break;
209 RegCloseKey(hkey);
211 return hr;
214 /*****************************************************
215 * ADsSetLastError [ACTIVEDS.12]
217 VOID WINAPI ADsSetLastError(DWORD dwErr, LPWSTR pszError, LPWSTR pszProvider)
219 FIXME("(%ld,%p,%p)!stub\n", dwErr, pszError, pszProvider);
222 /*****************************************************
223 * ADsGetLastError [ACTIVEDS.13]
225 HRESULT WINAPI ADsGetLastError(LPDWORD perror, LPWSTR errorbuf, DWORD errorbuflen, LPWSTR namebuf, DWORD namebuflen)
227 FIXME("(%p,%p,%ld,%p,%ld)!stub\n", perror, errorbuf, errorbuflen, namebuf, namebuflen);
228 return E_NOTIMPL;
231 /*****************************************************
232 * AllocADsMem [ACTIVEDS.14]
234 LPVOID WINAPI AllocADsMem(DWORD cb)
236 return malloc(cb);
239 /*****************************************************
240 * FreeADsMem [ACTIVEDS.15]
242 BOOL WINAPI FreeADsMem(LPVOID pMem)
244 free(pMem);
245 return TRUE;
248 /*****************************************************
249 * ReallocADsMem [ACTIVEDS.16]
251 LPVOID WINAPI ReallocADsMem(LPVOID pOldMem, DWORD cbOld, DWORD cbNew)
253 return realloc(pOldMem, cbNew);
256 /*****************************************************
257 * AllocADsStr [ACTIVEDS.17]
259 LPWSTR WINAPI AllocADsStr(LPWSTR pStr)
261 TRACE("(%p)\n", pStr);
262 return wcsdup(pStr);
265 /*****************************************************
266 * FreeADsStr [ACTIVEDS.18]
268 BOOL WINAPI FreeADsStr(LPWSTR pStr)
270 TRACE("(%p)\n", pStr);
272 return FreeADsMem(pStr);
275 /*****************************************************
276 * ReallocADsStr [ACTIVEDS.19]
278 BOOL WINAPI ReallocADsStr(LPWSTR *ppStr, LPWSTR pStr)
280 FIXME("(%p,%p)!stub\n",*ppStr, pStr);
281 return FALSE;
284 /*****************************************************
285 * ADsEncodeBinaryData [ACTIVEDS.20]
287 HRESULT WINAPI ADsEncodeBinaryData(PBYTE pbSrcData, DWORD dwSrcLen, LPWSTR *ppszDestData)
289 FIXME("(%p,%ld,%p)!stub\n", pbSrcData, dwSrcLen, *ppszDestData);
290 return E_NOTIMPL;