Directory Services |
The ADS_STATUSENUM enumeration specifies the status of a search preference set with the IDirectorySearch::SetSearchPreference method.
typedef enum { ADS_STATUS_S_OK = 0, ADS_STATUS_INVALID_SEARCHPREF = 1, ADS_STATUS_INVALID_SEARCHPREFVALUE = 2 } ADS_STATUSENUM;
The IDirectorySearch::SetSearchPreference method sets the dwStatus member ADS_SEARCHPREF_INFO structure to one of the ADS_STATUSENUM values to indicate the status of the corresponding search preference. Callers can use this status value to decide whether to execute a search.
The ADS_STATUS_INVALID_SEARCHPREF status value may be set if you set a valid search preference, but that preference is not supported. For example, if you set ADS_SEARCHPREF_SORT_ON, but the server you are communicating with does not support the LDAP server-side sort control, the dwStatus member of the ADS_SEARCHPREF_INFO structure will be set to ADS_STATUS_INVALID_SEARCHPREF by the IDirectorySearch::SetSearchPreference call.
Note Because VBScript cannot read data from a type library, VBScript applications do not recognize the symbolic constants as defined above. You should use the numerical constants instead to set the appropriate flags in your VBScript applications. To use the symbolic constants as a good programming practice, write explicit declarations of such constants, as done in the following code example.
The following C/C++ code example shows how to use ADS_STATUS with IDirectorySearch::SetSearchPreference in a directory search application.
[C++]
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
);
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension
on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.
ADSI Enumerations, ADS_SEARCHPREF_ENUM, ADS_SEARCHPREF_INFO, IDirectorySearch::SetSearchPreference