Platform SDK: Active Directory, ADSI, and Directory Services

ldap_escape_filter_element

The ldap_escape_filter_element function converts a filter element to a safe text string that can be passed safely in a search filter.

ULONG ldap_escape_filter_element (
  PCHAR sourceFilterElement,
  ULONG sourceLength,
  PCHAR destFilterElement,
  ULONG destLength
);

Parameters

sourceFilterElement
[in] The filter element to convert.
sourceLength
[in] The length of the source filter element.
destFilterElement
[out] A safe text string.
destLength
[out] The length of the safe text string.

Return Values

If the function succeeds, the return value is LDAP_SUCCESS.

If the function fails, it returns an error code. See Return Values for more information.

Remarks

The ldap_escape_filter_element function allows you to use raw binary data in search filters. For example, you can use this function to specify a certificate or a JPEG image as the attribute to match.

Call ldap_escape_filter_element with the sourceFilterElement parameter pointing to raw data and sourceCount set appropriately to the length of data. If the destFilterElement parameter is NULL, then the return value is the length required for the output buffer. If destFilterElement is not NULL, then the function copies the source into the destination buffer and ensures that it is of a safe format. Then insert the destination buffer into your search filter after the "attributetype=" filter element.

Note  Don't call ldap_escape_filter_element for attribute values that are strings, as the run time does not perform any conversion from UTF-8 format. Use this function only for attribute elements that are raw binary data.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 SP4 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Winldap.h.
  Library: Use Wldap32.lib.
  Unicode: Declared as Unicode and ANSI prototypes.

See Also

Functions, Return Values