Platform SDK: Active Directory, ADSI, and Directory Services |
The ADS_SYSTEMFLAG_ENUM enumeration defines the values that can be assigned to the systemflags attribute of the attributeSchema object, as well as other objects, such as domainDNS objects. The flags specify the types of attributes (also known as properties) represented by an attributeSchema object. For example, for the user object, there are three types of attributes: Domain-replicated and stored properties, Non-replicated and locally stored properties, and Non-stored and constructed properties.
typedef enum { ADS_SYSTEMFLAG_DISALLOW_DELETE = 0x80000000, ADS_SYSTEMFLAG_CONFIG_ALLOW_RENAME = 0x40000000, ADS_SYSTEMFLAG_CONFIG_ALLOW_MOVE = 0x20000000, ADS_SYSTEMFLAG_CONFIG_ALLOW_LIMITED_MOVE = 0x10000000, ADS_SYSTEMFLAG_DOMAIN_DISALLOW_RENAME = 0x08000000, ADS_SYSTEMFLAG_DOMAIN_DISALLOW_MOVE = 0x04000000, ADS_SYSTEMFLAG_CR_NTDS_NC = 0x00000001, ADS_SYSTEMFLAG_CR_NTDS_DOMAIN = 0x00000002, ADS_SYSTEMFLAG_ATTR_NOT_REPLICATED = 0x00000001, ADS_SYSTEMFLAG_ATTR_IS_CONTRUCTED = 0x00000004 } ADS_SYSTEMFLAG_ENUM
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 shows how elements of the ADS_SYSTEMFLAG_ENUM enumeration, together with the IDirectorySearch interface, are used to search non-replicated properties.
#include <wchar.h> #include <activeds.h> HRESULT hr = E_FAIL; LPOLESTR szPath = new OLECHAR[MAX_PATH]; IDirectorySearch *pSchemaNC = NULL; IADs *pObject = NULL; VARIANT var; CoInitialize(NULL); // initialize COM //Get rootDSE and the schema container's distinguished name. //Bind to current user's domain using current user's security context. hr = ADsOpenObject(L"LDAP://rootDSE", NULL, NULL, ADS_SECURE_AUTHENTICATION, //Use Secure Authentication IID_IADs, (void**)&pObject); if (SUCCEEDED(hr)) { hr = pObject->Get(L"schemaNamingContext",&var); if (SUCCEEDED(hr)) { wcscpy(szPath,L"LDAP://"); wcscat(szPath,var.bstrVal); hr = ADsOpenObject(szPath, NULL, NULL, ADS_SECURE_AUTHENTICATION, IID_IDirectorySearch, (void**)&pSchemaNC); if (SUCCEEDED(hr)) { wprintf(L"Find non-replicated attributes\n"); //Create search filter to find attributes with systemFlags that //match ADS_SYSTEMFLAG_ATTR_NOT_REPLICATED LPOLESTR pszSearchFilter = new OLECHAR[MAX_PATH*2]; wsprintf(pszSearchFilter, L"(&(objectCategory=attributeSchema)(systemFlags:1.2.840.113556.1.4.804:=%d))", ADS_SYSTEMFLAG_ATTR_NOT_REPLICATED); //Attributes are one-level deep in the Schema container //so only need to search one level. ADS_SEARCHPREF_INFO SearchPrefs; SearchPrefs.dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; SearchPrefs.vValue.dwType = ADSTYPE_INTEGER; SearchPrefs.vValue.Integer = ADS_SCOPE_ONELEVEL; DWORD dwNumPrefs = 1; // COL for iterations ADS_SEARCH_COLUMN col; // Handle used for searching ADS_SEARCH_HANDLE hSearch; IADs *pObj = NULL; IADs * pIADs = NULL; // Set the search preference hr = pSchemaNC->SetSearchPreference( &SearchPrefs, dwNumPrefs); if (FAILED(hr)) return hr; CONST DWORD dwAttrNameSize = 1; LPOLESTR pszAttribute[dwAttrNameSize]; pszAttribute[0] = L"cn"; // Execute the search hr = pSchemaNC->ExecuteSearch(pszSearchFilter, pszAttribute, dwAttrNameSize, &hSearch ); if ( SUCCEEDED(hr) ) { // Call IDirectorySearch::GetNextRow() to retrieve // the next row of data while( pSchemaNC->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS) { // loop through the array of passed column names, // print the data for each column for (DWORD x = 0; x < dwAttrNameSize; x++) { // Get the data for this column hr = pSchemaNC->GetColumn( hSearch, pszAttribute[x], &col ); if ( SUCCEEDED(hr) ) { // Print the data for the column and // free the column wprintf(L"%s: %s\r\n", pszAttribute[x], col.pADsValues->CaseIgnoreString); pSchemaNC->FreeColumn( &col ); } else wprintf(L"<%s property is not a string>", pszAttribute[x]); } } // Close the search handle to clean up pSchemaNC->CloseSearchHandle(hSearch); } if (pObject) pObject->Release(); VariantClear(&var); CoUninitialize(); // uninitialize COM.
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.