ReactOS 0.4.17-dev-116-ga4b6fe9
activeds_main.c
Go to the documentation of this file.
1/*
2 * Implementation of the Active Directory Service Interface
3 *
4 * Copyright 2005 Detlef Riekenberg
5 * Copyright 2019 Dmitry Timoshkov
6 *
7 * This file contains only stubs to get the printui.dll up and running
8 * activeds.dll is much much more than this
9 *
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.
14 *
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.
19 *
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
23 */
24
25#include <stdarg.h>
26
27#define COBJMACROS
28
29#include "windef.h"
30#include "winbase.h"
31#include "winuser.h"
32
33#include "objbase.h"
34#include "initguid.h"
35#include "iads.h"
36#include "adshlp.h"
37#include "adserr.h"
38
39#include "wine/debug.h"
40
42
43/*****************************************************
44 * ADsGetObject [ACTIVEDS.3]
45 */
47{
48 HRESULT hr;
49
50 hr = ADsOpenObject(path, NULL, NULL, ADS_SECURE_AUTHENTICATION, riid, obj);
51 if (hr != S_OK)
53 return hr;
54}
55
56/*****************************************************
57 * ADsBuildEnumerator [ACTIVEDS.4]
58 */
59HRESULT WINAPI ADsBuildEnumerator(IADsContainer * pADsContainer, IEnumVARIANT** ppEnumVariant)
60{
61 FIXME("(%p)->(%p)!stub\n",pADsContainer, ppEnumVariant);
62 return E_NOTIMPL;
63}
64
65/*****************************************************
66 * ADsFreeEnumerator [ACTIVEDS.5]
67 */
69{
70 FIXME("(%p)!stub\n",pEnumVariant);
71 return E_NOTIMPL;
72}
73
74/*****************************************************
75 * ADsEnumerateNext [ACTIVEDS.6]
76 */
77HRESULT WINAPI ADsEnumerateNext(IEnumVARIANT* pEnumVariant, ULONG cElements, VARIANT* pvar, ULONG * pcElementsFetched)
78{
79 FIXME("(%p)->(%lu, %p, %p)!stub\n",pEnumVariant, cElements, pvar, pcElementsFetched);
80 return E_NOTIMPL;
81}
82
83/*****************************************************
84 * ADsBuildVarArrayStr [ACTIVEDS.7]
85 */
87{
88 HRESULT hr;
90 LONG idx, end = count;
91
92 TRACE("(%p, %lu, %p)\n", str, count, var);
93
94 if (!var) return E_ADS_BAD_PARAMETER;
95
97 if (!sa) return E_OUTOFMEMORY;
98
100 for (idx = 0; idx < end; idx++)
101 {
103
104 V_VT(&item) = VT_BSTR;
106 if (!V_BSTR(&item))
107 {
109 goto fail;
110 }
111
114 if (hr != S_OK) goto fail;
115 }
116
118 V_ARRAY(var) = sa;
119 return S_OK;
120
121fail:
123 return hr;
124}
125
126/*****************************************************
127 * ADsBuildVarArrayInt [ACTIVEDS.8]
128 */
129HRESULT WINAPI ADsBuildVarArrayInt(LPDWORD lpdwObjectTypes, DWORD dwObjectTypes, VARIANT* pvar)
130{
131 FIXME("(%p, %ld, %p)!stub\n",lpdwObjectTypes, dwObjectTypes, pvar);
132 return E_NOTIMPL;
133}
134
135/*****************************************************
136 * ADsOpenObject [ACTIVEDS.9]
137 */
139{
140 HRESULT hr;
141 HKEY hkey, hprov;
142 WCHAR provider[MAX_PATH], progid[MAX_PATH];
143 DWORD idx = 0;
144
145 TRACE("(%s,%s,%lu,%s,%p)\n", debugstr_w(path), debugstr_w(user), reserved, debugstr_guid(riid), obj);
146
147 if (!path || !riid || !obj)
148 return E_INVALIDARG;
149
150 hr = E_FAIL;
151
152 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\ADs\\Providers", 0, KEY_READ, &hkey))
153 return hr;
154
155 for (;;)
156 {
157 if (RegEnumKeyW(hkey, idx++, provider, ARRAY_SIZE(provider)))
158 break;
159
160 TRACE("provider %s\n", debugstr_w(provider));
161
162 if (!wcsnicmp(path, provider, wcslen(provider)) && path[wcslen(provider)] == ':')
163 {
164 LONG size;
165
166 if (RegOpenKeyExW(hkey, provider, 0, KEY_READ, &hprov))
167 break;
168
170 if (!RegQueryValueW(hprov, NULL, progid, &size))
171 {
172 CLSID clsid;
173
175 {
176 IADsOpenDSObject *adsopen;
177 IDispatch *disp;
178
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)
181 {
182 BSTR bpath, buser, bpassword;
183
184 bpath = SysAllocString(path);
185 buser = SysAllocString(user);
186 bpassword = SysAllocString(password);
187
188 hr = IADsOpenDSObject_OpenDSObject(adsopen, bpath, buser, bpassword, reserved, &disp);
189 if (hr == S_OK)
190 {
191 hr = IDispatch_QueryInterface(disp, riid, obj);
192 IDispatch_Release(disp);
193 }
194
195 SysFreeString(bpath);
196 SysFreeString(buser);
197 SysFreeString(bpassword);
198
199 IADsOpenDSObject_Release(adsopen);
200 }
201 }
202 }
203
204 RegCloseKey(hprov);
205 break;
206 }
207 }
208
209 RegCloseKey(hkey);
210
211 return hr;
212}
213
214/*****************************************************
215 * ADsSetLastError [ACTIVEDS.12]
216 */
218{
219 FIXME("(%ld,%p,%p)!stub\n", dwErr, pszError, pszProvider);
220}
221
222/*****************************************************
223 * ADsGetLastError [ACTIVEDS.13]
224 */
225HRESULT WINAPI ADsGetLastError(LPDWORD perror, LPWSTR errorbuf, DWORD errorbuflen, LPWSTR namebuf, DWORD namebuflen)
226{
227 FIXME("(%p,%p,%ld,%p,%ld)!stub\n", perror, errorbuf, errorbuflen, namebuf, namebuflen);
228 return E_NOTIMPL;
229}
230
231/*****************************************************
232 * AllocADsMem [ACTIVEDS.14]
233 */
235{
236 return malloc(cb);
237}
238
239/*****************************************************
240 * FreeADsMem [ACTIVEDS.15]
241 */
243{
244 free(pMem);
245 return TRUE;
246}
247
248/*****************************************************
249 * ReallocADsMem [ACTIVEDS.16]
250 */
252{
253 return realloc(pOldMem, cbNew);
254}
255
256/*****************************************************
257 * AllocADsStr [ACTIVEDS.17]
258 */
260{
261 TRACE("(%p)\n", pStr);
262 return wcsdup(pStr);
263}
264
265/*****************************************************
266 * FreeADsStr [ACTIVEDS.18]
267 */
269{
270 TRACE("(%p)\n", pStr);
271
272 return FreeADsMem(pStr);
273}
274
275/*****************************************************
276 * ReallocADsStr [ACTIVEDS.19]
277 */
279{
280 FIXME("(%p,%p)!stub\n",*ppStr, pStr);
281 return FALSE;
282}
283
284/*****************************************************
285 * ADsEncodeBinaryData [ACTIVEDS.20]
286 */
287HRESULT WINAPI ADsEncodeBinaryData(PBYTE pbSrcData, DWORD dwSrcLen, LPWSTR *ppszDestData)
288{
289 FIXME("(%p,%ld,%p)!stub\n", pbSrcData, dwSrcLen, *ppszDestData);
290 return E_NOTIMPL;
291}
HRESULT WINAPI ADsGetObject(LPCWSTR path, REFIID riid, void **obj)
Definition: activeds_main.c:46
HRESULT WINAPI ADsOpenObject(LPCWSTR path, LPCWSTR user, LPCWSTR password, DWORD reserved, REFIID riid, void **obj)
HRESULT WINAPI ADsBuildVarArrayInt(LPDWORD lpdwObjectTypes, DWORD dwObjectTypes, VARIANT *pvar)
HRESULT WINAPI ADsBuildEnumerator(IADsContainer *pADsContainer, IEnumVARIANT **ppEnumVariant)
Definition: activeds_main.c:59
HRESULT WINAPI ADsBuildVarArrayStr(LPWSTR *str, DWORD count, VARIANT *var)
Definition: activeds_main.c:86
HRESULT WINAPI ADsFreeEnumerator(IEnumVARIANT *pEnumVariant)
Definition: activeds_main.c:68
HRESULT WINAPI ADsEnumerateNext(IEnumVARIANT *pEnumVariant, ULONG cElements, VARIANT *pvar, ULONG *pcElementsFetched)
Definition: activeds_main.c:77
BOOL WINAPI ReallocADsStr(LPWSTR *ppStr, LPWSTR pStr)
HRESULT WINAPI ADsGetLastError(LPDWORD perror, LPWSTR errorbuf, DWORD errorbuflen, LPWSTR namebuf, DWORD namebuflen)
LPVOID WINAPI ReallocADsMem(LPVOID pOldMem, DWORD cbOld, DWORD cbNew)
LPWSTR WINAPI AllocADsStr(LPWSTR pStr)
BOOL WINAPI FreeADsMem(LPVOID pMem)
VOID WINAPI ADsSetLastError(DWORD dwErr, LPWSTR pszError, LPWSTR pszProvider)
BOOL WINAPI FreeADsStr(LPWSTR pStr)
HRESULT WINAPI ADsEncodeBinaryData(PBYTE pbSrcData, DWORD dwSrcLen, LPWSTR *ppszDestData)
LPVOID WINAPI AllocADsMem(DWORD cb)
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define E_ADS_BAD_PARAMETER
Definition: adserr.h:36
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:20
DWORD dwErr
Definition: service.c:36
#define FIXME(fmt,...)
Definition: precomp.h:53
#define RegCloseKey(hKey)
Definition: registry.h:49
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:573
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4241
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1437
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define wcsnicmp
Definition: compat.h:14
OLECHAR * BSTR
Definition: compat.h:2293
#define MAX_PATH
Definition: compat.h:34
@ VT_BSTR
Definition: compat.h:2303
@ VT_ARRAY
Definition: compat.h:2341
@ VT_VARIANT
Definition: compat.h:2307
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
void CDECL perror(const char *str)
Definition: errno.c:337
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
SAFEARRAY *WINAPI SafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements)
Definition: safearray.c:677
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
HRESULT WINAPI SafeArrayPutElement(SAFEARRAY *psa, LONG *rgIndices, void *pvData)
Definition: safearray.c:864
#define L(x)
Definition: resources.c:13
r reserved
Definition: btrfs.c:3006
#define progid(str)
Definition: exdisp.idl:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
const char * var
Definition: shader.c:5666
static WCHAR password[]
Definition: url.c:33
const CLSID * clsid
Definition: msctf.cpp:50
#define KEY_READ
Definition: nt_native.h:1026
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
BYTE * PBYTE
Definition: pedump.c:66
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
const WCHAR * str
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:171
#define TRACE(s)
Definition: solgame.cpp:4
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
uint32_t * LPDWORD
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12