![]() |
|
||||
Dumping Attribute Names and Values for Directory ItemsBasically, all you need to do is call DAPIRead, obtain two DAPI_ENTRY pointers (one with attribute names and the other with their values), then traverse them and dump whatever you'll find to the screen. The following sample (Dir/DumpItemAttributes) demonstrates how this may be accomplished. #include <afxwin.h>
void DumpItemAttributes( DAPI_ENTRY * pdeAttributes, DAPI_ENTRY * pdeValues
)
// We assume both pointers to be valid
printf( "ERROR! One of DAPI_ENTRY
pointers is NULL...\n" );
// We also assume number of attributes and values
equal
printf( "ERROR! Number of
attributes is not equal to number of values...\n" );
int iCount = pdeAttributes->unAttributes;
char buffer[BUFFER_SIZE]; // This buffer will hold
attribute names and values
if ( BUFFER_SIZE <= pdeValues->rgEntryValues[i].size ) { printf(
"ERROR! Buffer too small...\n" );
case DAPI_NO_VALUE:
You may insert a call to this function after you have successfully called DAPIRead. It will conveniently dump all retrieved data to the screen. For the sake of experiment I have done this for my Addr-Type object and was amazed to see 50 (!) attributes dumped, many of them with no values (DAPI_NO_VALUE). However, important attributes such as "Obj-Dist-Name" (Object distinguished name), "Admin-Display-Name" and some others have been dumped with values that make sense. One interesting nuance about using this function after DAPIRead is that if you use DAPI_READ_ALL_ATTRIBUTES flag in DAPIRead, you would not be able to see a very important attribute called Proxy-Generator-DLL in your list. However, it will appear with DAPI_READ_DEFINED_ATTRIBUTES. In fact, using this flag will return only attributes with defined values. It is unclear to me why neither DAPI_READ_ALL_ATTRIBUTES, nor combination of it with DAPI_READ_DEFINED_ATTRIBUTES does not return Proxy-Genereator-DLL value and a few others (also very important). Perhaps it is what Microsoft sometimes calls a "feature" (this has been tested with the code as listed in this book on Exchange server 5.0). Anyway, using DAPI_READ_DEFINED_ATTRIBUTES for an Addr-Type object have
returned 15 attributes to me, which is equal to what Exchange Admin lists
when asked for raw properties. The only difference between Exchange Administrator
output and that of the DumpItemAttributes function seems to be the Obj-Class
attribute. Exchange Admin lists it as "Object-Class" which is obviously
similar but not quite the same. Also, the value for Object-Class is binary
and the dialog allows you to choose between two values there. Contrary
to this, the Obj-Class attribute is text and the value is "Addr-Type".
|