Platform SDK: Active Directory, ADSI, and Directory Services |
The ADsEncodeBinaryData function converts a binary blob of data to the Unicode format suitable to be embedded in a search filter.
HRESULT ADsEncodeBinaryData( PBYTE pbSrcData, DWORD dwSrcLen, LPWSTR *ppszDestData );
This method supports the standard return values, as well as the following:
In ADSI, search filters must be Unicode strings. Sometimes, a filter contains information that is normally represented by an opaque blob of data. For example, you may want to include an object's security identifier in a search filter, which is of binary data. In this case, you must first call the ADsEncodeBinaryData function to convert the binary data to the Unicode string format. When the data is no longer needed, you should call the FreeADsMem function to free the converted Unicode string (that is, ppszDestData). The following code snippet gives an example of how to use this function.
//Test binary values in filters and use //a binary filter instead of a string filter in ExecuteSearch. WCHAR pszBinaryFilter[256] = L"objectSid="; LPWSTR pszDest = NULL; BYTE column[100] = { 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0x59, 0x51, 0xb8, 0x17, 0x66, 0x72, 0x5d, 0x25, 0x64, 0x63, 0x3b, 0x0b, 0x29, 0x99, 0x21, 0x00 }; hr = ADsEncodeBinaryData ( column, 28, &pszDest ); wcscat( pszBinaryFilter, pszDest ); //Do the search with the pszDest as the filter string. Code omitted. . . . //Done with the search and free the converted string. FreeADsMem( pszDest );
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
Windows 95/98: Requires Windows 95 or later (with DSClient).
Header: Declared in Adshlp.h.
Library: Included as a resource in ActiveDs.dll.