2 * Active Directory services LDAP Provider
4 * Copyright 2018 Dmitry Timoshkov
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.
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.
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
31 #define SECURITY_WIN32
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(adsldp
);
38 static HMODULE adsldp_hinst
;
42 IADsADSystemInfo IADsADSystemInfo_iface
;
46 static inline AD_sysinfo
*impl_from_IADsADSystemInfo(IADsADSystemInfo
*iface
)
48 return CONTAINING_RECORD(iface
, AD_sysinfo
, IADsADSystemInfo_iface
);
51 static HRESULT WINAPI
sysinfo_QueryInterface(IADsADSystemInfo
*iface
, REFIID riid
, void **obj
)
53 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
55 if (!riid
|| !obj
) return E_INVALIDARG
;
57 if (IsEqualGUID(riid
, &IID_IADsADSystemInfo
) ||
58 IsEqualGUID(riid
, &IID_IDispatch
) ||
59 IsEqualGUID(riid
, &IID_IUnknown
))
61 IADsADSystemInfo_AddRef(iface
);
66 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
70 static ULONG WINAPI
sysinfo_AddRef(IADsADSystemInfo
*iface
)
72 AD_sysinfo
*sysinfo
= impl_from_IADsADSystemInfo(iface
);
73 return InterlockedIncrement(&sysinfo
->ref
);
76 static ULONG WINAPI
sysinfo_Release(IADsADSystemInfo
*iface
)
78 AD_sysinfo
*sysinfo
= impl_from_IADsADSystemInfo(iface
);
79 LONG ref
= InterlockedDecrement(&sysinfo
->ref
);
83 TRACE("destroying %p\n", iface
);
84 HeapFree(GetProcessHeap(), 0, sysinfo
);
90 static HRESULT WINAPI
sysinfo_GetTypeInfoCount(IADsADSystemInfo
*iface
, UINT
*count
)
92 FIXME("%p,%p: stub\n", iface
, count
);
96 static HRESULT WINAPI
sysinfo_GetTypeInfo(IADsADSystemInfo
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
98 FIXME("%p,%u,%#x,%p: stub\n", iface
, index
, lcid
, info
);
102 static HRESULT WINAPI
sysinfo_GetIDsOfNames(IADsADSystemInfo
*iface
, REFIID riid
, LPOLESTR
*names
,
103 UINT count
, LCID lcid
, DISPID
*dispid
)
105 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
109 static HRESULT WINAPI
sysinfo_Invoke(IADsADSystemInfo
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
110 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
112 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
113 params
, result
, excepinfo
, argerr
);
117 static HRESULT WINAPI
sysinfo_get_UserName(IADsADSystemInfo
*iface
, BSTR
*retval
)
119 FIXME("%p,%p: stub\n", iface
, retval
);
123 static HRESULT WINAPI
sysinfo_get_ComputerName(IADsADSystemInfo
*iface
, BSTR
*retval
)
128 TRACE("%p,%p\n", iface
, retval
);
131 GetComputerObjectNameW(NameFullyQualifiedDN
, NULL
, &size
);
132 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
133 return HRESULT_FROM_WIN32(GetLastError());
135 name
= SysAllocStringLen(NULL
, size
);
136 if (!name
) return E_OUTOFMEMORY
;
138 if (!GetComputerObjectNameW(NameFullyQualifiedDN
, name
, &size
))
141 return HRESULT_FROM_WIN32(GetLastError());
148 static HRESULT WINAPI
sysinfo_get_SiteName(IADsADSystemInfo
*iface
, BSTR
*retval
)
150 FIXME("%p,%p: stub\n", iface
, retval
);
154 static HRESULT WINAPI
sysinfo_get_DomainShortName(IADsADSystemInfo
*iface
, BSTR
*retval
)
156 FIXME("%p,%p: stub\n", iface
, retval
);
160 static HRESULT WINAPI
sysinfo_get_DomainDNSName(IADsADSystemInfo
*iface
, BSTR
*retval
)
162 FIXME("%p,%p: stub\n", iface
, retval
);
166 static HRESULT WINAPI
sysinfo_get_ForestDNSName(IADsADSystemInfo
*iface
, BSTR
*retval
)
168 FIXME("%p,%p: stub\n", iface
, retval
);
172 static HRESULT WINAPI
sysinfo_get_PDCRoleOwner(IADsADSystemInfo
*iface
, BSTR
*retval
)
174 FIXME("%p,%p: stub\n", iface
, retval
);
178 static HRESULT WINAPI
sysinfo_get_SchemaRoleOwner(IADsADSystemInfo
*iface
, BSTR
*retval
)
180 FIXME("%p,%p: stub\n", iface
, retval
);
184 static HRESULT WINAPI
sysinfo_get_IsNativeMode(IADsADSystemInfo
*iface
, VARIANT_BOOL
*retval
)
186 FIXME("%p,%p: stub\n", iface
, retval
);
190 static HRESULT WINAPI
sysinfo_GetAnyDCName(IADsADSystemInfo
*iface
, BSTR
*retval
)
192 FIXME("%p,%p: stub\n", iface
, retval
);
196 static HRESULT WINAPI
sysinfo_GetDCSiteName(IADsADSystemInfo
*iface
, BSTR server
, BSTR
*retval
)
198 FIXME("%p,%s,%p: stub\n", iface
, debugstr_w(server
), retval
);
202 static HRESULT WINAPI
sysinfo_RefreshSchemaCache(IADsADSystemInfo
*iface
)
204 FIXME("%p: stub\n", iface
);
208 static HRESULT WINAPI
sysinfo_GetTrees(IADsADSystemInfo
*iface
, VARIANT
*retval
)
210 FIXME("%p,%p: stub\n", iface
, retval
);
214 static const IADsADSystemInfoVtbl IADsADSystemInfo_vtbl
=
216 sysinfo_QueryInterface
,
219 sysinfo_GetTypeInfoCount
,
221 sysinfo_GetIDsOfNames
,
223 sysinfo_get_UserName
,
224 sysinfo_get_ComputerName
,
225 sysinfo_get_SiteName
,
226 sysinfo_get_DomainShortName
,
227 sysinfo_get_DomainDNSName
,
228 sysinfo_get_ForestDNSName
,
229 sysinfo_get_PDCRoleOwner
,
230 sysinfo_get_SchemaRoleOwner
,
231 sysinfo_get_IsNativeMode
,
232 sysinfo_GetAnyDCName
,
233 sysinfo_GetDCSiteName
,
234 sysinfo_RefreshSchemaCache
,
238 static HRESULT
ADSystemInfo_create(void **obj
)
242 sysinfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(*sysinfo
));
243 if (!sysinfo
) return E_OUTOFMEMORY
;
245 sysinfo
->IADsADSystemInfo_iface
.lpVtbl
= &IADsADSystemInfo_vtbl
;
247 *obj
= &sysinfo
->IADsADSystemInfo_iface
;
249 TRACE("created %p\n", *obj
);
256 IClassFactory IClassFactory_iface
;
257 HRESULT (*constructor
)(void **);
258 } ADSystemInfo_factory
;
260 static inline ADSystemInfo_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
262 return CONTAINING_RECORD(iface
, ADSystemInfo_factory
, IClassFactory_iface
);
265 static HRESULT WINAPI
factory_QueryInterface(IClassFactory
*iface
, REFIID riid
, LPVOID
*obj
)
267 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
269 if (!riid
|| !obj
) return E_INVALIDARG
;
271 if (IsEqualIID(riid
, &IID_IUnknown
) ||
272 IsEqualIID(riid
, &IID_IClassFactory
))
274 IClassFactory_AddRef(iface
);
280 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
281 return E_NOINTERFACE
;
284 static ULONG WINAPI
factory_AddRef(IClassFactory
*iface
)
289 static ULONG WINAPI
factory_Release(IClassFactory
*iface
)
294 static HRESULT WINAPI
factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **obj
)
296 ADSystemInfo_factory
*factory
= impl_from_IClassFactory(iface
);
300 TRACE("%p,%s,%p\n", outer
, debugstr_guid(riid
), obj
);
302 if (!riid
|| !obj
) return E_INVALIDARG
;
305 if (outer
) return CLASS_E_NOAGGREGATION
;
307 hr
= factory
->constructor((void **)&unknown
);
310 hr
= IUnknown_QueryInterface(unknown
, riid
, obj
);
311 IUnknown_Release(unknown
);
316 static HRESULT WINAPI
factory_LockServer(IClassFactory
*iface
, BOOL lock
)
318 FIXME("%p,%d: stub\n", iface
, lock
);
322 static const struct IClassFactoryVtbl factory_vtbl
=
324 factory_QueryInterface
,
327 factory_CreateInstance
,
331 static ADSystemInfo_factory ADSystemInfo_cf
= { { &factory_vtbl
}, ADSystemInfo_create
};
333 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, LPVOID
*obj
)
335 TRACE("%s,%s,%p\n", debugstr_guid(clsid
), debugstr_guid(iid
), obj
);
337 if (!clsid
|| !iid
|| !obj
) return E_INVALIDARG
;
341 if (IsEqualGUID(clsid
, &CLSID_ADSystemInfo
))
342 return IClassFactory_QueryInterface(&ADSystemInfo_cf
.IClassFactory_iface
, iid
, obj
);
344 FIXME("class %s/%s is not implemented\n", debugstr_guid(clsid
), debugstr_guid(iid
));
345 return CLASS_E_CLASSNOTAVAILABLE
;
348 HRESULT WINAPI
DllCanUnloadNow(void)
353 HRESULT WINAPI
DllRegisterServer(void)
355 return __wine_register_resources(adsldp_hinst
);
358 HRESULT WINAPI
DllUnregisterServer(void)
360 return __wine_unregister_resources(adsldp_hinst
);
363 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD reason
, void *reserved
)
365 TRACE("%p,%u,%p\n", hinst
, reason
, reserved
);
369 case DLL_WINE_PREATTACH
:
370 return FALSE
; /* prefer native version */
372 case DLL_PROCESS_ATTACH
:
373 adsldp_hinst
= hinst
;
374 DisableThreadLibraryCalls(hinst
);