Platform SDK: Active Directory, ADSI, and Directory Services |
The ADS_STATUSENUM enumeration specifies whether a search preference has been set and, if not, why not.
typedef enum { ADS_STATUS_S_OK = 0, ADS_STATUS_INVALID_SEARCHPREF = 1, ADS_STATUS_INVALID_SEARCHPREFVALUE = 2 } ADS_STATUSENUM;
The IDirectorySearch::SetSearchPreference method writes a member value of the ADS_STATUS enumeration to the dwStatus member of an ADS_SEARCHPREF_INFO structure to indicate whether the corresponding search preference was set. Callers can use this status value to decide whether to execute a search.
Note Because VBScript cannot read information from a type library, VBScript applications do not understand the symbolic constants as defined above. You should use the numerical constants instead to set the appropriate flags in your VBScript applications. If you want to use the symbolic constants as a good programming practice, you should make explicit declarations of such constants, as done here, in your VBScript applications.
The following C/C++ code snippet illustrates how to use ADS_STATUS with IDirectorySearch::SetSearchPreference in a directory search application.
ADS_SEARCHPREF_INFO pSearchPref[10]; LPWSTR pszSearchBase, pszSearchFilter, pszAttrNames[10]; DWORD dwNumberAttributes = -1; DWORD dwCurrPref = 0; LPWSTR pszUserName=NULL, pszPassword=NULL; DWORD dwAuthFlags=0; HRESULT hr=S_OK; IDirectorySearch *pDSSearch=NULL; ADS_SEARCH_HANDLE hSearchHandle=NULL; hr = ADsOpenObject( pszSearchBase, pszUserName, pszPassword, dwAuthFlags, IID_IDirectorySearch, (void **)&pDSSearch ); if (dwCurrPref) { hr = pDSSearch->SetSearchPreference( pSearchPref, dwCurrPref ); if (hr != S_OK) { for (i=0; i<dwCurrPref; i++) { if (pSearchPref[i].dwStatus != ADS_STATUS_S_OK) { printf( "Error in setting the preference %s: status = %d\n", prefNameLookup[pSearchPref[i].dwSearchPref], pSearchPref[i].dwStatus ); cErr++; } } } } hr = pDSSearch->ExecuteSearch( pszSearchFilter, pszAttrNames, dwNumberAttributes, &hSearchHandle ); hr = pDSSearch->GetNextRow( hSearchHandle );
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 Iads.h.
ADSI Enumerations, ADS_SEARCHPREF_ENUM, ADS_SEARCHPREF_INFO, IDirectorySearch::SetSearchPreference