Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
Rozhraní API LDAP poskytuje jednoduchou funkci pro ověření syntaxe. Mějte na paměti, že ověřuje pouze syntaxi a ne existenci vlastností zadaných ve filtru.
Následující funkce ověří syntaxi filtru dotazu a vrátí S_OK, pokud je filtr platný nebo S_FALSE, pokud ne.
HRESULT CheckFilterSyntax(
LPOLESTR szServer, // NULL binds to a DC in the current domain.
LPOLESTR szFilter) // Filter to check.
{
HRESULT hr = S_OK;
DWORD dwReturn;
LDAP *hConnect = NULL; // Connection handle
if (!szFilter)
return E_POINTER;
// LDAP_PORT is the default port, 389
hConnect = ldap_open(szServer, LDAP_PORT);
// Bind using the preferred authentication method on Windows 2000
// and the calling thread's security context.
dwReturn = ldap_bind_s( hConnect, NULL, NULL, LDAP_AUTH_NEGOTIATE );
if (dwReturn==LDAP_SUCCESS) {
dwReturn = ldap_check_filter(hConnect, szFilter);
if (dwReturn==LDAP_SUCCESS)
hr = S_OK;
else
hr = S_FALSE;
}
// Unbind to free the connection.
ldap_unbind( hConnect );
return hr;
}