Platform SDK: Active Directory, ADSI, and Directory Services |
The ADS_SEARCHPREF_ENUM enumeration specifies preferences for the directory search using IDirectorySearch methods.
typedef enum { ADS_SEARCHPREF_ASYNCHRONOUS = 0, ADS_SEARCHPREF_DEREF_ALIASES = 1, ADS_SEARCHPREF_SIZE_LIMIT = 2, ADS_SEARCHPREF_TIME_LIMIT = 3, ADS_SEARCHPREF_ATTRIBTYPES_ONLY = 4, ADS_SEARCHPREF_SEARCH_SCOPE = 5, ADS_SEARCHPREF_TIMEOUT = 6, ADS_SEARCHPREF_PAGESIZE = 7, ADS_SEARCHPREF_PAGED_TIME_LIMIT = 8, ADS_SEARCHPREF_CHASE_REFERRALS = 9, ADS_SEARCHPREF_SORT_ON = 10, ADS_SEARCHPREF_CACHE_RESULTS = 11, ADS_SEARCHPREF_DIRSYNC = 12, ADS_SEARCHPREF_TOMBSTONE = 13 } ADS_SEARCHPREF_ENUM;
This flag cannot be combined with ADS_SEARCHPREF_PAGESIZE.
The caller must have the SE_SYNC_AGENT_NAME privilege.
Not all attributes are preserved when the object is deleted. You can retrieve the objectGUID and RDN attributes. The distinguishedName attribute is the DN of the object in the "Deleted Objects" container, not the previous DN. The isDeleted attribute is TRUE for a deleted object. See also Retrieving Deleted Objects.
To set up a search preference, you assign appropriate values to the fields of an ADS_SEARCHPREF_INFO structure that will be passed to the server. To set up multiple preferences, you need to use an array of ADS_SEARCHPREF_INFO structures. The member values of this enumeration are assigned to the dwSearchPref field of the structure.
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 code snippet illustrates how to set up search preferences using the ADS_SEARCHPREF_ENUM enumeration.
HRESULT SetSearchPreferences2( DWORD dwScope,//-1 means use default: subtree DWORD dwOverallTimeOut,//<=0 means use default: no time out set. DWORD dwOverallSizeLimit,//<=0 means use default: no size limit set. DWORD dwOverallTimeLimit,//<=0 means use default: no time limit set. BOOL bCacheResult,//True means use default. BOOL bIsAsynchronous,//False means use default DWORD dwPageSize,//<=0 means use default DWORD dwPageTimeLimit,//<=0 means use default DWORD dwChaseReferral,//<=0 means use default LPOLESTR szSortKey,//NULL means don't sort. BOOL bIsDescending, BOOL bReturnAttributeNamesOnly,//False means use default. ADS_SEARCHPREF_INFO **ppSearchPref, //Return an array of search preferences. DWORD *pdwSearchPrefCount ) { HRESULT hr = S_OK; DWORD dwCountPref = 0L; //Determine size of preferences array. DWORD dwTotal = 11L; if(dwScope==-1) dwTotal--; if(dwOverallTimeOut<=0) dwTotal--; if(dwOverallSizeLimit<=0) dwTotal--; if(dwOverallTimeLimit<=0) dwTotal--; if(bCacheResult) dwTotal--; if(!bIsAsynchronous) dwTotal--; if(dwPageSize<=0) dwTotal--; if(dwPageTimeLimit<=0) dwTotal--; if(dwChaseReferral<=0) dwTotal--; if(!bReturnAttributeNamesOnly) dwTotal--; if (!szSortKey) dwTotal--; ADS_SEARCHPREF_INFO *prefInfo = new ADS_SEARCHPREF_INFO[ dwTotal ]; ADS_SORTKEY SortKey; ////////////////// // Search Scope ////////////////// if(dwScope>=0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = dwScope; dwCountPref++; } ////////////////// // Time Out ////////////////// if(dwOverallTimeOut>0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_TIMEOUT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = dwOverallTimeOut; dwCountPref++; } /////////////// // Size Limit /////////////// if(dwOverallSizeLimit>0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = dwOverallSizeLimit; dwCountPref++; } /////////////// // Time Limit /////////////// if(dwOverallTimeLimit>0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_TIME_LIMIT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = dwOverallTimeLimit; dwCountPref++; } ///////////////// // Cache Result ///////////////// if (!bCacheResult) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_CACHE_RESULTS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Boolean = bCacheResult; dwCountPref++; } ////////////// // Page Size ////////////// if(dwPageSize>0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_PAGESIZE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;; prefInfo[dwCountPref].vValue.Integer = dwPageSize; dwCountPref++; } ////////////////// // Page Time Limit ////////////////// if(dwPageTimeLimit>0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_PAGED_TIME_LIMIT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;; prefInfo[dwCountPref].vValue.Integer = dwPageTimeLimit; dwCountPref++; } /////////////////// // Chase Referrals /////////////////// if(dwChaseReferral>0) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = dwChaseReferral; dwCountPref++; } ///////////// // Sort ///////////// if (szSortKey) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SORT_ON; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_PROV_SPECIFIC; SortKey.pszAttrType = (LPWSTR)LocalAlloc( LPTR, wcslen(szSortKey)*sizeof(WCHAR) +sizeof(WCHAR) ); wcscpy(SortKey.pszAttrType,szSortKey); SortKey.pszReserved = NULL; SortKey.fReverseorder = 0; prefInfo[dwCountPref].vValue.ProviderSpecific.dwLength = sizeof(ADS_SORTKEY); prefInfo[dwCountPref].vValue.ProviderSpecific.lpValue = (LPBYTE) &SortKey; dwCountPref++; } ///////////////// // Asynchronous ///////////////// if(bIsAsynchronous) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ASYNCHRONOUS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Integer = bIsAsynchronous; dwCountPref++; } //////////////////////// // Attribute Type Only //////////////////////// if(bReturnAttributeNamesOnly) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ATTRIBTYPES_ONLY; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Integer = bReturnAttributeNamesOnly; dwCountPref++; } if (SUCCEEDED(hr)) { *pdwSearchPrefCount = dwCountPref; *ppSearchPref = prefInfo; } else { *pdwSearchPrefCount = 0L; *ppSearchPref = NULL; } return hr; }
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_CHASE_REFERRALS_ENUM, ADS_DEREFENUM, ADS_PROV_SPECIFIC, ADS_SEARCHPREF_INFO, ADS_SCOPEENUM, ADS_SORTKEY, ADSVALUE, IDirectorySearch, IDirectorySearch::GetColumn, IDirectorySearch::GetNextRow, Polling for Changes Using the DirSync Control, Retrieving Deleted Objects