Directory Services |
The ADS_SYSTEMFLAG_ENUM enumeration defines some of the values that can be assigned to the systemflags attribute. Some of the values in the enumeration are specific to attributeSchema objects; other values can be set on objects of any class.
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_CONSTRUCTED = 0x00000004 } ADS_SYSTEMFLAG_ENUM;
For classSchema and attributeSchema objects, the 0x10 bit of the systemFlags attribute indicates an object that is part of the base schema included with Active Directory. This bit cannot be set on new classSchema and attributeSchema objects. The ADS_SYSTEMFLAG_ENUM enumeration does not include a constant for this bit.
Note Because VBScript cannot read data from a type library, VBScript applications do not recognize the symbolic constants as defined above. Use the numeric constants instead to set the appropriate flags in your VBScript applications. 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 example shows how elements of the ADS_SYSTEMFLAG_ENUM enumeration, together with the IDirectorySearch interface, are used to search non-replicated properties.
[C++]
#include <wchar.h>
#include <activeds.h>
#include <atlbase.h>
HRESULT hr = E_FAIL;
LPWSTR szPrefix = L"LDAP://%s";
LPWSTR szPath = NULL;
IDirectorySearch *pSchemaNC = NULL;
IADs *pObject = NULL;
size_t nLength = 0;
LPWSTR pszSearchFilterTemplate = L"(&(objectCategory=attributeSchema)(systemFlags:1.2.840.113556.1.4.804:=%d))";
LPWSTR pszSearchFilter = NULL;
CoInitialize(NULL); // Initialize COM
// Get rootDSE and the schema container 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))
{
CComVarinat svar;
hr = pObject->Get(CComBSTR("schemaNamingContext"), &svar);
if (SUCCEEDED(hr))
{
nLength = wcslen(szPrefix) + wcslen(svar.bstrVal) + 1;
szPath = new WCHAR[nLength];
swprintf(szPath, szPrefix, svar.bstrVal);
hr = ADsOpenObject(szPath,
NULL,
NULL,
ADS_SECURE_AUTHENTICATION,
IID_IDirectorySearch,
(void**)&pSchemaNC);
delete [] szPath;
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
nLength = wcslen(pszSearchFilterTemplate) + 25 + 1;
pszSearchFilter = new WCHAR[nLength];
wsprintf(pszSearchFilter, pszSearchFilterTemplate, 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 );
delete [] pszSearchFilter;
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.
if (col.dwADsType == ADSTYPE_CASE_IGNORE_STRING)
{
wprintf(L"%s: %s\r\n",
pszAttribute[x],
col.pADsValues->CaseIgnoreString);
}
else
{
wprintf(L"<%s property is not a string>", pszAttribute[x]);
}
pSchemaNC->FreeColumn( &col );
}
}
}
// Close the search handle to clean up.
pSchemaNC->CloseSearchHandle(hSearch);
}
}
}
pObject->Release();
}
CoUninitialize(); // uninitialize COM.
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.