Platform SDK: Active Directory, ADSI, and Directory Services

ADS_STATUSENUM

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;

Elements

ADS_STATUS_S_OK
The search preference was set successfully.
ADS_STATUS_INVALID_SEARCHPREF
The search preference specified in the dwSearchPref field of the ADS_SEARCHPREF_INFO structure is invalid. Search preferences must be taken from the ADS_SEARCHPREF_ENUM enumeration.
ADS_STATUS_INVALID_SEARCHPREFVALUE
The value specified in the vValue member of the ADS_SEARCHPREF_INFO structure is invalid for the corresponding search preference.

Remarks

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.

Example Code [C++]

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
    );

Requirements

  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.

See Also

ADSI Enumerations, ADS_SEARCHPREF_ENUM, ADS_SEARCHPREF_INFO, IDirectorySearch::SetSearchPreference