Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/adsldp/adsldp.c
8795 views
1
/*
2
* Active Directory services LDAP Provider
3
*
4
* Copyright 2018 Dmitry Timoshkov
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
*/
20
21
#include <stdarg.h>
22
23
#define COBJMACROS
24
#include "windef.h"
25
#include "winbase.h"
26
#include "initguid.h"
27
#include "objbase.h"
28
#include "rpcproxy.h"
29
#include "rpc.h"
30
#include "iads.h"
31
#include "adshlp.h"
32
#include "adserr.h"
33
#define SECURITY_WIN32
34
#include "security.h"
35
#include "dsgetdc.h"
36
#include "lmcons.h"
37
#include "lmapibuf.h"
38
#include "winldap.h"
39
#include "winber.h"
40
41
#include "adsldp_private.h"
42
43
#include "wine/debug.h"
44
45
WINE_DEFAULT_DEBUG_CHANNEL(adsldp);
46
47
#ifndef LDAP_OPT_SERVER_CONTROLS
48
#define LDAP_OPT_SERVER_CONTROLS 0x0012
49
#endif
50
51
DEFINE_GUID(CLSID_LDAP,0x228d9a81,0xc302,0x11cf,0x9a,0xa4,0x00,0xaa,0x00,0x4a,0x56,0x91);
52
DEFINE_GUID(CLSID_LDAPNamespace,0x228d9a82,0xc302,0x11cf,0x9a,0xa4,0x00,0xaa,0x00,0x4a,0x56,0x91);
53
54
static HRESULT LDAPNamespace_create(REFIID riid, void **obj);
55
56
typedef struct
57
{
58
IParseDisplayName IParseDisplayName_iface;
59
LONG ref;
60
} LDAP_PARSE;
61
62
static inline LDAP_PARSE *impl_from_IParseDisplayName(IParseDisplayName *iface)
63
{
64
return CONTAINING_RECORD(iface, LDAP_PARSE, IParseDisplayName_iface);
65
}
66
67
static HRESULT WINAPI ldap_QueryInterface(IParseDisplayName *iface, REFIID riid, void **obj)
68
{
69
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
70
71
if (!riid || !obj) return E_INVALIDARG;
72
73
if (IsEqualGUID(riid, &IID_IUnknown) ||
74
IsEqualGUID(riid, &IID_IParseDisplayName))
75
{
76
IParseDisplayName_AddRef(iface);
77
*obj = iface;
78
return S_OK;
79
}
80
81
*obj = NULL;
82
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
83
return E_NOINTERFACE;
84
}
85
86
static ULONG WINAPI ldap_AddRef(IParseDisplayName *iface)
87
{
88
LDAP_PARSE *ldap = impl_from_IParseDisplayName(iface);
89
return InterlockedIncrement(&ldap->ref);
90
}
91
92
static ULONG WINAPI ldap_Release(IParseDisplayName *iface)
93
{
94
LDAP_PARSE *ldap = impl_from_IParseDisplayName(iface);
95
LONG ref = InterlockedDecrement(&ldap->ref);
96
97
if (!ref)
98
{
99
TRACE("destroying %p\n", iface);
100
free(ldap);
101
}
102
103
return ref;
104
}
105
106
static HRESULT WINAPI ldap_ParseDisplayName(IParseDisplayName *iface, IBindCtx *bc,
107
LPOLESTR name, ULONG *eaten, IMoniker **mk)
108
{
109
HRESULT hr;
110
IADsOpenDSObject *ads_open;
111
IDispatch *disp;
112
113
TRACE("%p,%p,%s,%p,%p\n", iface, bc, debugstr_w(name), eaten, mk);
114
115
hr = LDAPNamespace_create(&IID_IADsOpenDSObject, (void **)&ads_open);
116
if (hr != S_OK) return hr;
117
118
hr = IADsOpenDSObject_OpenDSObject(ads_open, name, NULL, NULL, ADS_SECURE_AUTHENTICATION, &disp);
119
if (hr != S_OK)
120
hr = IADsOpenDSObject_OpenDSObject(ads_open, name, NULL, NULL, 0, &disp);
121
if (hr == S_OK)
122
{
123
hr = CreatePointerMoniker((IUnknown *)disp, mk);
124
if (hr == S_OK)
125
*eaten = wcslen(name);
126
127
IDispatch_Release(disp);
128
}
129
130
IADsOpenDSObject_Release(ads_open);
131
132
return hr;
133
}
134
135
static const IParseDisplayNameVtbl LDAP_PARSE_vtbl =
136
{
137
ldap_QueryInterface,
138
ldap_AddRef,
139
ldap_Release,
140
ldap_ParseDisplayName
141
};
142
143
static HRESULT LDAP_create(REFIID riid, void **obj)
144
{
145
LDAP_PARSE *ldap;
146
HRESULT hr;
147
148
ldap = malloc(sizeof(*ldap));
149
if (!ldap) return E_OUTOFMEMORY;
150
151
ldap->IParseDisplayName_iface.lpVtbl = &LDAP_PARSE_vtbl;
152
ldap->ref = 1;
153
154
hr = IParseDisplayName_QueryInterface(&ldap->IParseDisplayName_iface, riid, obj);
155
IParseDisplayName_Release(&ldap->IParseDisplayName_iface);
156
157
return hr;
158
}
159
160
typedef struct
161
{
162
IADsADSystemInfo IADsADSystemInfo_iface;
163
LONG ref;
164
} AD_sysinfo;
165
166
static inline AD_sysinfo *impl_from_IADsADSystemInfo(IADsADSystemInfo *iface)
167
{
168
return CONTAINING_RECORD(iface, AD_sysinfo, IADsADSystemInfo_iface);
169
}
170
171
static HRESULT WINAPI sysinfo_QueryInterface(IADsADSystemInfo *iface, REFIID riid, void **obj)
172
{
173
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
174
175
if (!riid || !obj) return E_INVALIDARG;
176
177
if (IsEqualGUID(riid, &IID_IADsADSystemInfo) ||
178
IsEqualGUID(riid, &IID_IDispatch) ||
179
IsEqualGUID(riid, &IID_IUnknown))
180
{
181
IADsADSystemInfo_AddRef(iface);
182
*obj = iface;
183
return S_OK;
184
}
185
186
*obj = NULL;
187
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
188
return E_NOINTERFACE;
189
}
190
191
static ULONG WINAPI sysinfo_AddRef(IADsADSystemInfo *iface)
192
{
193
AD_sysinfo *sysinfo = impl_from_IADsADSystemInfo(iface);
194
return InterlockedIncrement(&sysinfo->ref);
195
}
196
197
static ULONG WINAPI sysinfo_Release(IADsADSystemInfo *iface)
198
{
199
AD_sysinfo *sysinfo = impl_from_IADsADSystemInfo(iface);
200
LONG ref = InterlockedDecrement(&sysinfo->ref);
201
202
if (!ref)
203
{
204
TRACE("destroying %p\n", iface);
205
free(sysinfo);
206
}
207
208
return ref;
209
}
210
211
static HRESULT WINAPI sysinfo_GetTypeInfoCount(IADsADSystemInfo *iface, UINT *count)
212
{
213
FIXME("%p,%p: stub\n", iface, count);
214
return E_NOTIMPL;
215
}
216
217
static HRESULT WINAPI sysinfo_GetTypeInfo(IADsADSystemInfo *iface, UINT index, LCID lcid, ITypeInfo **info)
218
{
219
FIXME("%p,%u,%#lx,%p: stub\n", iface, index, lcid, info);
220
return E_NOTIMPL;
221
}
222
223
static HRESULT WINAPI sysinfo_GetIDsOfNames(IADsADSystemInfo *iface, REFIID riid, LPOLESTR *names,
224
UINT count, LCID lcid, DISPID *dispid)
225
{
226
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
227
return E_NOTIMPL;
228
}
229
230
static HRESULT WINAPI sysinfo_Invoke(IADsADSystemInfo *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
231
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
232
{
233
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
234
params, result, excepinfo, argerr);
235
return E_NOTIMPL;
236
}
237
238
static HRESULT WINAPI sysinfo_get_UserName(IADsADSystemInfo *iface, BSTR *retval)
239
{
240
FIXME("%p,%p: stub\n", iface, retval);
241
return E_NOTIMPL;
242
}
243
244
static HRESULT WINAPI sysinfo_get_ComputerName(IADsADSystemInfo *iface, BSTR *retval)
245
{
246
ULONG size;
247
WCHAR *name;
248
249
TRACE("%p,%p\n", iface, retval);
250
251
size = 0;
252
GetComputerObjectNameW(NameFullyQualifiedDN, NULL, &size);
253
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
254
return HRESULT_FROM_WIN32(GetLastError());
255
256
name = SysAllocStringLen(NULL, size);
257
if (!name) return E_OUTOFMEMORY;
258
259
if (!GetComputerObjectNameW(NameFullyQualifiedDN, name, &size))
260
{
261
SysFreeString(name);
262
return HRESULT_FROM_WIN32(GetLastError());
263
}
264
265
*retval = name;
266
return S_OK;
267
}
268
269
static HRESULT WINAPI sysinfo_get_SiteName(IADsADSystemInfo *iface, BSTR *retval)
270
{
271
FIXME("%p,%p: stub\n", iface, retval);
272
return E_NOTIMPL;
273
}
274
275
static HRESULT WINAPI sysinfo_get_DomainShortName(IADsADSystemInfo *iface, BSTR *retval)
276
{
277
FIXME("%p,%p: stub\n", iface, retval);
278
return E_NOTIMPL;
279
}
280
281
static HRESULT WINAPI sysinfo_get_DomainDNSName(IADsADSystemInfo *iface, BSTR *retval)
282
{
283
FIXME("%p,%p: stub\n", iface, retval);
284
return E_NOTIMPL;
285
}
286
287
static HRESULT WINAPI sysinfo_get_ForestDNSName(IADsADSystemInfo *iface, BSTR *retval)
288
{
289
FIXME("%p,%p: stub\n", iface, retval);
290
return E_NOTIMPL;
291
}
292
293
static HRESULT WINAPI sysinfo_get_PDCRoleOwner(IADsADSystemInfo *iface, BSTR *retval)
294
{
295
FIXME("%p,%p: stub\n", iface, retval);
296
return E_NOTIMPL;
297
}
298
299
static HRESULT WINAPI sysinfo_get_SchemaRoleOwner(IADsADSystemInfo *iface, BSTR *retval)
300
{
301
FIXME("%p,%p: stub\n", iface, retval);
302
return E_NOTIMPL;
303
}
304
305
static HRESULT WINAPI sysinfo_get_IsNativeMode(IADsADSystemInfo *iface, VARIANT_BOOL *retval)
306
{
307
FIXME("%p,%p: stub\n", iface, retval);
308
return E_NOTIMPL;
309
}
310
311
static HRESULT WINAPI sysinfo_GetAnyDCName(IADsADSystemInfo *iface, BSTR *retval)
312
{
313
FIXME("%p,%p: stub\n", iface, retval);
314
return E_NOTIMPL;
315
}
316
317
static HRESULT WINAPI sysinfo_GetDCSiteName(IADsADSystemInfo *iface, BSTR server, BSTR *retval)
318
{
319
FIXME("%p,%s,%p: stub\n", iface, debugstr_w(server), retval);
320
return E_NOTIMPL;
321
}
322
323
static HRESULT WINAPI sysinfo_RefreshSchemaCache(IADsADSystemInfo *iface)
324
{
325
FIXME("%p: stub\n", iface);
326
return E_NOTIMPL;
327
}
328
329
static HRESULT WINAPI sysinfo_GetTrees(IADsADSystemInfo *iface, VARIANT *retval)
330
{
331
FIXME("%p,%p: stub\n", iface, retval);
332
return E_NOTIMPL;
333
}
334
335
static const IADsADSystemInfoVtbl IADsADSystemInfo_vtbl =
336
{
337
sysinfo_QueryInterface,
338
sysinfo_AddRef,
339
sysinfo_Release,
340
sysinfo_GetTypeInfoCount,
341
sysinfo_GetTypeInfo,
342
sysinfo_GetIDsOfNames,
343
sysinfo_Invoke,
344
sysinfo_get_UserName,
345
sysinfo_get_ComputerName,
346
sysinfo_get_SiteName,
347
sysinfo_get_DomainShortName,
348
sysinfo_get_DomainDNSName,
349
sysinfo_get_ForestDNSName,
350
sysinfo_get_PDCRoleOwner,
351
sysinfo_get_SchemaRoleOwner,
352
sysinfo_get_IsNativeMode,
353
sysinfo_GetAnyDCName,
354
sysinfo_GetDCSiteName,
355
sysinfo_RefreshSchemaCache,
356
sysinfo_GetTrees
357
};
358
359
static HRESULT ADSystemInfo_create(REFIID riid, void **obj)
360
{
361
AD_sysinfo *sysinfo;
362
HRESULT hr;
363
364
sysinfo = malloc(sizeof(*sysinfo));
365
if (!sysinfo) return E_OUTOFMEMORY;
366
367
sysinfo->IADsADSystemInfo_iface.lpVtbl = &IADsADSystemInfo_vtbl;
368
sysinfo->ref = 1;
369
370
hr = IADsADSystemInfo_QueryInterface(&sysinfo->IADsADSystemInfo_iface, riid, obj);
371
IADsADSystemInfo_Release(&sysinfo->IADsADSystemInfo_iface);
372
373
return hr;
374
}
375
376
typedef struct
377
{
378
IADs IADs_iface;
379
IADsOpenDSObject IADsOpenDSObject_iface;
380
IDirectorySearch IDirectorySearch_iface;
381
IDirectoryObject IDirectoryObject_iface;
382
IADsObjectOptions IADsObjectOptions_iface;
383
LONG ref;
384
LDAP *ld;
385
BSTR host;
386
BSTR object;
387
BSTR schema;
388
ULONG port;
389
ULONG attrs_count, attrs_count_allocated;
390
ADS_SEARCH_COLUMN *attrs;
391
struct attribute_type *at;
392
ULONG at_single_count, at_multiple_count;
393
struct
394
{
395
ADS_SCOPEENUM scope;
396
int pagesize;
397
int size_limit;
398
BOOL cache_results;
399
BOOL attribtypes_only;
400
BOOL tombstone;
401
} search;
402
} LDAP_namespace;
403
404
struct ldap_search_context
405
{
406
LDAPSearch *page;
407
LDAPMessage *res, *entry;
408
BerElement *ber;
409
ULONG count, pos;
410
BOOL add_ADsPath;
411
};
412
413
static inline LDAP_namespace *impl_from_IADs(IADs *iface)
414
{
415
return CONTAINING_RECORD(iface, LDAP_namespace, IADs_iface);
416
}
417
418
static HRESULT WINAPI ldapns_QueryInterface(IADs *iface, REFIID riid, void **obj)
419
{
420
LDAP_namespace *ldap = impl_from_IADs(iface);
421
422
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
423
424
if (!riid || !obj) return E_INVALIDARG;
425
426
if (IsEqualGUID(riid, &IID_IUnknown) ||
427
IsEqualGUID(riid, &IID_IDispatch) ||
428
IsEqualGUID(riid, &IID_IADs))
429
{
430
IADs_AddRef(iface);
431
*obj = iface;
432
return S_OK;
433
}
434
435
if (IsEqualGUID(riid, &IID_IADsOpenDSObject))
436
{
437
IADs_AddRef(iface);
438
*obj = &ldap->IADsOpenDSObject_iface;
439
return S_OK;
440
}
441
442
if (IsEqualGUID(riid, &IID_IDirectorySearch))
443
{
444
if (!ldap->ld || (ldap->object && !wcsicmp(ldap->object, L"rootDSE")))
445
return E_NOINTERFACE;
446
447
IADs_AddRef(iface);
448
*obj = &ldap->IDirectorySearch_iface;
449
return S_OK;
450
}
451
452
if (IsEqualGUID(riid, &IID_IDirectoryObject))
453
{
454
IADs_AddRef(iface);
455
*obj = &ldap->IDirectoryObject_iface;
456
return S_OK;
457
}
458
459
if (IsEqualGUID(riid, &IID_IADsObjectOptions))
460
{
461
if (!ldap->ld || (ldap->object && wcsicmp(ldap->object, L"rootDSE") != 0))
462
return E_NOINTERFACE;
463
464
IADs_AddRef(iface);
465
*obj = &ldap->IADsObjectOptions_iface;
466
return S_OK;
467
}
468
469
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
470
return E_NOINTERFACE;
471
}
472
473
static ULONG WINAPI ldapns_AddRef(IADs *iface)
474
{
475
LDAP_namespace *ldap = impl_from_IADs(iface);
476
return InterlockedIncrement(&ldap->ref);
477
}
478
479
static void free_attributes(LDAP_namespace *ldap)
480
{
481
ULONG i;
482
483
if (!ldap->attrs) return;
484
485
for (i = 0; i < ldap->attrs_count; i++)
486
IDirectorySearch_FreeColumn(&ldap->IDirectorySearch_iface, &ldap->attrs[i]);
487
488
free(ldap->attrs);
489
ldap->attrs = NULL;
490
ldap->attrs_count = 0;
491
}
492
493
static ULONG WINAPI ldapns_Release(IADs *iface)
494
{
495
LDAP_namespace *ldap = impl_from_IADs(iface);
496
LONG ref = InterlockedDecrement(&ldap->ref);
497
498
if (!ref)
499
{
500
TRACE("destroying %p\n", iface);
501
if (ldap->ld) ldap_unbind(ldap->ld);
502
SysFreeString(ldap->host);
503
SysFreeString(ldap->object);
504
free_attributes(ldap);
505
free_attribute_types(ldap->at, ldap->at_single_count + ldap->at_multiple_count);
506
free(ldap);
507
}
508
509
return ref;
510
}
511
512
static HRESULT WINAPI ldapns_GetTypeInfoCount(IADs *iface, UINT *count)
513
{
514
FIXME("%p,%p: stub\n", iface, count);
515
return E_NOTIMPL;
516
}
517
518
static HRESULT WINAPI ldapns_GetTypeInfo(IADs *iface, UINT index, LCID lcid, ITypeInfo **info)
519
{
520
FIXME("%p,%u,%#lx,%p: stub\n", iface, index, lcid, info);
521
return E_NOTIMPL;
522
}
523
524
static HRESULT WINAPI ldapns_GetIDsOfNames(IADs *iface, REFIID riid, LPOLESTR *names,
525
UINT count, LCID lcid, DISPID *dispid)
526
{
527
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
528
return E_NOTIMPL;
529
}
530
531
static HRESULT WINAPI ldapns_Invoke(IADs *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
532
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
533
{
534
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
535
params, result, excepinfo, argerr);
536
return E_NOTIMPL;
537
}
538
539
static HRESULT WINAPI ldapns_get_Name(IADs *iface, BSTR *retval)
540
{
541
FIXME("%p,%p: stub\n", iface, retval);
542
return E_NOTIMPL;
543
}
544
545
static HRESULT WINAPI ldapns_get_Class(IADs *iface, BSTR *retval)
546
{
547
FIXME("%p,%p: stub\n", iface, retval);
548
return E_NOTIMPL;
549
}
550
551
static HRESULT WINAPI ldapns_get_GUID(IADs *iface, BSTR *retval)
552
{
553
FIXME("%p,%p: stub\n", iface, retval);
554
return E_NOTIMPL;
555
}
556
557
static HRESULT WINAPI ldapns_get_ADsPath(IADs *iface, BSTR *retval)
558
{
559
FIXME("%p,%p: stub\n", iface, retval);
560
return E_NOTIMPL;
561
}
562
563
static HRESULT WINAPI ldapns_get_Parent(IADs *iface, BSTR *retval)
564
{
565
FIXME("%p,%p: stub\n", iface, retval);
566
return E_NOTIMPL;
567
}
568
569
static HRESULT WINAPI ldapns_get_Schema(IADs *iface, BSTR *retval)
570
{
571
LDAP_namespace *ldap = impl_from_IADs(iface);
572
HRESULT hr;
573
574
TRACE("%p,%p\n", iface, retval);
575
576
if (!ldap->schema)
577
{
578
VARIANT var, item;
579
LONG start, end;
580
581
hr = IADs_GetEx(iface, (BSTR)L"objectClass", &var);
582
if (hr != S_OK) return E_ADS_PROPERTY_NOT_SUPPORTED;
583
if (V_VT(&var) != (VT_ARRAY | VT_VARIANT))
584
{
585
VariantClear(&var);
586
return E_ADS_PROPERTY_NOT_SUPPORTED;
587
}
588
589
SafeArrayGetLBound(V_ARRAY(&var), 1, &start);
590
SafeArrayGetUBound(V_ARRAY(&var), 1, &end);
591
VariantInit(&item);
592
hr = SafeArrayGetElement(V_ARRAY(&var), &start, &item);
593
if (hr == S_OK)
594
{
595
if (V_VT(&item) == VT_BSTR)
596
{
597
if (!wcsicmp(V_BSTR(&item), L"top"))
598
{
599
VariantClear(&item);
600
hr = SafeArrayGetElement(V_ARRAY(&var), &end, &item);
601
if (hr == S_OK)
602
ldap->schema = SysAllocString(V_BSTR(&item));
603
}
604
else
605
ldap->schema = SysAllocString(V_BSTR(&item));
606
}
607
608
VariantClear(&item);
609
}
610
}
611
612
TRACE("ldap->schema: %s\n", debugstr_w(ldap->schema));
613
if (!ldap->schema) return E_ADS_PROPERTY_NOT_SUPPORTED;
614
615
*retval = SysAllocStringLen(NULL, wcslen(ldap->schema) + sizeof(L"LDAP://schema/") / sizeof(WCHAR));
616
if (!*retval) return E_OUTOFMEMORY;
617
618
wcscpy(*retval, L"LDAP://schema/");
619
wcscat(*retval, ldap->schema);
620
return S_OK;
621
}
622
623
static HRESULT WINAPI ldapns_GetInfo(IADs *iface)
624
{
625
HRESULT hr;
626
VARIANT var;
627
628
TRACE("%p\n", iface);
629
630
hr = ADsBuildVarArrayStr(NULL, 0, &var);
631
if (hr == S_OK)
632
{
633
hr = IADs_GetInfoEx(iface, var, 0);
634
VariantClear(&var);
635
}
636
return hr;
637
}
638
639
static HRESULT WINAPI ldapns_SetInfo(IADs *iface)
640
{
641
FIXME("%p: stub\n", iface);
642
return E_NOTIMPL;
643
}
644
645
static HRESULT adsvalue_to_variant(const ADSVALUE *value, VARIANT *var)
646
{
647
HRESULT hr = S_OK;
648
void *val;
649
650
switch (value->dwType)
651
{
652
default:
653
FIXME("no special handling for type %d\n", value->dwType);
654
/* fall through */
655
case ADSTYPE_DN_STRING:
656
case ADSTYPE_CASE_EXACT_STRING:
657
case ADSTYPE_CASE_IGNORE_STRING:
658
case ADSTYPE_PRINTABLE_STRING:
659
val = SysAllocString(value->CaseIgnoreString);
660
if (!val) return E_OUTOFMEMORY;
661
662
V_VT(var) = VT_BSTR;
663
V_BSTR(var) = val;
664
break;
665
666
case ADSTYPE_BOOLEAN:
667
V_VT(var) = VT_BOOL;
668
V_BOOL(var) = value->Boolean ? VARIANT_TRUE : VARIANT_FALSE;
669
break;
670
671
case ADSTYPE_INTEGER:
672
V_VT(var) = VT_I4;
673
V_I4(var) = value->Integer;
674
break;
675
676
case ADSTYPE_LARGE_INTEGER:
677
V_VT(var) = VT_I8;
678
V_I8(var) = value->LargeInteger.QuadPart;
679
break;
680
681
case ADSTYPE_OCTET_STRING:
682
case ADSTYPE_NT_SECURITY_DESCRIPTOR:
683
{
684
SAFEARRAY *sa;
685
686
sa = SafeArrayCreateVector(VT_UI1, 0, value->OctetString.dwLength);
687
if (!sa) return E_OUTOFMEMORY;
688
689
memcpy(sa->pvData, value->OctetString.lpValue, value->OctetString.dwLength);
690
V_VT(var) = VT_ARRAY | VT_UI1;
691
V_ARRAY(var) = sa;
692
break;
693
}
694
695
case ADSTYPE_UTC_TIME:
696
{
697
DOUBLE date;
698
699
if (!SystemTimeToVariantTime((SYSTEMTIME *)&value->UTCTime, &date))
700
return E_FAIL;
701
702
V_VT(var) = VT_DATE;
703
V_DATE(var) = date;
704
break;
705
}
706
707
case ADSTYPE_DN_WITH_BINARY:
708
{
709
SAFEARRAY *sa;
710
IADsDNWithBinary *dn = NULL;
711
VARIANT data;
712
713
sa = SafeArrayCreateVector(VT_UI1, 0, value->pDNWithBinary->dwLength);
714
if (!sa) return E_OUTOFMEMORY;
715
memcpy(sa->pvData, value->pDNWithBinary->lpBinaryValue, value->pDNWithBinary->dwLength);
716
717
hr = CoCreateInstance(&CLSID_DNWithBinary, 0, CLSCTX_INPROC_SERVER, &IID_IADsDNWithBinary, (void **)&dn);
718
if (hr != S_OK) goto fail;
719
720
V_VT(&data) = VT_ARRAY | VT_UI1;
721
V_ARRAY(&data) = sa;
722
hr = IADsDNWithBinary_put_BinaryValue(dn, data);
723
if (hr != S_OK) goto fail;
724
725
hr = IADsDNWithBinary_put_DNString(dn, value->pDNWithBinary->pszDNString);
726
if (hr != S_OK) goto fail;
727
728
V_VT(var) = VT_DISPATCH;
729
V_DISPATCH(var) = (IDispatch *)dn;
730
break;
731
fail:
732
SafeArrayDestroy(sa);
733
if (dn) IADsDNWithBinary_Release(dn);
734
return hr;
735
736
}
737
}
738
739
TRACE("=> %s\n", wine_dbgstr_variant(var));
740
return hr;
741
}
742
743
static HRESULT adsvalues_to_array(const ADSVALUE *values, LONG count, VARIANT *var)
744
{
745
HRESULT hr;
746
SAFEARRAY *sa;
747
VARIANT item;
748
LONG i;
749
750
sa = SafeArrayCreateVector(VT_VARIANT, 0, count);
751
if (!sa) return E_OUTOFMEMORY;
752
753
for (i = 0; i < count; i++)
754
{
755
hr = adsvalue_to_variant(&values[i], &item);
756
if (hr != S_OK) goto fail;
757
758
hr = SafeArrayPutElement(sa, &i, &item);
759
VariantClear(&item);
760
if (hr != S_OK) goto fail;
761
}
762
763
V_VT(var) = VT_ARRAY | VT_VARIANT;
764
V_ARRAY(var) = sa;
765
return S_OK;
766
767
fail:
768
SafeArrayDestroy(sa);
769
return hr;
770
}
771
772
static HRESULT WINAPI ldapns_Get(IADs *iface, BSTR name, VARIANT *prop)
773
{
774
LDAP_namespace *ldap = impl_from_IADs(iface);
775
HRESULT hr;
776
ULONG i;
777
778
TRACE("%p,%s,%p\n", iface, debugstr_w(name), prop);
779
780
if (!name || !prop) return E_ADS_BAD_PARAMETER;
781
782
if (!ldap->attrs_count)
783
{
784
hr = IADs_GetInfo(iface);
785
if (hr != S_OK) return hr;
786
}
787
788
for (i = 0; i < ldap->attrs_count; i++)
789
{
790
if (!wcsicmp(name, ldap->attrs[i].pszAttrName))
791
{
792
if (!ldap->attrs[i].dwNumValues)
793
{
794
V_BSTR(prop) = NULL;
795
V_VT(prop) = VT_BSTR;
796
return S_OK;
797
}
798
799
TRACE("attr %s has %lu values\n", debugstr_w(ldap->attrs[i].pszAttrName), ldap->attrs[i].dwNumValues);
800
801
if (ldap->attrs[i].dwNumValues > 1)
802
return adsvalues_to_array(ldap->attrs[i].pADsValues, ldap->attrs[i].dwNumValues, prop);
803
else
804
return adsvalue_to_variant(&ldap->attrs[i].pADsValues[0], prop);
805
}
806
}
807
808
return E_ADS_PROPERTY_NOT_FOUND;
809
}
810
811
static HRESULT WINAPI ldapns_Put(IADs *iface, BSTR name, VARIANT prop)
812
{
813
FIXME("%p,%s,%s: stub\n", iface, debugstr_w(name), wine_dbgstr_variant(&prop));
814
return E_NOTIMPL;
815
}
816
817
static HRESULT WINAPI ldapns_GetEx(IADs *iface, BSTR name, VARIANT *prop)
818
{
819
LDAP_namespace *ldap = impl_from_IADs(iface);
820
HRESULT hr;
821
ULONG i;
822
823
TRACE("%p,%s,%p\n", iface, debugstr_w(name), prop);
824
825
if (!name || !prop) return E_ADS_BAD_PARAMETER;
826
827
if (!ldap->attrs_count)
828
{
829
hr = IADs_GetInfo(iface);
830
if (hr != S_OK) return hr;
831
}
832
833
for (i = 0; i < ldap->attrs_count; i++)
834
{
835
if (!wcsicmp(name, ldap->attrs[i].pszAttrName))
836
{
837
if (!ldap->attrs[i].dwNumValues)
838
{
839
V_BSTR(prop) = NULL;
840
V_VT(prop) = VT_BSTR;
841
return S_OK;
842
}
843
844
TRACE("attr %s has %lu values\n", debugstr_w(ldap->attrs[i].pszAttrName), ldap->attrs[i].dwNumValues);
845
846
return adsvalues_to_array(ldap->attrs[i].pADsValues, ldap->attrs[i].dwNumValues, prop);
847
}
848
}
849
850
return E_ADS_PROPERTY_NOT_FOUND;
851
}
852
853
static HRESULT WINAPI ldapns_PutEx(IADs *iface, LONG code, BSTR name, VARIANT prop)
854
{
855
FIXME("%p,%ld,%s,%s: stub\n", iface, code, debugstr_w(name), wine_dbgstr_variant(&prop));
856
return E_NOTIMPL;
857
}
858
859
static HRESULT add_attribute(LDAP_namespace *ldap, ADS_SEARCH_COLUMN *attr)
860
{
861
ADS_SEARCH_COLUMN *new_attrs;
862
863
if (!ldap->attrs)
864
{
865
ldap->attrs = malloc(256 * sizeof(ldap->attrs[0]));
866
if (!ldap->attrs) return E_OUTOFMEMORY;
867
ldap->attrs_count_allocated = 256;
868
}
869
else if (ldap->attrs_count_allocated < ldap->attrs_count + 1)
870
{
871
new_attrs = realloc(ldap->attrs, (ldap->attrs_count_allocated * 2) * sizeof(*new_attrs));
872
if (!new_attrs) return E_OUTOFMEMORY;
873
874
ldap->attrs_count_allocated *= 2;
875
ldap->attrs = new_attrs;
876
}
877
878
ldap->attrs[ldap->attrs_count] = *attr;
879
ldap->attrs_count++;
880
881
return S_OK;
882
}
883
884
static HRESULT WINAPI ldapns_GetInfoEx(IADs *iface, VARIANT prop, LONG reserved)
885
{
886
LDAP_namespace *ldap = impl_from_IADs(iface);
887
HRESULT hr;
888
SAFEARRAY *sa;
889
VARIANT *item;
890
WCHAR **props = NULL;
891
DWORD i, count;
892
ADS_SEARCHPREF_INFO pref[3];
893
ADS_SEARCH_HANDLE sh;
894
ADS_SEARCH_COLUMN col;
895
896
TRACE("%p,%s,%ld\n", iface, wine_dbgstr_variant(&prop), reserved);
897
898
free_attributes(ldap);
899
900
if (!ldap->ld) return E_NOTIMPL;
901
902
if (V_VT(&prop) != (VT_ARRAY | VT_VARIANT))
903
return E_ADS_BAD_PARAMETER;
904
905
sa = V_ARRAY(&prop);
906
if (sa->cDims != 1)
907
return E_ADS_BAD_PARAMETER;
908
909
hr = SafeArrayAccessData(sa, (void *)&item);
910
if (hr != S_OK) return hr;
911
912
count = sa->rgsabound[0].cElements;
913
if (count)
914
{
915
props = malloc((count + 1) * sizeof(props[0]));
916
if (!props)
917
{
918
hr = E_OUTOFMEMORY;
919
goto exit;
920
}
921
922
for (i = 0; i < count; i++)
923
{
924
if (V_VT(&item[i]) != VT_BSTR)
925
{
926
hr = E_ADS_BAD_PARAMETER;
927
goto exit;
928
}
929
props[i] = V_BSTR(&item[i]);
930
}
931
}
932
else
933
count = ~0;
934
935
pref[0].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
936
pref[0].vValue.dwType = ADSTYPE_INTEGER;
937
pref[0].vValue.Integer = ADS_SCOPE_BASE;
938
pref[0].dwStatus = 0;
939
940
pref[1].dwSearchPref = ADS_SEARCHPREF_ATTRIBTYPES_ONLY;
941
pref[1].vValue.dwType = ADSTYPE_BOOLEAN;
942
pref[1].vValue.Boolean = FALSE;
943
pref[1].dwStatus = 0;
944
945
pref[2].dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT;
946
pref[2].vValue.dwType = ADSTYPE_INTEGER;
947
pref[2].vValue.Integer = 20;
948
pref[2].dwStatus = 0;
949
950
IDirectorySearch_SetSearchPreference(&ldap->IDirectorySearch_iface, pref, ARRAY_SIZE(pref));
951
952
hr = IDirectorySearch_ExecuteSearch(&ldap->IDirectorySearch_iface, (WCHAR *)L"(objectClass=*)", props, count, &sh);
953
if (hr != S_OK)
954
{
955
TRACE("ExecuteSearch error %#lx\n", hr);
956
goto exit;
957
}
958
959
while (IDirectorySearch_GetNextRow(&ldap->IDirectorySearch_iface, sh) != S_ADS_NOMORE_ROWS)
960
{
961
WCHAR *name;
962
while (IDirectorySearch_GetNextColumnName(&ldap->IDirectorySearch_iface, sh, &name) != S_ADS_NOMORE_COLUMNS)
963
{
964
hr = IDirectorySearch_GetColumn(&ldap->IDirectorySearch_iface, sh, name, &col);
965
if (hr == S_OK)
966
add_attribute(ldap, &col);
967
968
FreeADsMem(name);
969
}
970
}
971
972
IDirectorySearch_CloseSearchHandle(&ldap->IDirectorySearch_iface, sh);
973
exit:
974
free(props);
975
SafeArrayUnaccessData(sa);
976
return hr;
977
}
978
979
static const IADsVtbl IADs_vtbl =
980
{
981
ldapns_QueryInterface,
982
ldapns_AddRef,
983
ldapns_Release,
984
ldapns_GetTypeInfoCount,
985
ldapns_GetTypeInfo,
986
ldapns_GetIDsOfNames,
987
ldapns_Invoke,
988
ldapns_get_Name,
989
ldapns_get_Class,
990
ldapns_get_GUID,
991
ldapns_get_ADsPath,
992
ldapns_get_Parent,
993
ldapns_get_Schema,
994
ldapns_GetInfo,
995
ldapns_SetInfo,
996
ldapns_Get,
997
ldapns_Put,
998
ldapns_GetEx,
999
ldapns_PutEx,
1000
ldapns_GetInfoEx
1001
};
1002
1003
static inline LDAP_namespace *impl_from_IADsOpenDSObject(IADsOpenDSObject *iface)
1004
{
1005
return CONTAINING_RECORD(iface, LDAP_namespace, IADsOpenDSObject_iface);
1006
}
1007
1008
static HRESULT WINAPI openobj_QueryInterface(IADsOpenDSObject *iface, REFIID riid, void **obj)
1009
{
1010
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
1011
1012
if (!riid || !obj) return E_INVALIDARG;
1013
1014
if (IsEqualGUID(riid, &IID_IADsOpenDSObject) ||
1015
IsEqualGUID(riid, &IID_IDispatch) ||
1016
IsEqualGUID(riid, &IID_IUnknown))
1017
{
1018
IADsOpenDSObject_AddRef(iface);
1019
*obj = iface;
1020
return S_OK;
1021
}
1022
1023
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
1024
return E_NOINTERFACE;
1025
}
1026
1027
static ULONG WINAPI openobj_AddRef(IADsOpenDSObject *iface)
1028
{
1029
LDAP_namespace *ldap = impl_from_IADsOpenDSObject(iface);
1030
return IADs_AddRef(&ldap->IADs_iface);
1031
}
1032
1033
static ULONG WINAPI openobj_Release(IADsOpenDSObject *iface)
1034
{
1035
LDAP_namespace *ldap = impl_from_IADsOpenDSObject(iface);
1036
return IADs_Release(&ldap->IADs_iface);
1037
}
1038
1039
static HRESULT WINAPI openobj_GetTypeInfoCount(IADsOpenDSObject *iface, UINT *count)
1040
{
1041
FIXME("%p,%p: stub\n", iface, count);
1042
return E_NOTIMPL;
1043
}
1044
1045
static HRESULT WINAPI openobj_GetTypeInfo(IADsOpenDSObject *iface, UINT index, LCID lcid, ITypeInfo **info)
1046
{
1047
FIXME("%p,%u,%#lx,%p: stub\n", iface, index, lcid, info);
1048
return E_NOTIMPL;
1049
}
1050
1051
static HRESULT WINAPI openobj_GetIDsOfNames(IADsOpenDSObject *iface, REFIID riid, LPOLESTR *names,
1052
UINT count, LCID lcid, DISPID *dispid)
1053
{
1054
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
1055
return E_NOTIMPL;
1056
}
1057
1058
static HRESULT WINAPI openobj_Invoke(IADsOpenDSObject *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
1059
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
1060
{
1061
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
1062
params, result, excepinfo, argerr);
1063
return E_NOTIMPL;
1064
}
1065
1066
static HRESULT parse_path(WCHAR *path, BSTR *host, ULONG *port, BSTR *object)
1067
{
1068
WCHAR *p, *p_host;
1069
int host_len;
1070
1071
if (host) *host = NULL;
1072
if (port) *port = 0;
1073
if (object) *object = NULL;
1074
1075
if (wcsnicmp(path, L"LDAP:", 5) != 0)
1076
return E_ADS_BAD_PATHNAME;
1077
1078
p = path + 5;
1079
if (!*p) return S_OK;
1080
1081
if (*p++ != '/' || *p++ != '/' || !*p)
1082
return E_ADS_BAD_PATHNAME;
1083
1084
p_host = p;
1085
host_len = 0;
1086
while (*p && *p != '/')
1087
{
1088
if (*p == ':')
1089
{
1090
ULONG dummy;
1091
if (!port) port = &dummy;
1092
*port = wcstol(p + 1, &p, 10);
1093
if (*p && *p != '/') return E_ADS_BAD_PATHNAME;
1094
}
1095
else
1096
{
1097
p++;
1098
host_len++;
1099
}
1100
}
1101
if (host_len == 0) return E_ADS_BAD_PATHNAME;
1102
1103
if (host)
1104
{
1105
*host = SysAllocStringLen(p_host, host_len);
1106
if (!*host) return E_OUTOFMEMORY;
1107
}
1108
1109
if (!*p) return S_OK;
1110
1111
if (*p++ != '/' || !*p)
1112
{
1113
SysFreeString(*host);
1114
return E_ADS_BAD_PATHNAME;
1115
}
1116
1117
if (object)
1118
{
1119
*object = SysAllocString(p);
1120
if (!*object)
1121
{
1122
SysFreeString(*host);
1123
return E_OUTOFMEMORY;
1124
}
1125
}
1126
1127
return S_OK;
1128
}
1129
1130
static HRESULT bind_to_host(BSTR host, ULONG port, LONG flags, BSTR user, BSTR password, LDAP **ld_ret)
1131
{
1132
LDAP *ld;
1133
ULONG err;
1134
int version;
1135
HRESULT hr;
1136
1137
TRACE("binding to host %s, port %lu\n", debugstr_w(host), port);
1138
1139
ld = ldap_initW(host, port);
1140
if (!ld)
1141
{
1142
hr = HRESULT_FROM_WIN32(ERROR_DS_SERVER_DOWN);
1143
goto fail;
1144
}
1145
1146
version = LDAP_VERSION3;
1147
err = ldap_set_optionW(ld, LDAP_OPT_PROTOCOL_VERSION, &version);
1148
if (err != LDAP_SUCCESS)
1149
{
1150
hr = HRESULT_FROM_WIN32(map_ldap_error(err));
1151
goto fail;
1152
}
1153
1154
err = ldap_connect(ld, NULL);
1155
if (err != LDAP_SUCCESS)
1156
{
1157
hr = HRESULT_FROM_WIN32(map_ldap_error(err));
1158
goto fail;
1159
}
1160
1161
if (flags & ADS_SECURE_AUTHENTICATION)
1162
{
1163
SEC_WINNT_AUTH_IDENTITY_W id;
1164
1165
id.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
1166
id.Domain = (unsigned short *)host;
1167
id.DomainLength = host ? wcslen(host) : 0;
1168
id.User = (unsigned short *)user;
1169
id.UserLength = user ? wcslen(user) : 0;
1170
id.Password = (unsigned short *)password;
1171
id.PasswordLength = password ? wcslen(password) : 0;
1172
1173
err = ldap_bind_sW(ld, NULL, (WCHAR *)&id, LDAP_AUTH_NEGOTIATE);
1174
if (err != LDAP_SUCCESS)
1175
{
1176
TRACE("ldap_bind_sW error %#lx\n", err);
1177
hr = HRESULT_FROM_WIN32(map_ldap_error(err));
1178
goto fail;
1179
}
1180
}
1181
else
1182
{
1183
err = ldap_simple_bind_sW(ld, user, password);
1184
if (err != LDAP_SUCCESS)
1185
{
1186
TRACE("ldap_simple_bind_sW error %#lx\n", err);
1187
hr = HRESULT_FROM_WIN32(map_ldap_error(err));
1188
goto fail;
1189
}
1190
}
1191
1192
*ld_ret = ld;
1193
return S_OK;
1194
1195
fail:
1196
ldap_unbind(ld);
1197
*ld_ret = NULL;
1198
return hr;
1199
}
1200
1201
static HRESULT WINAPI openobj_OpenDSObject(IADsOpenDSObject *iface, BSTR path, BSTR user, BSTR password,
1202
LONG flags, IDispatch **obj)
1203
{
1204
BSTR host, object;
1205
ULONG port;
1206
IADs *ads;
1207
LDAP *ld = NULL;
1208
HRESULT hr;
1209
ULONG at_single_count = 0, at_multiple_count = 0;
1210
struct attribute_type *at = NULL;
1211
1212
TRACE("%p,%s,%s,%p,%08lx,%p\n", iface, debugstr_w(path), debugstr_w(user), password, flags, obj);
1213
1214
hr = parse_path(path, &host, &port, &object);
1215
if (hr != S_OK) return hr;
1216
1217
TRACE("host %s, port %lu, object %s\n", debugstr_w(host), port, debugstr_w(object));
1218
1219
if (host)
1220
{
1221
if (!wcsicmp(host, L"rootDSE"))
1222
{
1223
if (object)
1224
{
1225
hr = E_ADS_BAD_PATHNAME;
1226
goto fail;
1227
}
1228
1229
object = host;
1230
host = NULL;
1231
}
1232
1233
hr = bind_to_host(host, port, flags, user, password, &ld);
1234
if (hr != S_OK && host)
1235
{
1236
if (hr != HRESULT_FROM_WIN32(ERROR_DS_SERVER_DOWN)) goto fail;
1237
1238
SysFreeString(host);
1239
if (!object)
1240
{
1241
host = NULL;
1242
object = SysAllocString(path + 7); /* skip LDAP:// */
1243
1244
TRACE("retrying with host %s, port %lu, object %s\n", debugstr_w(host), port, debugstr_w(object));
1245
hr = bind_to_host(host, port, flags, user, password, &ld);
1246
}
1247
else
1248
{
1249
SysFreeString(object);
1250
object = SysAllocString(path + 7); /* skip LDAP:// */
1251
TRACE("Assume that %s is virtual object\n", debugstr_w(object));
1252
hr = S_OK;
1253
}
1254
}
1255
1256
if (hr != S_OK) goto fail;
1257
at = load_schema(ld, &at_single_count, &at_multiple_count);
1258
}
1259
1260
hr = LDAPNamespace_create(&IID_IADs, (void **)&ads);
1261
if (hr == S_OK)
1262
{
1263
LDAP_namespace *ldap = impl_from_IADs(ads);
1264
1265
ldap->ld = ld;
1266
ldap->host = host;
1267
ldap->port = port;
1268
ldap->object = object;
1269
ldap->at = at;
1270
ldap->at_single_count = at_single_count;
1271
ldap->at_multiple_count = at_multiple_count;
1272
1273
/* Windows fails to create IADs if it doesn't have an associated schema attribute */
1274
if (ld && object && wcsicmp(object, L"rootDSE") != 0)
1275
{
1276
BSTR schema;
1277
1278
if (IADs_get_Schema(ads, &schema) != S_OK)
1279
{
1280
IADs_Release(ads);
1281
return E_ADS_BAD_PATHNAME;
1282
}
1283
1284
SysFreeString(schema);
1285
}
1286
1287
hr = IADs_QueryInterface(ads, &IID_IDispatch, (void **)obj);
1288
IADs_Release(ads);
1289
1290
return hr;
1291
}
1292
1293
fail:
1294
SysFreeString(host);
1295
SysFreeString(object);
1296
1297
return hr;
1298
}
1299
1300
static const IADsOpenDSObjectVtbl IADsOpenDSObject_vtbl =
1301
{
1302
openobj_QueryInterface,
1303
openobj_AddRef,
1304
openobj_Release,
1305
openobj_GetTypeInfoCount,
1306
openobj_GetTypeInfo,
1307
openobj_GetIDsOfNames,
1308
openobj_Invoke,
1309
openobj_OpenDSObject
1310
};
1311
1312
static inline LDAP_namespace *impl_from_IDirectorySearch(IDirectorySearch *iface)
1313
{
1314
return CONTAINING_RECORD(iface, LDAP_namespace, IDirectorySearch_iface);
1315
}
1316
1317
static HRESULT WINAPI search_QueryInterface(IDirectorySearch *iface, REFIID riid, void **obj)
1318
{
1319
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
1320
1321
if (!riid || !obj) return E_INVALIDARG;
1322
1323
if (IsEqualGUID(riid, &IID_IDirectorySearch) ||
1324
IsEqualGUID(riid, &IID_IUnknown))
1325
{
1326
IDirectorySearch_AddRef(iface);
1327
*obj = iface;
1328
return S_OK;
1329
}
1330
1331
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
1332
return E_NOINTERFACE;
1333
}
1334
1335
static ULONG WINAPI search_AddRef(IDirectorySearch *iface)
1336
{
1337
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1338
return IADs_AddRef(&ldap->IADs_iface);
1339
}
1340
1341
static ULONG WINAPI search_Release(IDirectorySearch *iface)
1342
{
1343
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1344
return IADs_Release(&ldap->IADs_iface);
1345
}
1346
1347
static HRESULT WINAPI search_SetSearchPreference(IDirectorySearch *iface, PADS_SEARCHPREF_INFO prefs, DWORD count)
1348
{
1349
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1350
HRESULT hr = S_OK;
1351
DWORD i;
1352
1353
TRACE("%p,%p,%lu\n", iface, prefs, count);
1354
1355
for (i = 0; i < count; i++)
1356
{
1357
switch (prefs[i].dwSearchPref)
1358
{
1359
case ADS_SEARCHPREF_SEARCH_SCOPE:
1360
if (prefs[i].vValue.dwType != ADSTYPE_INTEGER)
1361
{
1362
FIXME("ADS_SEARCHPREF_SEARCH_SCOPE: unsupported dwType %d\n", prefs[i].vValue.dwType);
1363
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1364
break;
1365
}
1366
1367
switch (prefs[i].vValue.Integer)
1368
{
1369
case ADS_SCOPE_BASE:
1370
case ADS_SCOPE_ONELEVEL:
1371
case ADS_SCOPE_SUBTREE:
1372
TRACE("SEARCH_SCOPE: %ld\n", prefs[i].vValue.Integer);
1373
ldap->search.scope = prefs[i].vValue.Integer;
1374
prefs[i].dwStatus = ADS_STATUS_S_OK;
1375
break;
1376
1377
default:
1378
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1379
break;
1380
}
1381
break;
1382
1383
case ADS_SEARCHPREF_SECURITY_MASK:
1384
{
1385
int security_mask;
1386
ULONG err;
1387
BerElement *ber;
1388
struct berval *berval;
1389
LDAPControlW *ctrls[2], mask;
1390
1391
if (prefs[i].vValue.dwType != ADSTYPE_INTEGER)
1392
{
1393
FIXME("ADS_SEARCHPREF_SECURITY_MASK: not supported dwType %d\n", prefs[i].vValue.dwType);
1394
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1395
break;
1396
}
1397
1398
TRACE("SECURITY_MASK: %08lx\n", prefs[i].vValue.Integer);
1399
security_mask = prefs[i].vValue.Integer;
1400
if (!security_mask)
1401
security_mask = ADS_SECURITY_INFO_OWNER;
1402
1403
ber = ber_alloc_t(LBER_USE_DER);
1404
if (!ber || ber_printf(ber, (char *)"{i}", security_mask) == -1 || ber_flatten(ber, &berval) == -1)
1405
{
1406
ber_free(ber, 1);
1407
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREF;
1408
break;
1409
}
1410
TRACE("ber: %s\n", debugstr_an(berval->bv_val, berval->bv_len));
1411
1412
mask.ldctl_oid = (WCHAR *)L"1.2.840.113556.1.4.801";
1413
mask.ldctl_iscritical = TRUE;
1414
mask.ldctl_value.bv_val = berval->bv_val;
1415
mask.ldctl_value.bv_len = berval->bv_len;
1416
ctrls[0] = &mask;
1417
ctrls[1] = NULL;
1418
err = ldap_set_optionW(ldap->ld, LDAP_OPT_SERVER_CONTROLS, ctrls);
1419
if (err != LDAP_SUCCESS)
1420
{
1421
TRACE("ldap_set_option error %#lx\n", err);
1422
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREF;
1423
hr = S_ADS_ERRORSOCCURRED;
1424
}
1425
else
1426
prefs[i].dwStatus = ADS_STATUS_S_OK;
1427
1428
ber_bvfree(berval);
1429
ber_free(ber, 1);
1430
break;
1431
}
1432
1433
case ADS_SEARCHPREF_PAGESIZE:
1434
if (prefs[i].vValue.dwType != ADSTYPE_INTEGER)
1435
{
1436
FIXME("ADS_SEARCHPREF_PAGESIZE: unsupported dwType %d\n", prefs[i].vValue.dwType);
1437
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1438
break;
1439
}
1440
1441
TRACE("PAGESIZE: %ld\n", prefs[i].vValue.Integer);
1442
ldap->search.pagesize = prefs[i].vValue.Integer;
1443
prefs[i].dwStatus = ADS_STATUS_S_OK;
1444
break;
1445
1446
case ADS_SEARCHPREF_CACHE_RESULTS:
1447
if (prefs[i].vValue.dwType != ADSTYPE_BOOLEAN)
1448
{
1449
FIXME("ADS_SEARCHPREF_CACHE_RESULTS: unsupported dwType %d\n", prefs[i].vValue.dwType);
1450
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1451
break;
1452
}
1453
1454
TRACE("CACHE_RESULTS: %ld\n", prefs[i].vValue.Boolean);
1455
ldap->search.cache_results = prefs[i].vValue.Boolean;
1456
prefs[i].dwStatus = ADS_STATUS_S_OK;
1457
break;
1458
1459
case ADS_SEARCHPREF_ATTRIBTYPES_ONLY:
1460
if (prefs[i].vValue.dwType != ADSTYPE_BOOLEAN)
1461
{
1462
FIXME("ADS_SEARCHPREF_ATTRIBTYPES_ONLY: unsupported dwType %d\n", prefs[i].vValue.dwType);
1463
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1464
break;
1465
}
1466
1467
TRACE("ATTRIBTYPES_ONLY: %ld\n", prefs[i].vValue.Boolean);
1468
ldap->search.attribtypes_only = prefs[i].vValue.Boolean;
1469
prefs[i].dwStatus = ADS_STATUS_S_OK;
1470
break;
1471
1472
case ADS_SEARCHPREF_TOMBSTONE:
1473
if (prefs[i].vValue.dwType != ADSTYPE_BOOLEAN)
1474
{
1475
FIXME("ADS_SEARCHPREF_TOMBSTONE: unsupported dwType %d\n", prefs[i].vValue.dwType);
1476
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1477
break;
1478
}
1479
1480
TRACE("TOMBSTONE: %ld\n", prefs[i].vValue.Boolean);
1481
ldap->search.tombstone = prefs[i].vValue.Boolean;
1482
prefs[i].dwStatus = ADS_STATUS_S_OK;
1483
break;
1484
1485
case ADS_SEARCHPREF_SIZE_LIMIT:
1486
if (prefs[i].vValue.dwType != ADSTYPE_INTEGER)
1487
{
1488
FIXME("ADS_SEARCHPREF_SIZE_LIMIT: unsupported dwType %d\n", prefs[i].vValue.dwType);
1489
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREFVALUE;
1490
break;
1491
}
1492
1493
TRACE("SIZE_LIMIT: %ld\n", prefs[i].vValue.Integer);
1494
ldap->search.size_limit = prefs[i].vValue.Integer;
1495
prefs[i].dwStatus = ADS_STATUS_S_OK;
1496
break;
1497
1498
default:
1499
FIXME("pref %d, type %u: stub\n", prefs[i].dwSearchPref, prefs[i].vValue.dwType);
1500
prefs[i].dwStatus = ADS_STATUS_INVALID_SEARCHPREF;
1501
break;
1502
}
1503
}
1504
1505
return hr;
1506
}
1507
1508
static HRESULT WINAPI search_ExecuteSearch(IDirectorySearch *iface, LPWSTR filter, LPWSTR *names,
1509
DWORD count, PADS_SEARCH_HANDLE res)
1510
{
1511
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1512
ULONG err, i;
1513
WCHAR **props, *object;
1514
LDAPControlW **ctrls = NULL, *ctrls_a[2], tombstone;
1515
struct ldap_search_context *ldap_ctx;
1516
1517
TRACE("%p,%s,%p,%lu,%p\n", iface, debugstr_w(filter), names, count, res);
1518
1519
if (!res) return E_ADS_BAD_PARAMETER;
1520
1521
ldap_ctx = calloc(1, sizeof(*ldap_ctx));
1522
if (!ldap_ctx) return E_OUTOFMEMORY;
1523
1524
if (count == 0xffffffff)
1525
props = NULL;
1526
else
1527
{
1528
if (count && !names)
1529
{
1530
free(ldap_ctx);
1531
return E_ADS_BAD_PARAMETER;
1532
}
1533
1534
props = malloc((count + 1) * sizeof(props[0]));
1535
if (!props)
1536
{
1537
free(ldap_ctx);
1538
return E_OUTOFMEMORY;
1539
}
1540
1541
for (i = 0; i < count; i++)
1542
{
1543
TRACE("=> %s\n", debugstr_w(names[i]));
1544
props[i] = names[i];
1545
}
1546
1547
props[count] = NULL;
1548
}
1549
1550
if (ldap->search.tombstone)
1551
{
1552
tombstone.ldctl_oid = (WCHAR *)L"1.2.840.113556.1.4.417";
1553
tombstone.ldctl_iscritical = TRUE;
1554
tombstone.ldctl_value.bv_val = NULL;
1555
tombstone.ldctl_value.bv_len = 0;
1556
ctrls_a[0] = &tombstone;
1557
ctrls_a[1] = NULL;
1558
ctrls = ctrls_a;
1559
}
1560
1561
object = ldap->object;
1562
if (object && !wcsicmp(object, L"rootDSE"))
1563
object = NULL;
1564
1565
if (ldap->search.pagesize)
1566
{
1567
ldap_ctx->page = ldap_search_init_pageW(ldap->ld, object, ldap->search.scope,
1568
filter, props, ldap->search.attribtypes_only,
1569
ctrls, NULL, 0, ldap->search.size_limit, NULL);
1570
if (ldap_ctx->page)
1571
err = ldap_get_next_page_s(ldap->ld, ldap_ctx->page, NULL,
1572
ldap->search.pagesize, &count, &ldap_ctx->res);
1573
else
1574
err = LDAP_NO_MEMORY;
1575
}
1576
else
1577
err = ldap_search_ext_sW(ldap->ld, object, ldap->search.scope, filter, props,
1578
ldap->search.attribtypes_only, ctrls, NULL, NULL, ldap->search.size_limit,
1579
&ldap_ctx->res);
1580
free(props);
1581
if (err != LDAP_SUCCESS)
1582
{
1583
TRACE("ldap_search_sW error %#lx\n", err);
1584
if (ldap_ctx->res)
1585
ldap_msgfree(ldap_ctx->res);
1586
if (ldap_ctx->page)
1587
ldap_search_abandon_page(ldap->ld, ldap_ctx->page);
1588
free(ldap_ctx);
1589
return HRESULT_FROM_WIN32(map_ldap_error(err));
1590
}
1591
1592
*res = ldap_ctx;
1593
return S_OK;
1594
}
1595
1596
static HRESULT WINAPI search_AbandonSearch(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)
1597
{
1598
FIXME("%p,%p: stub\n", iface, res);
1599
return E_NOTIMPL;
1600
}
1601
1602
static HRESULT WINAPI search_GetFirstRow(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)
1603
{
1604
struct ldap_search_context *ldap_ctx = res;
1605
1606
TRACE("%p,%p\n", iface, res);
1607
1608
if (!res) return E_ADS_BAD_PARAMETER;
1609
1610
ldap_ctx->entry = NULL;
1611
1612
return IDirectorySearch_GetNextRow(iface, res);
1613
}
1614
1615
static HRESULT WINAPI search_GetNextRow(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)
1616
{
1617
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1618
struct ldap_search_context *ldap_ctx = res;
1619
1620
TRACE("%p,%p\n", iface, res);
1621
1622
if (!res) return E_ADS_BAD_PARAMETER;
1623
1624
if (!ldap_ctx->entry)
1625
{
1626
ldap_ctx->count = ldap_count_entries(ldap->ld, ldap_ctx->res);
1627
ldap_ctx->pos = 0;
1628
1629
if (ldap_ctx->pos >= ldap_ctx->count)
1630
return S_ADS_NOMORE_ROWS;
1631
1632
ldap_ctx->entry = ldap_first_entry(ldap->ld, ldap_ctx->res);
1633
}
1634
else
1635
{
1636
if (ldap_ctx->pos >= ldap_ctx->count)
1637
{
1638
if (ldap_ctx->page)
1639
{
1640
ULONG err, count;
1641
1642
ldap_msgfree(ldap_ctx->res);
1643
ldap_ctx->res = NULL;
1644
1645
err = ldap_get_next_page_s(ldap->ld, ldap_ctx->page, NULL, ldap->search.pagesize, &count, &ldap_ctx->res);
1646
if (err == LDAP_SUCCESS)
1647
{
1648
ldap_ctx->count = ldap_count_entries(ldap->ld, ldap_ctx->res);
1649
ldap_ctx->pos = 0;
1650
1651
if (ldap_ctx->pos >= ldap_ctx->count)
1652
return S_ADS_NOMORE_ROWS;
1653
1654
ldap_ctx->entry = ldap_first_entry(ldap->ld, ldap_ctx->res);
1655
goto exit;
1656
}
1657
1658
if (err != LDAP_NO_RESULTS_RETURNED)
1659
{
1660
TRACE("ldap_get_next_page_s error %#lx\n", err);
1661
return HRESULT_FROM_WIN32(map_ldap_error(err));
1662
}
1663
/* fall through */
1664
}
1665
1666
return S_ADS_NOMORE_ROWS;
1667
}
1668
1669
ldap_ctx->entry = ldap_next_entry(ldap->ld, ldap_ctx->entry);
1670
}
1671
1672
exit:
1673
if (!ldap_ctx->entry)
1674
return S_ADS_NOMORE_ROWS;
1675
1676
ldap_ctx->pos++;
1677
if (ldap_ctx->ber) ber_free(ldap_ctx->ber, 0);
1678
ldap_ctx->ber = NULL;
1679
1680
return S_OK;
1681
}
1682
1683
static HRESULT WINAPI search_GetPreviousRow(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)
1684
{
1685
FIXME("%p,%p: stub\n", iface, res);
1686
return E_NOTIMPL;
1687
}
1688
1689
static HRESULT WINAPI search_GetNextColumnName(IDirectorySearch *iface, ADS_SEARCH_HANDLE res, LPWSTR *name)
1690
{
1691
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1692
struct ldap_search_context *ldap_ctx = res;
1693
WCHAR *attr;
1694
1695
TRACE("%p,%p,%p\n", iface, res, name);
1696
1697
if (!name || !ldap_ctx || !ldap_ctx->entry) return E_ADS_BAD_PARAMETER;
1698
1699
if (!ldap_ctx->ber)
1700
{
1701
attr = ldap_first_attributeW(ldap->ld, ldap_ctx->entry, &ldap_ctx->ber);
1702
ldap_ctx->add_ADsPath = TRUE;
1703
}
1704
else
1705
attr = ldap_next_attributeW(ldap->ld, ldap_ctx->entry, ldap_ctx->ber);
1706
1707
if (attr)
1708
{
1709
TRACE("=> %s\n", debugstr_w(attr));
1710
*name = AllocADsStr(attr);
1711
ldap_memfreeW(attr);
1712
return *name ? S_OK : E_OUTOFMEMORY;
1713
}
1714
else if (ldap_ctx->add_ADsPath)
1715
{
1716
ldap_ctx->add_ADsPath = FALSE;
1717
*name = AllocADsStr((WCHAR *)L"ADsPath");
1718
TRACE("=> %s\n", debugstr_w(*name));
1719
return *name ? S_OK : E_OUTOFMEMORY;
1720
}
1721
1722
*name = NULL;
1723
return S_ADS_NOMORE_COLUMNS;
1724
}
1725
1726
static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_context *ldap_ctx,
1727
LPWSTR name, ADS_SEARCH_COLUMN *col)
1728
{
1729
ADSTYPEENUM type;
1730
DWORD i, count;
1731
1732
type = get_schema_type(name, ldap->at, ldap->at_single_count, ldap->at_multiple_count);
1733
TRACE("%s => type %d\n", debugstr_w(name), type);
1734
1735
switch (type)
1736
{
1737
default:
1738
FIXME("no special handling for type %d\n", type);
1739
/* fall through */
1740
case ADSTYPE_DN_STRING:
1741
case ADSTYPE_CASE_EXACT_STRING:
1742
case ADSTYPE_CASE_IGNORE_STRING:
1743
case ADSTYPE_PRINTABLE_STRING:
1744
{
1745
WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
1746
if (!values)
1747
return E_ADS_COLUMN_NOT_SET;
1748
count = ldap_count_valuesW(values);
1749
1750
col->pADsValues = calloc(count, sizeof(col->pADsValues[0]));
1751
if (!col->pADsValues)
1752
{
1753
ldap_value_freeW(values);
1754
return E_OUTOFMEMORY;
1755
}
1756
1757
for (i = 0; i < count; i++)
1758
{
1759
TRACE("=> %s\n", debugstr_w(values[i]));
1760
col->pADsValues[i].dwType = type;
1761
col->pADsValues[i].CaseIgnoreString = values[i];
1762
}
1763
1764
col->hReserved = values;
1765
break;
1766
}
1767
1768
case ADSTYPE_BOOLEAN:
1769
{
1770
WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
1771
if (!values)
1772
return E_ADS_COLUMN_NOT_SET;
1773
count = ldap_count_valuesW(values);
1774
1775
col->pADsValues = calloc(count, sizeof(col->pADsValues[0]));
1776
if (!col->pADsValues)
1777
{
1778
ldap_value_freeW(values);
1779
return E_OUTOFMEMORY;
1780
}
1781
1782
for (i = 0; i < count; i++)
1783
{
1784
col->pADsValues[i].dwType = type;
1785
1786
if (!wcsicmp(values[i], L"TRUE"))
1787
col->pADsValues[i].Boolean = 1;
1788
else if (!wcsicmp(values[i], L"FALSE"))
1789
col->pADsValues[i].Boolean = 0;
1790
else
1791
{
1792
FIXME("not recognized boolean value %s\n", debugstr_w(values[i]));
1793
col->pADsValues[i].Boolean = 0;
1794
}
1795
TRACE("%s => %ld\n", debugstr_w(values[i]), col->pADsValues[i].Boolean);
1796
}
1797
1798
ldap_value_freeW(values);
1799
col->hReserved = NULL;
1800
break;
1801
}
1802
1803
case ADSTYPE_INTEGER:
1804
case ADSTYPE_LARGE_INTEGER:
1805
{
1806
struct berval **values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
1807
if (!values)
1808
return E_ADS_COLUMN_NOT_SET;
1809
count = ldap_count_values_len(values);
1810
1811
col->pADsValues = calloc(count, sizeof(col->pADsValues[0]));
1812
if (!col->pADsValues)
1813
{
1814
ldap_value_free_len(values);
1815
return E_OUTOFMEMORY;
1816
}
1817
1818
for (i = 0; i < count; i++)
1819
{
1820
col->pADsValues[i].dwType = type;
1821
1822
if (type == ADSTYPE_LARGE_INTEGER)
1823
{
1824
col->pADsValues[i].LargeInteger.QuadPart = _atoi64(values[i]->bv_val);
1825
TRACE("%s => %s\n", debugstr_an(values[i]->bv_val, values[i]->bv_len), wine_dbgstr_longlong(col->pADsValues[i].LargeInteger.QuadPart));
1826
}
1827
else
1828
{
1829
col->pADsValues[i].Integer = atol(values[i]->bv_val);
1830
TRACE("%s => %ld\n", debugstr_an(values[i]->bv_val, values[i]->bv_len), col->pADsValues[i].Integer);
1831
}
1832
}
1833
1834
ldap_value_free_len(values);
1835
col->hReserved = NULL;
1836
break;
1837
}
1838
1839
case ADSTYPE_OCTET_STRING:
1840
case ADSTYPE_NT_SECURITY_DESCRIPTOR:
1841
{
1842
struct berval **values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
1843
if (!values)
1844
return E_ADS_COLUMN_NOT_SET;
1845
count = ldap_count_values_len(values);
1846
1847
col->pADsValues = calloc(count, sizeof(col->pADsValues[0]));
1848
if (!col->pADsValues)
1849
{
1850
ldap_value_free_len(values);
1851
return E_OUTOFMEMORY;
1852
}
1853
1854
for (i = 0; i < count; i++)
1855
{
1856
TRACE("=> %s\n", debugstr_an(values[i]->bv_val, values[i]->bv_len));
1857
col->pADsValues[i].dwType = type;
1858
col->pADsValues[i].OctetString.dwLength = values[i]->bv_len;
1859
col->pADsValues[i].OctetString.lpValue = (BYTE *)values[i]->bv_val;
1860
}
1861
1862
col->hReserved = values;
1863
break;
1864
}
1865
1866
case ADSTYPE_UTC_TIME:
1867
{
1868
struct berval **values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
1869
if (!values)
1870
return E_ADS_COLUMN_NOT_SET;
1871
count = ldap_count_values_len(values);
1872
1873
col->pADsValues = calloc(count, sizeof(col->pADsValues[0]));
1874
if (!col->pADsValues)
1875
{
1876
ldap_value_free_len(values);
1877
return E_OUTOFMEMORY;
1878
}
1879
1880
for (i = 0; i < count; i++)
1881
{
1882
col->pADsValues[i].dwType = type;
1883
if (values[i]->bv_len < 14 ||
1884
_snscanf_l(values[i]->bv_val, values[i]->bv_len, "%04hu%02hu%02hu%02hu%02hu%02hu", NULL,
1885
&col->pADsValues[i].UTCTime.wYear, &col->pADsValues[i].UTCTime.wMonth,
1886
&col->pADsValues[i].UTCTime.wDay, &col->pADsValues[i].UTCTime.wHour,
1887
&col->pADsValues[i].UTCTime.wMinute, &col->pADsValues[i].UTCTime.wSecond) != 6)
1888
{
1889
FIXME("not recognized UTCTime: %s\n", debugstr_an(values[i]->bv_val, values[i]->bv_len));
1890
memset(&col->pADsValues[i].UTCTime, 0, sizeof(col->pADsValues[i].UTCTime));
1891
continue;
1892
}
1893
1894
if ((values[i]->bv_val[14] != '.' && values[i]->bv_val[14] != ',') ||
1895
values[i]->bv_val[15] != '0' || values[i]->bv_val[16] != 'Z')
1896
FIXME("not handled time zone: %s\n", debugstr_an(values[i]->bv_val + 14, values[i]->bv_len - 14));
1897
1898
TRACE("%s => %02u.%02u.%04u %02u:%02u:%02u\n", debugstr_an(values[i]->bv_val, values[i]->bv_len),
1899
col->pADsValues[i].UTCTime.wDay, col->pADsValues[i].UTCTime.wMonth,
1900
col->pADsValues[i].UTCTime.wYear, col->pADsValues[i].UTCTime.wHour,
1901
col->pADsValues[i].UTCTime.wMinute, col->pADsValues[i].UTCTime.wSecond);
1902
}
1903
1904
ldap_value_free_len(values);
1905
col->hReserved = NULL;
1906
break;
1907
}
1908
1909
case ADSTYPE_DN_WITH_BINARY:
1910
{
1911
static const BYTE hex2bin[] =
1912
{
1913
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x00 */
1914
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x10 */
1915
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x20 */
1916
0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, /* 0x30 */
1917
0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, /* 0x40 */
1918
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x50 */
1919
0,10,11,12,13,14,15 /* 0x60 */
1920
};
1921
ADS_DN_WITH_BINARY *dnb;
1922
WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
1923
if (!values)
1924
return E_ADS_COLUMN_NOT_SET;
1925
count = ldap_count_valuesW(values);
1926
1927
col->pADsValues = calloc(count, sizeof(col->pADsValues[0]) + sizeof(col->pADsValues[0].pDNWithBinary[0]));
1928
if (!col->pADsValues)
1929
{
1930
ldap_value_freeW(values);
1931
return E_OUTOFMEMORY;
1932
}
1933
1934
dnb = (ADS_DN_WITH_BINARY *)(col->pADsValues + count);
1935
1936
for (i = 0; i < count; i++)
1937
{
1938
WCHAR *p = values[i];
1939
DWORD n;
1940
1941
col->pADsValues[i].dwType = type;
1942
col->pADsValues[i].pDNWithBinary = dnb++;
1943
1944
if ((p[0] != 'b' && p[0] != 'B') || p[1] != ':')
1945
FIXME("wrong DN with binary tag '%c%c'\n", p[0], p[1]);
1946
p += 2;
1947
1948
col->pADsValues[i].pDNWithBinary->dwLength = wcstol(p, &p, 10) / 2;
1949
if (*p != ':')
1950
FIXME("wrong DN with binary separator '%c'\n", *p);
1951
p++;
1952
col->pADsValues[i].pDNWithBinary->lpBinaryValue = (BYTE *)p;
1953
/* decode values in-place */
1954
for (n = 0; n < col->pADsValues[i].pDNWithBinary->dwLength; n++, p += 2)
1955
{
1956
BYTE b;
1957
1958
if (p[0] > 'f' || (p[0] != '0' && !hex2bin[p[0]]) ||
1959
p[1] > 'f' || (p[1] != '0' && !hex2bin[p[1]]))
1960
{
1961
FIXME("bad hex encoding at %s\n", debugstr_w(p));
1962
continue;
1963
}
1964
1965
b = (hex2bin[p[0]] << 4) | hex2bin[p[1]];
1966
col->pADsValues[i].pDNWithBinary->lpBinaryValue[n] = b;
1967
}
1968
if (*p != ':')
1969
FIXME("wrong DN with binary separator '%c'\n", *p);
1970
col->pADsValues[i].pDNWithBinary->pszDNString = p + 1;
1971
1972
TRACE("%s => %lu,%s,%s\n", debugstr_w(values[i]),
1973
col->pADsValues[i].pDNWithBinary->dwLength,
1974
debugstr_an((char *)col->pADsValues[i].pDNWithBinary->lpBinaryValue, col->pADsValues[i].pDNWithBinary->dwLength),
1975
debugstr_w(col->pADsValues[i].pDNWithBinary->pszDNString));
1976
}
1977
1978
col->hReserved = values;
1979
break;
1980
}
1981
}
1982
1983
col->dwADsType = type;
1984
col->dwNumValues = count;
1985
col->pszAttrName = wcsdup(name);
1986
1987
return S_OK;
1988
}
1989
1990
static HRESULT WINAPI search_GetColumn(IDirectorySearch *iface, ADS_SEARCH_HANDLE res,
1991
LPWSTR name, PADS_SEARCH_COLUMN col)
1992
{
1993
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
1994
struct ldap_search_context *ldap_ctx = res;
1995
HRESULT hr;
1996
ULONG count;
1997
1998
TRACE("%p,%p,%s,%p\n", iface, res, debugstr_w(name), col);
1999
2000
if (!res || !name || !ldap_ctx->entry) return E_ADS_BAD_PARAMETER;
2001
2002
memset(col, 0, sizeof(*col));
2003
2004
if (!wcsicmp(name, L"ADsPath"))
2005
{
2006
WCHAR *dn = ldap_get_dnW(ldap->ld, ldap_ctx->entry);
2007
2008
col->pADsValues = malloc(sizeof(col->pADsValues[0]));
2009
if (!col->pADsValues)
2010
{
2011
hr = E_OUTOFMEMORY;
2012
goto exit;
2013
}
2014
2015
count = sizeof(L"LDAP://");
2016
if (ldap->host)
2017
count += (wcslen(ldap->host) + 1 /* '/' */) * sizeof(WCHAR);
2018
if (dn) count += wcslen(dn) * sizeof(WCHAR);
2019
2020
col->pADsValues[0].CaseIgnoreString = malloc(count);
2021
if (!col->pADsValues[0].CaseIgnoreString)
2022
{
2023
hr = E_OUTOFMEMORY;
2024
goto exit;
2025
}
2026
2027
wcscpy(col->pADsValues[0].CaseIgnoreString, L"LDAP://");
2028
if (ldap->host)
2029
{
2030
wcscat(col->pADsValues[0].CaseIgnoreString, ldap->host);
2031
wcscat(col->pADsValues[0].CaseIgnoreString, L"/");
2032
}
2033
if (dn) wcscat(col->pADsValues[0].CaseIgnoreString, dn);
2034
col->pADsValues[0].dwType = ADSTYPE_CASE_IGNORE_STRING;
2035
col->dwADsType = ADSTYPE_CASE_IGNORE_STRING;
2036
col->dwNumValues = 1;
2037
col->pszAttrName = wcsdup(name);
2038
col->hReserved = NULL;
2039
2040
TRACE("=> %s\n", debugstr_w(col->pADsValues[0].CaseIgnoreString));
2041
hr = S_OK;
2042
exit:
2043
ldap_memfreeW(dn);
2044
return hr;
2045
}
2046
2047
return add_column_values(ldap, ldap_ctx, name, col);
2048
}
2049
2050
static HRESULT WINAPI search_FreeColumn(IDirectorySearch *iface, PADS_SEARCH_COLUMN col)
2051
{
2052
TRACE("%p,%p\n", iface, col);
2053
2054
if (!col) return E_ADS_BAD_PARAMETER;
2055
2056
if (!wcsicmp(col->pszAttrName, L"ADsPath"))
2057
free(col->pADsValues[0].CaseIgnoreString);
2058
free(col->pADsValues);
2059
free(col->pszAttrName);
2060
2061
if (col->hReserved)
2062
{
2063
if (col->dwADsType == ADSTYPE_OCTET_STRING || col->dwADsType == ADSTYPE_NT_SECURITY_DESCRIPTOR)
2064
ldap_value_free_len(col->hReserved);
2065
else
2066
ldap_value_freeW(col->hReserved);
2067
}
2068
2069
return S_OK;
2070
}
2071
2072
static HRESULT WINAPI search_CloseSearchHandle(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)
2073
{
2074
LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
2075
struct ldap_search_context *ldap_ctx = res;
2076
2077
TRACE("%p,%p\n", iface, res);
2078
2079
if (!res) return E_ADS_BAD_PARAMETER;
2080
2081
if (ldap_ctx->page)
2082
ldap_search_abandon_page(ldap->ld, ldap_ctx->page);
2083
if (ldap_ctx->res)
2084
ldap_msgfree(ldap_ctx->res);
2085
if (ldap_ctx->ber)
2086
ber_free(ldap_ctx->ber, 0);
2087
free(ldap_ctx);
2088
2089
return S_OK;
2090
}
2091
2092
static const IDirectorySearchVtbl IDirectorySearch_vtbl =
2093
{
2094
search_QueryInterface,
2095
search_AddRef,
2096
search_Release,
2097
search_SetSearchPreference,
2098
search_ExecuteSearch,
2099
search_AbandonSearch,
2100
search_GetFirstRow,
2101
search_GetNextRow,
2102
search_GetPreviousRow,
2103
search_GetNextColumnName,
2104
search_GetColumn,
2105
search_FreeColumn,
2106
search_CloseSearchHandle
2107
};
2108
2109
static inline LDAP_namespace *impl_from_IDirectoryObject(IDirectoryObject *iface)
2110
{
2111
return CONTAINING_RECORD(iface, LDAP_namespace, IDirectoryObject_iface);
2112
}
2113
2114
static HRESULT WINAPI dirobj_QueryInterface(IDirectoryObject *iface, REFIID riid, void **obj)
2115
{
2116
LDAP_namespace *ldap = impl_from_IDirectoryObject(iface);
2117
2118
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
2119
2120
if (!riid || !obj) return E_INVALIDARG;
2121
2122
if (IsEqualGUID(riid, &IID_IDirectoryObject) ||
2123
IsEqualGUID(riid, &IID_IUnknown))
2124
{
2125
IDirectoryObject_AddRef(iface);
2126
*obj = iface;
2127
return S_OK;
2128
}
2129
2130
return IADs_QueryInterface(&ldap->IADs_iface, riid, obj);
2131
}
2132
2133
static ULONG WINAPI dirobj_AddRef(IDirectoryObject *iface)
2134
{
2135
LDAP_namespace *ldap = impl_from_IDirectoryObject(iface);
2136
return IADs_AddRef(&ldap->IADs_iface);
2137
}
2138
2139
static ULONG WINAPI dirobj_Release(IDirectoryObject *iface)
2140
{
2141
LDAP_namespace *ldap = impl_from_IDirectoryObject(iface);
2142
return IADs_Release(&ldap->IADs_iface);
2143
}
2144
2145
static HRESULT WINAPI dirobj_GetObjectInformation(IDirectoryObject *iface, PADS_OBJECT_INFO *info)
2146
{
2147
FIXME("%p,%p: stub\n", iface, info);
2148
return E_NOTIMPL;
2149
}
2150
2151
static HRESULT WINAPI dirobj_GetObjectAttributes(IDirectoryObject *iface, LPWSTR *names,
2152
DWORD count, PADS_ATTR_INFO *attrs, DWORD *count_returned)
2153
{
2154
FIXME("%p,%p,%lu,%p,%p: stub\n", iface, names, count, attrs, count_returned);
2155
return E_NOTIMPL;
2156
}
2157
2158
static HRESULT WINAPI dirobj_SetObjectAttributes(IDirectoryObject *iface, PADS_ATTR_INFO attrs,
2159
DWORD count, DWORD *count_set)
2160
{
2161
FIXME("%p,%p,%lu,%p: stub\n", iface, attrs, count, count_set);
2162
return E_NOTIMPL;
2163
}
2164
2165
static HRESULT WINAPI dirobj_CreateDSObject(IDirectoryObject *iface, LPWSTR name,
2166
PADS_ATTR_INFO attrs, DWORD count, IDispatch **obj)
2167
{
2168
FIXME("%p,%s,%p,%lu,%p: stub\n", iface, debugstr_w(name), attrs, count, obj);
2169
return E_NOTIMPL;
2170
}
2171
2172
static HRESULT WINAPI dirobj_DeleteDSObject(IDirectoryObject *iface, LPWSTR name)
2173
{
2174
FIXME("%p,%s: stub\n", iface, debugstr_w(name));
2175
return E_NOTIMPL;
2176
}
2177
2178
static const IDirectoryObjectVtbl IDirectoryObject_vtbl =
2179
{
2180
dirobj_QueryInterface,
2181
dirobj_AddRef,
2182
dirobj_Release,
2183
dirobj_GetObjectInformation,
2184
dirobj_GetObjectAttributes,
2185
dirobj_SetObjectAttributes,
2186
dirobj_CreateDSObject,
2187
dirobj_DeleteDSObject
2188
};
2189
2190
static inline LDAP_namespace *impl_from_IADsObjectOptions(IADsObjectOptions *iface)
2191
{
2192
return CONTAINING_RECORD(iface, LDAP_namespace, IADsObjectOptions_iface);
2193
}
2194
2195
static HRESULT WINAPI options_QueryInterface(IADsObjectOptions *iface, REFIID riid, void **obj)
2196
{
2197
LDAP_namespace *ldap = impl_from_IADsObjectOptions(iface);
2198
2199
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
2200
2201
if (!riid || !obj) return E_INVALIDARG;
2202
2203
if (IsEqualGUID(riid, &IID_IADsObjectOptions) ||
2204
IsEqualGUID(riid, &IID_IDispatch) ||
2205
IsEqualGUID(riid, &IID_IUnknown))
2206
{
2207
IADsObjectOptions_AddRef(iface);
2208
*obj = iface;
2209
return S_OK;
2210
}
2211
2212
return IADs_QueryInterface(&ldap->IADs_iface, riid, obj);
2213
}
2214
2215
static ULONG WINAPI options_AddRef(IADsObjectOptions *iface)
2216
{
2217
LDAP_namespace *ldap = impl_from_IADsObjectOptions(iface);
2218
return IADs_AddRef(&ldap->IADs_iface);
2219
}
2220
2221
static ULONG WINAPI options_Release(IADsObjectOptions *iface)
2222
{
2223
LDAP_namespace *ldap = impl_from_IADsObjectOptions(iface);
2224
return IADs_Release(&ldap->IADs_iface);
2225
}
2226
2227
static HRESULT WINAPI options_GetTypeInfoCount(IADsObjectOptions *iface, UINT *count)
2228
{
2229
FIXME("%p,%p: stub\n", iface, count);
2230
return E_NOTIMPL;
2231
}
2232
2233
static HRESULT WINAPI options_GetTypeInfo(IADsObjectOptions *iface, UINT index, LCID lcid, ITypeInfo **info)
2234
{
2235
FIXME("%p,%u,%#lx,%p: stub\n", iface, index, lcid, info);
2236
return E_NOTIMPL;
2237
}
2238
2239
static HRESULT WINAPI options_GetIDsOfNames(IADsObjectOptions *iface, REFIID riid, LPOLESTR *names,
2240
UINT count, LCID lcid, DISPID *dispid)
2241
{
2242
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
2243
return E_NOTIMPL;
2244
}
2245
2246
static HRESULT WINAPI options_Invoke(IADsObjectOptions *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
2247
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
2248
{
2249
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
2250
params, result, excepinfo, argerr);
2251
return E_NOTIMPL;
2252
}
2253
2254
static HRESULT WINAPI options_GetOption(IADsObjectOptions *iface, LONG option, VARIANT *var)
2255
{
2256
LDAP_namespace *ldap = impl_from_IADsObjectOptions(iface);
2257
LONG err;
2258
2259
TRACE("%p,%ld,%p\n", iface, option, var);
2260
2261
if (!ldap->ld) return E_NOTIMPL;
2262
2263
switch (option)
2264
{
2265
case ADS_OPTION_SERVERNAME:
2266
{
2267
WCHAR *host;
2268
BSTR val;
2269
2270
err = ldap_get_optionW(ldap->ld, LDAP_OPT_HOST_NAME, &host);
2271
if (err != LDAP_SUCCESS)
2272
return HRESULT_FROM_WIN32(map_ldap_error(err));
2273
2274
val = SysAllocString(host);
2275
ldap_memfreeW(host);
2276
if (!val) return E_OUTOFMEMORY;
2277
2278
V_VT(var) = VT_BSTR;
2279
V_BSTR(var) = val;
2280
return S_OK;
2281
}
2282
2283
case ADS_OPTION_ACCUMULATIVE_MODIFICATION:
2284
V_VT(var) = VT_BOOL;
2285
V_BOOL(var) = VARIANT_FALSE;
2286
return S_OK;
2287
2288
default:
2289
FIXME("%p,%ld,%p: stub\n", iface, option, var);
2290
break;
2291
}
2292
2293
return E_ADS_BAD_PARAMETER;
2294
}
2295
2296
static HRESULT WINAPI options_SetOption(IADsObjectOptions *iface, LONG option, VARIANT var)
2297
{
2298
FIXME("%p,%ld,%s: stub\n", iface, option, wine_dbgstr_variant(&var));
2299
2300
switch (option)
2301
{
2302
case ADS_OPTION_ACCUMULATIVE_MODIFICATION:
2303
return S_OK;
2304
2305
default:
2306
break;
2307
}
2308
2309
return E_NOTIMPL;
2310
}
2311
2312
static const IADsObjectOptionsVtbl IADsObjectOptions_vtbl =
2313
{
2314
options_QueryInterface,
2315
options_AddRef,
2316
options_Release,
2317
options_GetTypeInfoCount,
2318
options_GetTypeInfo,
2319
options_GetIDsOfNames,
2320
options_Invoke,
2321
options_GetOption,
2322
options_SetOption
2323
};
2324
2325
static HRESULT LDAPNamespace_create(REFIID riid, void **obj)
2326
{
2327
LDAP_namespace *ldap;
2328
HRESULT hr;
2329
2330
ldap = malloc(sizeof(*ldap));
2331
if (!ldap) return E_OUTOFMEMORY;
2332
2333
ldap->IADs_iface.lpVtbl = &IADs_vtbl;
2334
ldap->IADsOpenDSObject_iface.lpVtbl = &IADsOpenDSObject_vtbl;
2335
ldap->IDirectorySearch_iface.lpVtbl = &IDirectorySearch_vtbl;
2336
ldap->IDirectoryObject_iface.lpVtbl = &IDirectoryObject_vtbl;
2337
ldap->IADsObjectOptions_iface.lpVtbl = &IADsObjectOptions_vtbl;
2338
ldap->ref = 1;
2339
ldap->ld = NULL;
2340
ldap->host = NULL;
2341
ldap->object = NULL;
2342
ldap->schema = NULL;
2343
ldap->attrs_count = 0;
2344
ldap->attrs_count_allocated = 0;
2345
ldap->attrs = NULL;
2346
ldap->search.scope = ADS_SCOPE_SUBTREE;
2347
ldap->search.pagesize = 0;
2348
ldap->search.size_limit = 0;
2349
ldap->search.cache_results = TRUE;
2350
ldap->search.attribtypes_only = FALSE;
2351
ldap->search.tombstone = FALSE;
2352
ldap->at = NULL;
2353
ldap->at_single_count = 0;
2354
ldap->at_multiple_count = 0;
2355
2356
hr = IADs_QueryInterface(&ldap->IADs_iface, riid, obj);
2357
IADs_Release(&ldap->IADs_iface);
2358
2359
return hr;
2360
}
2361
2362
static const struct class_info
2363
{
2364
const CLSID *clsid;
2365
HRESULT (*constructor)(REFIID, void **);
2366
} class_info[] =
2367
{
2368
{ &CLSID_ADSystemInfo, ADSystemInfo_create },
2369
{ &CLSID_LDAP, LDAP_create },
2370
{ &CLSID_LDAPNamespace, LDAPNamespace_create },
2371
};
2372
2373
typedef struct
2374
{
2375
IClassFactory IClassFactory_iface;
2376
LONG ref;
2377
const struct class_info *info;
2378
} class_factory;
2379
2380
static inline class_factory *impl_from_IClassFactory(IClassFactory *iface)
2381
{
2382
return CONTAINING_RECORD(iface, class_factory, IClassFactory_iface);
2383
}
2384
2385
static HRESULT WINAPI factory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *obj)
2386
{
2387
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
2388
2389
if (!riid || !obj) return E_INVALIDARG;
2390
2391
if (IsEqualIID(riid, &IID_IUnknown) ||
2392
IsEqualIID(riid, &IID_IClassFactory))
2393
{
2394
IClassFactory_AddRef(iface);
2395
*obj = iface;
2396
return S_OK;
2397
}
2398
2399
*obj = NULL;
2400
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
2401
return E_NOINTERFACE;
2402
}
2403
2404
static ULONG WINAPI factory_AddRef(IClassFactory *iface)
2405
{
2406
class_factory *factory = impl_from_IClassFactory(iface);
2407
ULONG ref = InterlockedIncrement(&factory->ref);
2408
2409
TRACE("(%p) ref %lu\n", iface, ref);
2410
2411
return ref;
2412
}
2413
2414
static ULONG WINAPI factory_Release(IClassFactory *iface)
2415
{
2416
class_factory *factory = impl_from_IClassFactory(iface);
2417
ULONG ref = InterlockedDecrement(&factory->ref);
2418
2419
TRACE("(%p) ref %lu\n", iface, ref);
2420
2421
if (!ref)
2422
free(factory);
2423
2424
return ref;
2425
}
2426
2427
static HRESULT WINAPI factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj)
2428
{
2429
class_factory *factory = impl_from_IClassFactory(iface);
2430
2431
TRACE("%p,%s,%p\n", outer, debugstr_guid(riid), obj);
2432
2433
if (!riid || !obj) return E_INVALIDARG;
2434
2435
*obj = NULL;
2436
if (outer) return CLASS_E_NOAGGREGATION;
2437
2438
return factory->info->constructor(riid, obj);
2439
}
2440
2441
static HRESULT WINAPI factory_LockServer(IClassFactory *iface, BOOL lock)
2442
{
2443
FIXME("%p,%d: stub\n", iface, lock);
2444
return S_OK;
2445
}
2446
2447
static const struct IClassFactoryVtbl factory_vtbl =
2448
{
2449
factory_QueryInterface,
2450
factory_AddRef,
2451
factory_Release,
2452
factory_CreateInstance,
2453
factory_LockServer
2454
};
2455
2456
static HRESULT factory_constructor(const struct class_info *info, REFIID riid, void **obj)
2457
{
2458
class_factory *factory;
2459
HRESULT hr;
2460
2461
factory = malloc(sizeof(*factory));
2462
if (!factory) return E_OUTOFMEMORY;
2463
2464
factory->IClassFactory_iface.lpVtbl = &factory_vtbl;
2465
factory->ref = 1;
2466
factory->info = info;
2467
2468
hr = IClassFactory_QueryInterface(&factory->IClassFactory_iface, riid, obj);
2469
IClassFactory_Release(&factory->IClassFactory_iface);
2470
2471
return hr;
2472
}
2473
2474
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *obj)
2475
{
2476
int i;
2477
2478
TRACE("%s,%s,%p\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
2479
2480
if (!clsid || !iid || !obj) return E_INVALIDARG;
2481
2482
*obj = NULL;
2483
2484
for (i = 0; i < ARRAY_SIZE(class_info); i++)
2485
{
2486
if (IsEqualCLSID(class_info[i].clsid, clsid))
2487
return factory_constructor(&class_info[i], iid, obj);
2488
}
2489
2490
FIXME("class %s/%s is not implemented\n", debugstr_guid(clsid), debugstr_guid(iid));
2491
return CLASS_E_CLASSNOTAVAILABLE;
2492
}
2493
2494