Commit 889e66c2 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

adsldp: Implement IDirectorySearch::GetColumn().

parent e53a0094
...@@ -1301,11 +1301,58 @@ static HRESULT WINAPI search_GetNextColumnName(IDirectorySearch *iface, ADS_SEAR ...@@ -1301,11 +1301,58 @@ static HRESULT WINAPI search_GetNextColumnName(IDirectorySearch *iface, ADS_SEAR
return S_ADS_NOMORE_COLUMNS; return S_ADS_NOMORE_COLUMNS;
} }
static HRESULT add_column_values(ADS_SEARCH_COLUMN *col, struct berval **values, DWORD count)
{
DWORD i;
col->pADsValues = heap_alloc(count * sizeof(col->pADsValues[0]));
if (!col->pADsValues)
return E_OUTOFMEMORY;
for (i = 0; i < count; i++)
{
DWORD outlen;
TRACE("=> %s\n", debugstr_an(values[i]->bv_val, values[i]->bv_len));
col->pADsValues[i].u.CaseIgnoreString = strnAtoW(values[i]->bv_val, values[i]->bv_len, &outlen);
if (!col->pADsValues[i].u.CaseIgnoreString)
{
heap_free(col->pADsValues);
return E_OUTOFMEMORY;
}
}
col->dwADsType = ADSTYPE_CASE_IGNORE_STRING;
col->dwNumValues = count;
return S_OK;
}
static HRESULT WINAPI search_GetColumn(IDirectorySearch *iface, ADS_SEARCH_HANDLE res, static HRESULT WINAPI search_GetColumn(IDirectorySearch *iface, ADS_SEARCH_HANDLE res,
LPWSTR name, PADS_SEARCH_COLUMN col) LPWSTR name, PADS_SEARCH_COLUMN col)
{ {
FIXME("%p,%p,%s,%p: stub\n", iface, res, debugstr_w(name), col); LDAP_namespace *ldap = impl_from_IDirectorySearch(iface);
return E_NOTIMPL; struct ldap_search_context *ldap_ctx = res;
HRESULT hr;
struct berval **values;
ULONG count;
TRACE("%p,%p,%s,%p\n", iface, res, debugstr_w(name), col);
if (!ldap->ld) return E_NOTIMPL;
if (!res || !name || !ldap_ctx->entry) return E_ADS_BAD_PARAMETER;
values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
if (!values) return ERROR_DS_NO_ATTRIBUTE_OR_VALUE;
count = ldap_count_values_len(values);
hr = add_column_values(col, values, count);
ldap_value_free_len(values);
if (hr == S_OK)
col->pszAttrName = strdupW(name);
return hr;
} }
static HRESULT WINAPI search_FreeColumn(IDirectorySearch *iface, PADS_SEARCH_COLUMN col) static HRESULT WINAPI search_FreeColumn(IDirectorySearch *iface, PADS_SEARCH_COLUMN col)
......
...@@ -29,6 +29,23 @@ static inline WCHAR *strdupW(const WCHAR *src) ...@@ -29,6 +29,23 @@ static inline WCHAR *strdupW(const WCHAR *src)
return dst; return dst;
} }
static inline LPWSTR strnAtoW( LPCSTR str, DWORD inlen, DWORD *outlen )
{
LPWSTR ret = NULL;
*outlen = 0;
if (str)
{
DWORD len = MultiByteToWideChar( CP_ACP, 0, str, inlen, NULL, 0 );
if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) )))
{
MultiByteToWideChar( CP_ACP, 0, str, inlen, ret, len );
ret[len] = 0;
*outlen = len;
}
}
return ret;
}
DWORD map_ldap_error(DWORD) DECLSPEC_HIDDEN; DWORD map_ldap_error(DWORD) DECLSPEC_HIDDEN;
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment