home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / dapi.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  71KB  |  1,327 lines

  1.  
  2. /*******************************************************************
  3.  *
  4.  * Copyright (c) Microsoft Corp. 1986-1996. All Rights Reserved.
  5.  *
  6.  *
  7.  *    DESCRIPTION:   This header file defines the functions, structures,
  8.  *                   and macros used to access the Microsoft Exchange
  9.  *                   APIs for modifying entries in the Exchange 4.0 DIT.
  10.  *                   These APIs permit a calling process to create, 
  11.  *                   modify, or delete DIT objects by specifying the
  12.  *                   name of a CSV text file containing attributes 
  13.  *                   for objects to import into ( or to modify) 
  14.  *                   the DIT.  See the Directory Access Functions
  15.  *                   section of the Exchange Developer's Kit for 
  16.  *                   more detailed description of this interface.
  17.  *                   
  18.  *                   Calling programs must link with DAPI.LIB.
  19.  *                   
  20.  *                   Error and warning codes are defined in DAPIMSG.H
  21.  *
  22.  *
  23.  *******************************************************************/
  24.  
  25. /** include files **/
  26. #ifndef _WINDOWS_
  27. #include <windows.h>
  28. #endif
  29.  
  30. /** local definitions **/
  31.  
  32. #ifndef  _DAPI_INCLUDED_
  33. #define  _DAPI_INCLUDED_
  34.  
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39.  
  40. // Import / Export APIs check for the presence of this signature in 
  41. // the dwDAPISignature field in the import parameter blocks.
  42. // This signature will be incremented each time one of the parameter
  43. // blocks is changed so that header synchronization problems can be 
  44. // detected.
  45. #define  DAPI_SIGNATURE                   0x46414400
  46.  
  47.  
  48. // Combinable flags used to control the API functions.
  49.  
  50.    // The following flags control filtering of DAPI events
  51.    // The default action is DAPI_EVENT_ALL
  52. #define DAPI_EVENT_MASK                   0x00000007  /* bit-field containing event-filtering requested 
  53.                                                          if none of these bits are set, DAPI_EVENT_ALL is assumed */
  54. #define DAPI_EVENT_MIN                    0x00000001  /* No warning or error logging.
  55.                                                          Log start and stop messages */
  56. #define DAPI_EVENT_SOME                   0x00000002  /* Start, Stop, and Error messages will be logged. */
  57. #define DAPI_EVENT_ALL                    0x00000004  /* Start, Stop, Error, and Warning messages
  58.                                                          will be logged. */
  59.                                                          
  60.    // The following flags control schema read and use of the schema
  61. #define DAPI_FORCE_SCHEMA_LOAD            0x00000010  /* Unload previously loaded schema
  62.                                                          and read schema again.
  63.                                                          Default action is to re-use
  64.                                                          previously loaded schema if read
  65.                                                          from the same messaging domain */
  66. #define DAPI_RAW_MODE                     0x00000020  /* Import / Export in "Raw" mode.  Import
  67.                                                          lines are taken literally.  No
  68.                                                          attributes will be inherited, 
  69.                                                          constructed, etc.  Aliases for 
  70.                                                          attribute and class names will
  71.                                                          not be recognized. */
  72.                                                          
  73. #define DAPI_OVERRIDE_CONTAINER           0x00000040  /* Container specified in the parameter block
  74.                                                          overrides the contents of the container column.
  75.                                                          Default behaviour is for the value specified
  76.                                                          in the Obj-Container column to override
  77.                                                          that specified in the parameter block */
  78.                                                  
  79. #define DAPI_IMPORT_NO_ERR_FILE           0x00000080  /* Do not create Error File -- BatchImport only */
  80. #define DAPI_IMPORT_WRITE_THROUGH         0x00400000  /* Commit write operations immediately */
  81.  
  82. // Flags defined for "Batch" operations only -- ignored by DAPIRead, DAPIWrite
  83. #define DAPI_YES_TO_ALL                   0x00000100  /* Force "yes" response on any
  84.                                                          user-prompt UI 
  85.                                                          (i.e., continue w/o proxy addresses, etc.) */
  86.  
  87. #define DAPI_SUPPRESS_PROGRESS            0x00000200  /* Suppress progress thermometer on batch operations.
  88.                                                          Default is to display progress */
  89. #define DAPI_SUPPRESS_COMPLETION          0x00000400  /* Suppress completion notification message box on batch operations */
  90.                                                          
  91. #define DAPI_SUPPRESS_ARCHIVES            0x00000800  /* Suppress creation of "archive" copies
  92.                                                          of output files -- BatchImport and BatchExport only*/
  93.                                                          
  94.  
  95.  
  96. // Flags defined for BatchExport
  97. #define DAPI_EXPORT_MAILBOX               0x00001000  /* Export Mailbox recipients */
  98. #define DAPI_EXPORT_CUSTOM                0x00002000  /* Export remote address recipients */
  99. #define DAPI_EXPORT_DIST_LIST             0x00004000  /* Export Distribution Lists */
  100. #define DAPI_EXPORT_RECIPIENTS       (DAPI_EXPORT_MAILBOX | DAPI_EXPORT_CUSTOM | DAPI_EXPORT_DIST_LIST)
  101.                                                       /* Export all recipient objects */
  102.  
  103. #define DAPI_EXPORT_ALL_CLASSES           0x00008000  /* If this flag is set, all objects meeting other restrictions
  104.                                                          (i.e., USN level, container scope, etc.) will be exported,
  105.                                                          regardless of class */
  106.  
  107. #define DAPI_EXPORT_HIDDEN                0x00010000  /* Include Hidden objects in export.
  108.                                                                       Default is no export if Hide-From-Address-Book */
  109. #define DAPI_EXPORT_SUBTREE               0x00020000  /* Traverse the Directory Information Tree hierarchy,
  110.                                                          exporting objects that meet the export restrictions */
  111. #define DAPI_EXPORT_BASEPOINT_ONLY        0x00040000  /* Export only the requested attributes from
  112.                                                          the named BasePoint object.  All other 
  113.                                                          export restrictions are ignored (class flags, 
  114.                                                          rgpszClasses, pszServerName). 
  115.                                                          This flag implies DAPI_SUPPRESS_PROGRESS
  116.                                                          and DAPI_SUPPRESS_COMPLETION */
  117.  
  118. // Flags defined only for BatchImport
  119. #define DAPI_OVERRIDE_SYNCH_STATE         0x00080000  /* Override server's synchronization status,
  120.                                                          normally checked on BatchImport.
  121.                                                          NOTE:  This flag should normally NOT be set.
  122.                                                                 The normal behaviour is to prevent BatchImport
  123.                                                                 operations from possible conflict with directory
  124.                                                                 synchronization */
  125.  
  126.  
  127. // Flags defined only for DAPIRead                                                         
  128. #define  DAPI_READ_DEFINED_ATTRIBUTES     0x00100000  /* return all attributes that are set
  129.                                                          for the current object. 
  130.                                                          This flag is ignored if pAttributes is specified. */
  131.  
  132. #define  DAPI_READ_ALL_ATTRIBUTES         0x00200000  /* return all attributes that are defined
  133.                                                          for the class of the current object. 
  134.                                                          This flag is ignored if pAttributes is specified. */
  135.  
  136.  
  137.  // The following flags control NT Security management
  138. #define DAPI_RESTRICT_ACCESS              0x01000000  /* Apply NT Security Descriptor to 
  139.                                                          created objects */
  140. #define DAPI_CREATE_NT_ACCOUNT            0x02000000  /* Create NT accounts 
  141.                                                          (valid only in Create/Modify mode) */
  142. #define DAPI_CREATE_RANDOM_PASSWORD       0x04000000  /* Generate random passwords for
  143.                                                          created NT accounts.  Ignored if DAPI_CREATE_NT_ACCOUNT
  144.                                                          is not set */
  145.                                                          
  146. #define DAPI_DELETE_NT_ACCOUNT            0x08000000  /* Delete ASSOC-NT-ACCOUNT when
  147.                                                          deleting mailbox */
  148. // Flags defined only for DAPIWrite
  149. #define DAPI_MODIFY_REPLACE_PROPERTIES    0x00800000  /* Append values to multi-value attributes when modifying */
  150.  
  151. #define  DAPI_WRITE_UPDATE                0x10000000  /* Modify if object exists, create if it doesn't.
  152.                                                          NOTE:  This is the default mode */
  153. #define  DAPI_WRITE_CREATE                0x20000000  /* Create object -- fail if object exists */
  154. #define  DAPI_WRITE_MODIFY                0x30000000  /* Modify object -- fail if object does not exist */
  155. #define  DAPI_WRITE_DELETE                0x40000000  /* Delete object */
  156. #define  DAPI_WRITE_MODE_MASK             0x70000000
  157.  
  158.  
  159.  
  160. // Callback flags
  161. #define  DAPI_CALLBACK_CHAIN              0x00000001  /* If set in dwFlags field of the ERROR_CALLBACK
  162.                                                          and the CALLBACKPROGRESS structures, the default
  163.                                                          handler will be invoked after calling out to the 
  164.                                                          caller-supplied handler function, unless the user
  165.                                                          function returns FALSE, indicating cancel.
  166.                                                          NOTE:  This flag is not defined for the EXPORT_CALLBACK
  167.                                                                 structure.
  168.                                                          NOTE:  This flag should not be set in the dwFlags
  169.                                                                 field of the main parameter block */
  170.  
  171.  
  172. // default delimiter values used when parsing the import file
  173.  
  174. #define DAPI_DEFAULT_DELIMA   ','
  175. #define DAPI_DEFAULT_QUOTEA   '"'
  176. #define DAPI_DEFAULT_MV_SEPA  '%'
  177. #define DAPI_DEFAULT_DELIMW   L','
  178. #define DAPI_DEFAULT_QUOTEW   L'"'
  179. #define DAPI_DEFAULT_MV_SEPW  L'%'
  180.  
  181.  
  182. #define DAPI_CTRL_FILE_PTRA   '='
  183. #define DAPI_CTRL_FILE_PTRW   L'='
  184. #define DAPI_CTRL_ANR_PREFIXA '='
  185. #define DAPI_CTRL_ANR_PREFIXW L'='
  186. #define DAPI_CTRL_META_CHARA  '~'
  187. #define DAPI_CTRL_META_CHARW  L'~'
  188. #define pszSubstServerA       "~SERVER"
  189. #define pszSubstServerW       L"~SERVER"
  190. #define cchSubstServer        ((sizeof (pszSubstServerA) / sizeof(CHAR)) - 1)
  191. #define pszDeleteKeyA         "~DEL"
  192. #define pszDeleteKeyW         L"~DEL"
  193. #define cchDeleteKey          ((sizeof (pszDeleteKeyA) / sizeof(CHAR)) - 1)
  194.  
  195. #define DAPI_UNICODE_FILE     ((UINT)-1)
  196.  
  197. #ifdef UNICODE
  198.  
  199. #define DAPI_DEFAULT_DELIM    DAPI_DEFAULT_DELIMW
  200. #define DAPI_DEFAULT_QUOTE    DAPI_DEFAULT_QUOTEW
  201. #define DAPI_DEFAULT_MV_SEP   DAPI_DEFAULT_MV_SEPW
  202. #define DAPI_CTRL_FILE_PTR    DAPI_CTRL_FILE_PTRW
  203. #define DAPI_CTRL_ANR_PREFIX  DAPI_CTRL_ANR_PREFIXW
  204. #define DAPI_CTRL_META_CHAR   DAPI_CTRL_META_CHARW
  205. #define pszSubstServer        pszSubstServerW
  206. #define pszDeleteKey          pszDeleteKeyW
  207.  
  208. #else
  209.  
  210. #define DAPI_DEFAULT_DELIM    DAPI_DEFAULT_DELIMA
  211. #define DAPI_DEFAULT_QUOTE    DAPI_DEFAULT_QUOTEA
  212. #define DAPI_DEFAULT_MV_SEP   DAPI_DEFAULT_MV_SEPA
  213. #define DAPI_CTRL_FILE_PTR    DAPI_CTRL_FILE_PTRA
  214. #define DAPI_CTRL_ANR_PREFIX  DAPI_CTRL_ANR_PREFIXA
  215. #define DAPI_CTRL_META_CHAR   DAPI_CTRL_META_CHARA
  216. #define pszSubstServer        pszSubstServerA
  217. #define pszDeleteKey          pszDeleteKeyA
  218.  
  219. #endif
  220.  
  221.  
  222. /*******************************************************************************
  223. * Batch Operation Progress Callback Function Definitions
  224. * Pointers to functions of these types are provided by the caller via the 
  225. * CALLBACKPROGRESS structure in the Batch function parameter block
  226. *               
  227. ********************************************************************************
  228. *               
  229. *  procedure :  PDAPI_FInitProgress
  230. *               
  231. *    purpose :  Initialize progress handler (possibly progress display dialog)
  232. *               
  233. * parameters :  lpvAppDefined value provided in the progress callback structure
  234. *               nMac          Maximum Anticipated Calls.  If non-zero, this indicates
  235. *                             the number of progress events anticipated.
  236. *                             If zero, the number of items to process is unknown,
  237. *                             so the number of calls to UpdateProgress is indeterminate.
  238. *               
  239. *    returns :  TRUE    Indicates that all is well
  240. *               FALSE   Could not initialize progress handler, cancel session.
  241. *               
  242. ********************************************************************************
  243. *               
  244. *  procedure :  PDAPI_FResetProgress
  245. *               
  246. *    purpose :  Re-initialize progress handler (possibly reset progress bar)
  247. *               
  248. * parameters :  lpvAppDefined value provided in the progress callback structure
  249. *               nMac          Maximum Anticipated Calls.  If non-zero, this indicates
  250. *                             the number of progress events anticipated.
  251. *                             If zero, the number of items to process is unknown,
  252. *                             so the number of calls to UpdateProgress is indeterminate.
  253. *               
  254. *    returns :  TRUE    Indicates that all is well
  255. *               FALSE   Could not re-initialize progress handler, cancel session.
  256. *               
  257. ********************************************************************************
  258. *               
  259. *  procedure :  PDAPI_FEndProgress
  260. *               
  261. *    purpose :  Terminate progress handler (possibly progress display dialog)
  262. *               
  263. * parameters :  lpvAppDefined value provided in the progress callback structure
  264. *               
  265. *    returns :  TRUE    Indicates that all is well
  266. *               FALSE   Could not terminate progress handler, cancel session.
  267. *               
  268. ********************************************************************************
  269. *               
  270. *  procedure :  PDAPI_FUpdateProgress
  271. *               
  272. *    purpose :  Completed processing item.  Called to indicate time to increment
  273. *               progress display.
  274. *               
  275. * parameters :  lpvAppDefined value provided in the progress callback structure
  276. *               
  277. *    returns :  TRUE    Indicates that all is well
  278. *               FALSE   Cancel session (i.e., cancel button pressed).
  279. *               
  280. ********************************************************************************
  281. *               
  282. *  procedure :  PDAPI_FUpdateProgressText
  283. *               
  284. *    purpose :  Replace progress text area with provided text string
  285. *               
  286. * parameters :  lpvAppDefined value provided in the progress callback structure
  287. *               
  288. *    returns :  TRUE    Indicates that all is well
  289. *               FALSE   Cancel session (i.e., cancel button pressed).
  290. *               
  291. ********************************************************************************/
  292. typedef BOOL (PASCAL * PDAPI_FInitProgress)
  293.                           (LPVOID lpvAppDefined, INT nMac);
  294. typedef BOOL (PASCAL * PDAPI_FUpdateProgress)
  295.                           (LPVOID lpvAppDefined);
  296. typedef BOOL (PASCAL * PDAPI_FEndProgress)
  297.                           (LPVOID lpvAppDefined);
  298. typedef BOOL (PASCAL * PDAPI_FResetProgress)
  299.                           (LPVOID lpvAppDefined, INT nMac);
  300. typedef BOOL (PASCAL * PDAPI_FUpdateProgressText)
  301.                           (LPVOID lpvAppDefined, LPTSTR pszText);
  302.             
  303. typedef struct CallBackProgressEntryPoints
  304. {
  305.    DWORD                      dwFlags;
  306.    LPVOID                     lpvAppDefined;
  307.    PDAPI_FInitProgress        pfnInitProgress;
  308.    PDAPI_FUpdateProgress      pfnUpdateProgress;
  309.    PDAPI_FEndProgress         pfnEndProgress;
  310.    PDAPI_FResetProgress       pfnResetProgress;
  311.    PDAPI_FUpdateProgressText  pfnUpdateProgressText;
  312. } CALLBACKPROGRESS, *PCALLBACKPROGRESS;
  313.  
  314.  
  315.  
  316. // Values specified in the ulEvalTag field of the 
  317. //    DAPI_ENTRY and EXPORT_CALLBACK structures
  318. //    
  319. typedef enum _DAPI_EVAL
  320. {
  321.    VALUE_ARRAY = 0,           // Each attribute has an entry in the array
  322.                               //    Text strings and object names exported as text
  323.                               //    Numerical values exported as numbers
  324.                               //    Binary data exported as binary string
  325.    TEXT_VALUE_ARRAY,          // Each attribute has an entry in the array
  326.                               //    All values converted to text representation
  327.    TEXT_LINE                  // first item in the rgEntryValues array
  328.                               //    is a delimited text line
  329. } DAPI_EVAL, *PDAPI_EVAL;
  330.  
  331. typedef enum _EXP_TYPE_TAG
  332. {
  333.    EXPORT_HEADER = 0,         // export item contains column headers
  334.    EXPORT_ENTRY               // export item contains attribute values
  335. } EXP_TYPE, * PEXP_TYPE;
  336.  
  337.  
  338. typedef enum enumDAPI_DATA_TYPE
  339. {
  340.    DAPI_NO_VALUE = 0,
  341.    DAPI_STRING8,
  342.    DAPI_UNICODE,
  343.    DAPI_BINARY,
  344.    DAPI_INT,
  345.    DAPI_BOOL,
  346. } DAPI_DATA_TYPE, * PDAPI_DATA_TYPE;
  347.  
  348. #ifdef UNICODE
  349. #define DAPI_TEXT DAPI_UNICODE
  350. #else
  351. #define DAPI_TEXT DAPI_STRING8
  352. #endif
  353.  
  354. typedef union _DAPI_VALUE
  355. {
  356.    LPSTR    pszA;
  357.    LPWSTR   pszW;
  358. #ifdef UNICODE
  359.    LPWSTR   pszValue;
  360. #else
  361.    LPSTR    pszValue;
  362. #endif
  363.    LPBYTE   lpBinary;
  364.    INT      iValue;
  365.    BOOL     bool;
  366. } DAPI_VALUE, * PDAPI_VALUE;
  367.  
  368.  
  369.  
  370. // The ATT_VALUE structure contains a text representation of an attribute value
  371. // A linked list of these structures is used for a multi-valued attribute
  372. typedef struct _ATT_VALUE
  373. {
  374.    DAPI_DATA_TYPE       DapiType;         // How to evaluate DAPI_VALUE union
  375.    DAPI_VALUE           Value;
  376.    UINT                 size;             // size of the value -- 
  377.                                           //    # chars if string type
  378.                                           //    else, # bytes
  379.    struct _ATT_VALUE *  pNextValue;
  380. } ATT_VALUE, * PATT_VALUE;
  381.  
  382.  
  383. typedef struct _DAPI_ENTRY
  384. {
  385.    UINT           unAttributes;              // Number of attributes exported
  386.    DAPI_EVAL      ulEvalTag;                 // rgEntryValues is interpreted based on this value
  387.    PATT_VALUE     rgEntryValues;             // if (ulEvalTag == TEXT_LINE)
  388.                                              //    There is a single value, w/ delimited line
  389.                                              // else
  390.                                              //    unAttributes, each w/ 1 or more value in list
  391. } DAPI_ENTRY, * PDAPI_ENTRY;
  392.  
  393. // Define type for address of application routine 
  394. // for call-back on each exported entry.
  395. // Return value of FALSE indicates that export operation should be cancelled
  396. typedef BOOL (PASCAL DAPI_FNExportEntry) (
  397.                EXP_TYPE    ExportDataType,   // What type of data is being exported
  398.                LPVOID      lpvAppDefined,    // Application-defined parameter,
  399.                                              // passed in EXPORT_CALLBACK structure
  400.                                              // on initialization
  401.                PDAPI_ENTRY pExportEntry      // pointer to exported entry data
  402.                                              // NOTE: Data in this structure
  403.                                              // will NOT remain valid after return
  404.                                              // from this function
  405.                );
  406. typedef DAPI_FNExportEntry * PDAPI_FNExportEntry;
  407.  
  408. typedef struct _EXPORT_CALLBACK
  409. {
  410.    DWORD       dwFlags;                      // Flags defined to control callback functionality
  411.                                              // See flag definitions below
  412.    DAPI_EVAL   ulEvalTag;                    // Specifies data format on callback
  413.    LPVOID      lpvAppDefined;                // Application-defined field, passed as parm to callback
  414.    PDAPI_FNExportEntry  pfnExportEntry;      // Pointer to function called to process
  415.                                              // each exported entry
  416.  
  417. } EXPORT_CALLBACK, * PEXPORT_CALLBACK;
  418.  
  419.  
  420.  
  421. /*******************************************************************************
  422. *  procedure :  pfnErrorCallback
  423. *               
  424. *    purpose :  The following section defines structures for the error callback
  425. *               mechanism of the Batch Import APIs
  426. *               Events will be filtered based on the ControlfFlags set in the 
  427. *               API parameter block
  428. *               
  429. ********************************************************************************/
  430.  
  431. // Define flags used for export callback
  432.  
  433. // Define the maximum number of substitutions in a single event string
  434. #define DAPI_MAX_SUBST 8
  435.  
  436.  
  437. typedef struct _DAPI_EVENTA
  438. {
  439.    DWORD             dwDAPIError;            // Message ID for event log
  440.    LPSTR             rgpszSubst[DAPI_MAX_SUBST];   // Event message substitution array
  441.    UINT              unSubst;                // number of substitution strings
  442.    LPSTR             pszAttribute;           // Name of attribute specifically affected
  443.                                              //    Note:  may be NULL on some errors
  444.    LPSTR             pszHoldLine;            // point to buffer containing copy
  445.                                              //    of current import line
  446.    HINSTANCE         hinstDAPI;              // Instance of DAPI DLL
  447.    struct _DAPI_EVENTA * pNextEvent;       // Pointer to next event
  448. } DAPI_EVENTA, *PDAPI_EVENTA;
  449.  
  450. typedef struct _DAPI_EVENTW
  451. {
  452.    DWORD             dwDAPIError;            // Message ID for event log
  453.    LPWSTR            rgpszSubst[DAPI_MAX_SUBST];   // Event message substitution array
  454.    UINT              unSubst;                // number of substitution strings
  455.    LPWSTR            pszAttribute;           // Name of attribute specifically affected
  456.                                              //    Note:  may be NULL on some errors
  457.    LPWSTR            pszHoldLine;            // point to buffer containing copy
  458.                                              //    of current import line
  459.    HINSTANCE         hinstDAPI;              // Instance of DAPI DLL
  460.    struct _DAPI_EVENTW * pNextEvent;       // Pointer to next event
  461. } DAPI_EVENTW, *PDAPI_EVENTW;
  462.  
  463. #ifdef UNICODE
  464. typedef DAPI_EVENTW  DAPI_EVENT;
  465. typedef PDAPI_EVENTW PDAPI_EVENT;
  466. #else
  467. typedef DAPI_EVENTA  DAPI_EVENT;
  468. typedef PDAPI_EVENTA PDAPI_EVENT;
  469. #endif
  470.  
  471. // Define type for address of application routine 
  472. // for call-back on each error encountered.
  473. // Return value of FALSE indicates that operation should be cancelled
  474. typedef BOOL (PASCAL DAPI_FNErrorCallback) (
  475.                LPVOID      lpvAppDefined,    // Application-defined parameter,
  476.                                              // passed in EXPORT_CALLBACK structure
  477.                                              // on initialization
  478.                PDAPI_EVENT pDapiEvent        // Event information structure
  479.                                              // NOTE: Data in the event record
  480.                                              // will NOT remain valid after return
  481.                                              // from this function
  482.                );
  483. typedef DAPI_FNErrorCallback * PDAPI_FNErrorCallback;
  484.  
  485.  
  486. typedef struct tagERROR_CALLBACK
  487. {
  488.    DWORD                   dwFlags;          // Flags defined to control callback functionality
  489.                                              // See flag definitions above
  490.    LPVOID                  lpvAppDefined;    // Application-defined field, passed back in callback
  491.    PDAPI_FNErrorCallback   pfnErrorCallback; // Address of function that should be
  492.                                              // called on each error encountered
  493.                                              // If not supplied (NULL), default
  494.                                              // error handler is called, which
  495.                                              // writes the error into the 
  496.                                              // NT Application event log
  497.  
  498. } ERROR_CALLBACK, * PERROR_CALLBACK;
  499.  
  500.  
  501.  
  502.  
  503.  
  504. /*******************************************************************************
  505. *  
  506. *   Batch Directory Import Interface definitions
  507. *               
  508. ********************************************************************************/
  509.  
  510. /*******************************************************************************
  511. *  procedure :  DAPIUninitialize
  512. *               
  513. *    purpose :  Notify DAPI that it is time to terminate background threads
  514. *               and such in preparation for process shutdown
  515. *               
  516. * parameters :  dwFlags        combinable bits which may be set to control function
  517. *               
  518. *    returns :  nothing
  519. *               
  520. *    created :  11/01/95 
  521. *               
  522. *    changes :  
  523. *               
  524. ********************************************************************************/
  525. extern void APIENTRY DAPIUninitialize (
  526.                               DWORD    dwFlags // Flags for call
  527. );
  528.  
  529.  
  530.  
  531. /*******************************************************************************
  532. *  procedure :  SchemaPreload
  533. *               
  534. *    purpose :  Called to perform asyncronous schema load.  This entry point
  535. *               spawns a thread that initializes all the attribute and class
  536. *               tables for normal import/export operation.
  537. *               
  538. * parameters :  pSchemaPreloadParms    pointer to SchemaPreloadParameter block
  539. *               
  540. *    returns :  nothing
  541. *               
  542. *    history :  
  543. *               
  544. ********************************************************************************/
  545. extern void APIENTRY SchemaPreloadA (
  546.                               DWORD    dwFlags, // Flags used to control schema load.
  547.                               LPSTR    pszDSA   // name of DSA from which to read schema
  548. );
  549.  
  550. extern void APIENTRY SchemaPreloadW (
  551.                               DWORD    dwFlags, // Flags used to control schema load.
  552.                               LPWSTR   pszDSA   // name of DSA from which to read schema
  553. );
  554.  
  555. #ifdef UNICODE
  556. #define  SchemaPreload  SchemaPreloadW
  557. #else
  558. #define  SchemaPreload  SchemaPreloadA
  559. #endif
  560.  
  561. typedef struct _BIMPORT_PARMSW
  562. {
  563.    // NOTE:  the order of the first three fields of this structure 
  564.    //       should NOT be changed.
  565.    DWORD    dwDAPISignature;
  566.    DWORD    dwFlags;             // Bitmapped flags that control import action
  567.    HWND     hwndParent;                // Windows handle to use when displaying message boxes
  568.    LPWSTR   pszImportFile;       // Fully qualified pathname to Import Data file
  569.                                  //   On Batch Import, objects are imported into
  570.                                  //   the DIT from this file.
  571.    UINT     uCodePage;           // Code page specification for import file.
  572.                                  // The following values are interpreted:
  573.                                  // DAPI_UNICODE_FILE    Import file is Unicode
  574.                                  //                        Will return error if file is ANSI
  575.                                  // 0                    Auto-detect file type
  576.                                  //                        If ANSI, assume CP_ACP
  577.                                  // other                File contains text in the
  578.                                  //                        specified code page
  579.                                  //                        Will return error if file is Unicode
  580.                                  //                      Will return error if code page is not
  581.                                  //                        supported by the system
  582.    LPWSTR   pszDSAName;          // Computer name of DSA to update
  583.                                  //    Default:  local DSA (if operating)
  584.                                  //              if no local DSA, first DSA found 
  585.                                  //              on network is used
  586.    LPWSTR   pszBasePoint;        // DN of base-point in DIT for bulk operations
  587.                                  //    Default values:
  588.                                  //       if NULL, Messaging Site containing bound server
  589.                                  //       if empty string, enterprise containing bound server
  590.    LPWSTR   pszContainer;        // RDN of default container under which
  591.                                  //    to perform bulk import operations
  592.                                  //    NOTE:  This container is assumed to be
  593.                                  //          at the level below that indicated by
  594.                                  //          the pszBasePoint.  If NULL, 
  595.                                  //          bulk operations will be performed at
  596.                                  //          the level below BaseImportPoint.
  597.                                  //          Container names specified in the 
  598.                                  //          import file will override this value.
  599.    WCHAR    chColSep;            // Column Separator -- 
  600.                                  //    DEFAULT_DELIM is used if this value is zero
  601.    WCHAR    chQuote;             // String enclosing character -- 
  602.                                  //    DEFAULT_QUOTE is used if this value is zero
  603.    WCHAR    chMVSep;             // Multi-value Property Separator --
  604.                                  //    DEFAULT_MV_SEP is used if this value is zero
  605.    WCHAR    creserved;           // alignment
  606.    CALLBACKPROGRESS  ProgressCallBacks;    // Progress call-back entry points
  607.    ERROR_CALLBACK    ErrorCallback;
  608.    
  609.    LPWSTR   pszNTDomain;         // Name of NT Domain in which to lookup / create NT accounts.
  610.                                  //    Defaults to current logon domain if NULL or empty
  611.    LPWSTR   pszCreateTemplate;   // DN of the Default User (NULL if none) from which
  612.                                  //    to draw template values
  613.  
  614. } BIMPORT_PARMSW, *PBIMPORT_PARMSW, *LPBIMPORT_PARMSW;
  615.  
  616. typedef struct _BIMPORT_PARMSA
  617. {
  618.    // NOTE:  the order of the first three fields of this structure 
  619.    //       should NOT be changed.
  620.    DWORD    dwDAPISignature;
  621.    DWORD    dwFlags;             // Bitmapped flags that control import action
  622.    HWND     hwndParent;          // Windows handle to use when displaying message boxes
  623.    LPSTR    pszImportFile;       // Fully qualified pathname to Import Data file
  624.                                  //   On Batch Import, objects are imported into
  625.                                  //   the DIT from this file.
  626.    UINT     uCodePage;           // Code page specification for import file.
  627.                                  // The following values are interpreted:
  628.                                  // DAPI_UNICODE_FILE    Import file is Unicode
  629.                                  //                        Will return error if file is ANSI
  630.                                  // 0                    Auto-detect file type
  631.                                  //                        If ANSI, assume CP_ACP
  632.                                  // other                File contains text in the
  633.                                  //                        specified code page
  634.                                  //                        Will return error if file is Unicode
  635.                                  //                      Will return error if code page is not
  636.                                  //                        supported by the system
  637.    LPSTR    pszDSAName;          // Computer name of DSA to update
  638.                                  //    Default:  local DSA (if operating)
  639.                                  //              if no local DSA, first DSA found 
  640.                                  //              on network is used
  641.    LPSTR    pszBasePoint;        // DN of base-point in DIT for bulk operations
  642.                                  //    Default values:
  643.                                  //       if NULL, Messaging Site containing bound server
  644.                                  //       if empty string, enterprise containing bound server
  645.    LPSTR    pszContainer;        // RDN of default container under which
  646.                                  //    to perform bulk import operations
  647.                                  //    NOTE:  This container is assumed to be
  648.                                  //          at the level below that indicated by
  649.                                  //          the pszBasePoint.  If NULL, 
  650.                                  //          bulk operations will be performed at
  651.                                  //          the level below BaseImportPoint.
  652.                                  //          Container names specified in the 
  653.                                  //          import file will override this value.
  654.    CHAR     chColSep;            // Column Separator -- 
  655.                                  //    DEFAULT_DELIM is used if this value is zero
  656.    CHAR     chQuote;             // String enclosing character -- 
  657.                                  //    DEFAULT_QUOTE is used if this value is zero
  658.    CHAR     chMVSep;             // Multi-value Property Separator --
  659.                                  //    DEFAULT_MV_SEP is used if this value is zero
  660.    CHAR     creserved;           // alignment
  661.    CALLBACKPROGRESS  ProgressCallBacks;    // Progress call-back entry points
  662.    ERROR_CALLBACK    ErrorCallback;
  663.    
  664.    LPSTR    pszNTDomain;         // Name of NT Domain in which to lookup / create NT accounts.
  665.                                  //    Defaults to current logon domain if NULL or empty
  666.    LPSTR    pszCreateTemplate;   // DN of the Default User (NULL if none) from which
  667.                                  //    to draw template values
  668.  
  669. } BIMPORT_PARMSA, *PBIMPORT_PARMSA, *LPBIMPORT_PARMSA;
  670.  
  671. #ifdef UNICODE
  672. typedef  BIMPORT_PARMSW    BIMPORT_PARMS;
  673. typedef  PBIMPORT_PARMSW   PBIMPORT_PARMS;
  674. typedef  LPBIMPORT_PARMSW  LPBIMPORT_PARMS;
  675. #else
  676. typedef  BIMPORT_PARMSA    BIMPORT_PARMS;
  677. typedef  PBIMPORT_PARMSA   PBIMPORT_PARMS;
  678. typedef  LPBIMPORT_PARMSA  LPBIMPORT_PARMS;
  679. #endif
  680.  
  681. // The BatchImport function provides single-call BatchImport from the
  682. //    specified import file.  All import parameters are specified in the
  683. //    BIMPORT_PARMS structure pointed to by lpBimportParms.
  684. //    The return value indicates the number of errors logged in the
  685. //    NT Application log.  Please note that this does not indicate
  686. //    success or failure of the Batch Import.
  687. //    UI and Logging of errors and warnings into the Application log 
  688. //    are controlled through import parameters.
  689. extern DWORD APIENTRY BatchImportW (LPBIMPORT_PARMSW lpBimportParms);
  690. extern DWORD APIENTRY BatchImportA (LPBIMPORT_PARMSA lpBimportParms);
  691.  
  692. #ifdef UNICODE
  693. #define BatchImport        BatchImportW
  694. #else
  695. #define BatchImport        BatchImportA
  696. #endif
  697.  
  698. /*******************************************************************************
  699. *  
  700. *   Batch Directory Export Interface definitions
  701. *               
  702. ********************************************************************************/
  703.  
  704. typedef struct _BEXPORT_PARMSW
  705. {
  706.    DWORD    dwDAPISignature;
  707.    DWORD    dwFlags;             // Bitmapped flags that control export action
  708.    HWND     hwndParent;          // Windows handle to use when displaying message boxes
  709.    LPWSTR   pszExportFile;       // Fully qualified pathname of file to export into
  710.                                  //   Ignored if ExportCallback is specified
  711.    UINT     uCodePage;           // Code page specification for export file.
  712.                                  // The following values are interpreted:
  713.                                  // DAPI_UNICODE_FILE    Export file is Unicode.
  714.                                  //                      Will return error 
  715.                                  //                        if file exists and is ANSI
  716.                                  // 0                    Auto-detect file type
  717.                                  //                        If file does not exist,
  718.                                  //                          export file will contain CP_ACP text.
  719.                                  //                        If file exists and is ANSI
  720.                                  //                          export file will contain CP_ACP text.
  721.                                  //                        If file exists and is Unicode,
  722.                                  //                          export file will contain Unicode
  723.                                  // other                Export text to file in the
  724.                                  //                        specified code page
  725.                                  //                      Will return error 
  726.                                  //                        if file exists and is Unicode
  727.                                  //                      Will return error if code page is not
  728.                                  //                        supported by the system
  729.    LPWSTR   pszDSAName;          // Computer name of DSA from which to export
  730.                                  //    Default:  local DSA (if operating)
  731.                                  //              if no local DSA, first DSA found 
  732.                                  //              on network is used
  733.    LPWSTR   pszBasePoint;        // DN of base-point in DIT for bulk operations
  734.                                  //    Default values:
  735.                                  //       if NULL, Messaging Site containing bound server
  736.                                  //       if empty string, enterprise containing bound server
  737.    LPWSTR   pszContainer;        // RDN of container from which to export objects
  738.                                  //    NOTE:  This container is assumed to be
  739.                                  //          at the level below that indicated by
  740.                                  //          the pszBasePoint.  If NULL, 
  741.                                  //          the contents of all containers below
  742.                                  //          the BaseImportPoint will be exported.
  743.    WCHAR     chColSep;           // Column Separator -- 
  744.                                  //    DEFAULT_DELIM is used if this value is zero
  745.    WCHAR     chQuote;            // String enclosing character -- 
  746.                                  //    DEFAULT_QUOTE is used if this value is zero
  747.    WCHAR     chMVSep;            // Multi-value Property Separator --
  748.                                  //    DEFAULT_MV_SEP is used if this value is zero
  749.    WCHAR     cReserved;          // alignment
  750.  
  751.    CALLBACKPROGRESS  ProgressCallBacks;    // Progress call-back entry points
  752.    ERROR_CALLBACK    ErrorCallback;
  753.    EXPORT_CALLBACK   ExportCallback;   // Structure filled in by calling app to 
  754.                                        // receive callback on each exported item
  755.                                        // NOTE:  Callback functions are optional
  756.                                        // The default export function (write to file)
  757.                                        // will be called if these pointers are NULL
  758.    PDAPI_ENTRY       pAttributes;      // DAPI_ENTRY filled with names of attributes to export
  759.                                        // Optional if pszExportFile specified
  760.                                        // Required if ExportCallback specified
  761.    LPWSTR   pszHomeServer;       // Name of server for server-associated export
  762.    LPWSTR * rgpszClasses;        // array of pointers to zero-terminated object classes to export
  763.                                  // The last entry must be NULL
  764.                                  // NOTE:  The Directory will be queried for objects
  765.                                  //          of the classes in the specified order.
  766.    ULONG       ulUSNBase;        // Base USN to use for export restriction.  
  767.                                  //    If non-zero, only items having USN-Changed >= ulUSNBase will be exported
  768.    LPVOID      pReserved;        // Reserved -- Must be zero
  769.    
  770. } BEXPORT_PARMSW, *PBEXPORT_PARMSW, *LPBEXPORT_PARMSW;
  771.  
  772. typedef struct _BEXPORT_PARMSA
  773. {
  774.    DWORD    dwDAPISignature;
  775.    DWORD    dwFlags;             // Bitmapped flags that control export action
  776.    HWND     hwndParent;          // Windows handle to use when displaying message boxes
  777.    LPSTR    pszExportFile;       // Fully qualified pathname of file to export into
  778.                                  //   Ignored if ExportCallback is specified
  779.    UINT     uCodePage;           // Code page specification for export file.
  780.                                  // The following values are interpreted:
  781.                                  // DAPI_UNICODE_FILE    Export file is Unicode.
  782.                                  //                      Will return error 
  783.                                  //                        if file exists and is ANSI
  784.                                  // 0                    Auto-detect file type
  785.                                  //                        If file does not exist,
  786.                                  //                          export file will contain CP_ACP text.
  787.                                  //                        If file exists and is ANSI
  788.                                  //                          export file will contain CP_ACP text.
  789.                                  //                        If file exists and is Unicode,
  790.                                  //                          export file will contain Unicode
  791.                                  // other                Export text to file in the
  792.                                  //                        specified code page
  793.                                  //                      Will return error 
  794.                                  //                        if file exists and is Unicode
  795.                                  //                      Will return error if code page is not
  796.                                  //                        supported by the system
  797.    LPSTR    pszDSAName;          // Computer name of DSA from which to export
  798.                                  //    Default:  local DSA (if operating)
  799.                                  //              if no local DSA, first DSA found 
  800.                                  //              on network is used
  801.    LPSTR    pszBasePoint;        // DN of base-point in DIT for bulk operations
  802.                                  //    Default values:
  803.                                  //       if NULL, Messaging Site containing bound server
  804.                                  //       if empty string, enterprise containing bound server
  805.    LPSTR    pszContainer;        // RDN of container from which to export objects
  806.                                  //    NOTE:  This container is assumed to be
  807.                                  //          at the level below that indicated by
  808.                                  //          the pszBasePoint.  If NULL, 
  809.                                  //          the contents of all containers below
  810.                                  //          the BaseImportPoint will be exported.
  811.    CHAR     chColSep;            // Column Separator -- 
  812.                                  //    DEFAULT_DELIM is used if this value is zero
  813.    CHAR     chQuote;             // String enclosing character -- 
  814.                                  //    DEFAULT_QUOTE is used if this value is zero
  815.    CHAR     chMVSep;             // Multi-value Property Separator --
  816.                                  //    DEFAULT_MV_SEP is used if this value is zero
  817.    CHAR     cReserved;           // alignment
  818.  
  819.    CALLBACKPROGRESS  ProgressCallBacks;    // Progress call-back entry points
  820.    ERROR_CALLBACK    ErrorCallback;
  821.    EXPORT_CALLBACK   ExportCallback;   // Structure filled in by calling app to 
  822.                                        // receive callback on each exported item
  823.                                        // NOTE:  Callback functions are optional
  824.                                        // The default export function (write to file)
  825.                                        // will be called if these pointers are NULL
  826.    PDAPI_ENTRY       pAttributes; // DAPI_ENTRY filled with names of attributes to export
  827.                                         // Optional if pszExportFile specified
  828.                                         // Required if ExportCallback specified
  829.    LPSTR    pszHomeServer;       // Name of server for server-associated export
  830.    LPSTR  * rgpszClasses;        // array of pointers to zero-terminated object classes to export
  831.                                  // The last entry must be NULL
  832.                                  // NOTE:  The Directory will be queried for objects
  833.                                  //          of the classes in the specified order.
  834.    ULONG       ulUSNBase;        // Base USN to use for export restriction.  
  835.                                  //    If non-zero, only items having USN-Changed >= ulUSNBase will be exported
  836.    LPVOID      pReserved;        // Reserved -- Must be zero
  837.    
  838. } BEXPORT_PARMSA, *PBEXPORT_PARMSA, *LPBEXPORT_PARMSA;
  839.  
  840.  
  841. #ifdef UNICODE
  842. typedef  BEXPORT_PARMSW    BEXPORT_PARMS;
  843. typedef  PBEXPORT_PARMSW   PBEXPORT_PARMS;
  844. typedef  LPBEXPORT_PARMSW  LPBEXPORT_PARMS;
  845. #else
  846. typedef  BEXPORT_PARMSA    BEXPORT_PARMS;
  847. typedef  PBEXPORT_PARMSA   PBEXPORT_PARMS;
  848. typedef  LPBEXPORT_PARMSA  LPBEXPORT_PARMS;
  849. #endif
  850.  
  851.  
  852.  
  853. // Batch Export entry points
  854.  
  855. // The BatchExport function provides single-call BatchExport from the
  856. //    specified import file.  All import parameters are specified in the
  857. //    BEXPORT_PARMS structure pointed to by lpBexportParms.
  858. //    The return value indicates the number of errors logged in the
  859. //    NT Application log.  Please note that this does not indicate
  860. //    success or failure of the Batch Export.
  861. //    UI and Logging of errors and warnings into the Application log 
  862. //    are controlled through import parameters.
  863. extern DWORD   APIENTRY BatchExportW (LPBEXPORT_PARMSW lpBexportParms);
  864. extern DWORD   APIENTRY BatchExportA (LPBEXPORT_PARMSA lpBexportParms);
  865.  
  866. #ifdef UNICODE
  867. #define BatchExport     BatchExportW
  868. #else
  869. #define BatchExport     BatchExportA
  870. #endif
  871.  
  872.  
  873. /*******************************************************************************
  874. *  
  875. *  Single-Object Interface definitions             
  876. *               
  877. ********************************************************************************/
  878.  
  879. typedef struct _DAPI_PARMSW
  880. {
  881.    DWORD        dwDAPISignature;
  882.    DWORD        dwFlags;         // Bitmapped flags that control import action
  883.                                  //    See Import Control flags defined above.
  884.    LPWSTR       pszDSAName;      // Computer name of DSA to update
  885.                                  //    Default:  local DSA (if operating)
  886.                                  //              if no local DSA, first DSA found 
  887.                                  //              on network is used
  888.    LPWSTR       pszBasePoint;    // DN of base-point in DIT for bulk operations
  889.                                  //    Default values:
  890.                                  //       if NULL, Messaging Site containing bound server
  891.                                  //       if empty string, enterprise containing bound server
  892.    LPWSTR       pszContainer;    // RDN of default container under which
  893.                                  //    to perform bulk import operations
  894.                                  //    NOTE:  This container is assumed to be
  895.                                  //          at the level below that indicated by
  896.                                  //          the pszBasePoint.  If NULL, 
  897.                                  //          bulk operations will be performed at
  898.                                  //          the level below BaseImportPoint.
  899.                                  //          Container names specified in the 
  900.                                  //          import file will override this value.
  901.    LPWSTR       pszNTDomain;     // Name of NT Domain in which to lookup accounts
  902.                                  //   and to create NT accounts.
  903.                                  //   Current logon domain is used if NULL or empty string.
  904.    LPWSTR       pszCreateTemplate;// DN of the template object used for default values
  905.    PDAPI_ENTRY  pAttributes;    // DAPI_ENTRY filled with default attribute list
  906. } DAPI_PARMSW, *PDAPI_PARMSW, FAR *LPDAPI_PARMSW;
  907.  
  908. typedef struct _DAPI_PARMSA
  909. {
  910.    DWORD    dwDAPISignature;
  911.    DWORD    dwFlags;             // Bitmapped flags that control import action
  912.                                  //    See Import Control flags defined above.
  913.    LPSTR    pszDSAName;          // Computer name of DSA to update
  914.                                  //    Default:  local DSA (if operating)
  915.                                  //              if no local DSA, first DSA found 
  916.                                  //              on network is used
  917.    LPSTR    pszBasePoint;        // DN of base-point in DIT for bulk operations
  918.                                  //    Default values:
  919.                                  //       if NULL, Messaging Site containing bound server
  920.                                  //       if empty string, enterprise containing bound server
  921.    LPSTR    pszContainer;        // RDN of default container under which
  922.                                  //    to perform bulk import operations
  923.                                  //    NOTE:  This container is assumed to be
  924.                                  //          at the level below that indicated by
  925.                                  //          the pszBasePoint.  If NULL, 
  926.                                  //          bulk operations will be performed at
  927.                                  //          the level below BaseImportPoint.
  928.                                  //          Container names specified in the 
  929.                                  //          import file will override this value.
  930.    LPSTR    pszNTDomain;         // Name of NT Domain in which to lookup accounts
  931.                                  //   and to create NT accounts.
  932.                                  //   Current logon domain is used if NULL or empty string.
  933.    LPSTR    pszCreateTemplate;   // DN of the template object used for default values
  934.    PDAPI_ENTRY   pAttributes;    // DAPI_ENTRY filled with default attribute list
  935. } DAPI_PARMSA, *PDAPI_PARMSA, FAR *LPDAPI_PARMSA;
  936.  
  937.  
  938. #ifdef UNICODE
  939. typedef  DAPI_PARMSW    DAPI_PARMS;
  940. typedef  PDAPI_PARMSW   PDAPI_PARMS;
  941. typedef  LPDAPI_PARMSW  LPDAPI_PARMS;
  942. #else
  943. typedef  DAPI_PARMSA    DAPI_PARMS;
  944. typedef  PDAPI_PARMSA   PDAPI_PARMS;
  945. typedef  LPDAPI_PARMSA  LPDAPI_PARMS;
  946. #endif
  947.  
  948.  
  949. typedef  LPVOID   DAPI_HANDLE;
  950. typedef  LPVOID * PDAPI_HANDLE;
  951. typedef  LPVOID FAR * LPDAPI_HANDLE;
  952.  
  953. #define  DAPI_INVALID_HANDLE  ((DAPI_HANDLE) -1)
  954.  
  955.  
  956.  
  957. // DAPIStart initializes a DAPI session.
  958. //    for use by DAPIRead and DAPIWrite.  The return value is 0 if no errors
  959. //    are encountered.  A pointer to a DAPI_EVENT structure is returned if an 
  960. //    error is encountered.  
  961. //    NOTE:  The DAPI_HANDLE must be returned via a call to DAPIEnd.
  962. //           If a non-NULL value is returned, its memory must be freed by
  963. //           a call to DAPIFreeMemory
  964. extern PDAPI_EVENTW APIENTRY DAPIStartW  (LPDAPI_HANDLE    lphDAPISession,
  965.                                           LPDAPI_PARMSW     lpDAPIParms);
  966. extern PDAPI_EVENTA APIENTRY DAPIStartA  (LPDAPI_HANDLE    lphDAPISession,
  967.                                           LPDAPI_PARMSA     lpDAPIParms);
  968.  
  969. #ifdef UNICODE
  970. #define DAPIStart    DAPIStartW
  971. #else
  972. #define DAPIStart    DAPIStartA
  973. #endif
  974.  
  975. // DAPIEnd invalidates the DAPI_HANDLE obtained by the call to DAPIStart.
  976. //    NOTE:  There are no separate Unicode / Ansi entry points defined 
  977. extern   void  APIENTRY DAPIEnd (LPDAPI_HANDLE lphDAPISession);
  978.  
  979.  
  980. // DAPIRead() Reads indicated attributes from the named Directory Object
  981. // Parameters:  
  982. // Returned value:   NULL indicates no difficulties encountered.
  983. //                   Else, pointer to structure containing description of 
  984. //                      error(s) or warning(s) encountered.
  985. //                      Must be freed by call to DAPIFreeMemory.
  986. //    hDAPISession   DAPI Session handle obtained via InitDAPISession
  987. //    dwFlags        control operation
  988. //    pszObjectName  String containing name of object to read.
  989. //                      If specified as RDN, combined w/ session's
  990. //                      pszBasePoint and pszParentContainer.
  991. //                      If specified w/ prefix of "/cn=", the string 
  992. //                      is concatenated to the session pszBasePoint.
  993. //                      If specified w/ prefix of "/o=", the string
  994. //                      is taken to be a fully-qualified DN.
  995. //    pAttList       Pointer to DAPI_ENTRY structure containing names of
  996. //                      attributes to read.  The session default list is
  997. //                      overridden for the present call only.
  998. //    ppValues       Address of variable receiving pointer to DAPI_ENTRY
  999. //                      structure containing the values read from the DIT entry.
  1000. //                      The pointer returned must be freed by call to 
  1001. //                      DAPIFreeMemory.
  1002. //    ppAttributes   Address of variable receiving pointer to DAPI_ENTRY
  1003. //                      structure containing the names of attributes read
  1004. //                      from the DIT IFF DAPI_ALL_ATTRIBUTES or DAPI_LEGAL_ATTRIBUTES
  1005. //                      were set in dwFlags.
  1006. //                      The pointer returned must be freed by call to 
  1007. //                      DAPIFreeMemory.
  1008. extern PDAPI_EVENTW APIENTRY DAPIReadW   (DAPI_HANDLE        hDAPISession,
  1009.                                              DWORD          dwFlags,
  1010.                                              LPWSTR         pszObjectName,
  1011.                                              PDAPI_ENTRY    pAttList,
  1012.                                              PDAPI_ENTRY *  ppValues,
  1013.                                              PDAPI_ENTRY *  ppAttributes);
  1014. extern PDAPI_EVENTA APIENTRY DAPIReadA   (DAPI_HANDLE        hDAPISession,
  1015.                                              DWORD          dwFlags,
  1016.                                              LPSTR          pszObjectName,
  1017.                                              PDAPI_ENTRY    pAttList,
  1018.                                              PDAPI_ENTRY *  ppValues,
  1019.                                              PDAPI_ENTRY *  ppAttributes);
  1020.  
  1021. #ifdef UNICODE
  1022. #define DAPIRead     DAPIReadW
  1023. #else
  1024. #define DAPIRead     DAPIReadA
  1025. #endif
  1026.  
  1027.  
  1028. // DAPIWrite() 
  1029. //   Perform the indicated write operation on the named object
  1030. // Returned value:   NULL indicates no difficulties encountered.
  1031. //                   Else, pointer to structure containing description of 
  1032. //                      error(s) or warning(s) encountered.
  1033. //                      Must be freed by call to DAPIFreeMemory.
  1034. // Parameters:  
  1035. //    hDAPISession   DAPI Session handle obtained via InitDAPISession
  1036. //    dwFlags        Operational control
  1037. //    pAttributes   Pointer to DAPI_ENTRY structure containing names of
  1038. //                      attributes to write.  The session default list is
  1039. //                      used if this parameter is NULL
  1040. //    pValues        Pointer to DAPI_ENTRY structure containing the values 
  1041. //                      to set on the DIT entry.
  1042. //    lpulUSN         Optional:  Address of variable receiving USN of updated
  1043. //                      DIT entry.  May be specified as NULL to suppress this
  1044. //                      return value.
  1045. //    lppszCreatedAccount  Address receiving pointer to name of created NT account
  1046. //    lppszPassword  Address receiving pointer to password generated if
  1047. //                      NT Account is created. 
  1048. extern PDAPI_EVENTW APIENTRY DAPIWriteW (DAPI_HANDLE        hDAPISession,
  1049.                                              DWORD          dwFlags,
  1050.                                              PDAPI_ENTRY    pAttributes,
  1051.                                              PDAPI_ENTRY    pValues,
  1052.                                              PULONG         lpulUSN,
  1053.                                              LPWSTR *       lppszCreatedAccount,
  1054.                                              LPWSTR *       lppszPassword);
  1055. extern PDAPI_EVENTA APIENTRY DAPIWriteA (DAPI_HANDLE        hDAPISession,
  1056.                                              DWORD          dwFlags,
  1057.                                              PDAPI_ENTRY    pAttributes,
  1058.                                              PDAPI_ENTRY    pValues,
  1059.                                              PULONG         lpulUSN,
  1060.                                              LPSTR *        lppszCreatedAccount,
  1061.                                              LPSTR *        lppszPassword);
  1062. #ifdef UNICODE
  1063. #define DAPIWrite      DAPIWriteW
  1064. #else
  1065. #define DAPIWrite      DAPIWriteA
  1066. #endif
  1067.  
  1068.  
  1069. /*******************************************************************************
  1070. *  procedure :  DAPIAllocBuffer
  1071. *               
  1072. *    purpose :  Allocate buffer, logically linking it to the pvAllocBase
  1073. *               The first buffer in logically linked set of allocations must be 
  1074. *               freed by call to DAPIFreeMemory
  1075. *               
  1076. * parameters :  cbSize        dword containing size of allocation request (in bytes)
  1077. *               pvAllocBase    base for logical linking of allocated block
  1078. *                             May be NULL
  1079. *                             If non-NULL, must be a block previously allocated
  1080. *                             by DAPIAllocBuffer or returned by DAPI function
  1081. *               
  1082. *    returns :  ptr to allocated block
  1083. *               
  1084. *    history :  
  1085. *               
  1086. ********************************************************************************/
  1087. extern LPVOID APIENTRY DAPIAllocBuffer (DWORD    cbSize, LPVOID    pvAllocBase);
  1088.  
  1089.  
  1090. /*******************************************************************************
  1091. *  procedure :  DAPIFreeMemory
  1092. *               
  1093. *    purpose :  Release memory allocated for structures returned by DAPI calls.
  1094. *               
  1095. * parameters :  lpVoid  pointer to block to free
  1096. *               
  1097. *    returns :  nothing
  1098. *               
  1099. *    history :  
  1100. *               
  1101. ********************************************************************************/
  1102. extern void APIENTRY DAPIFreeMemory (LPVOID   lpVoid);
  1103.  
  1104.  
  1105. /* 
  1106.  * NetUserList interface definitions
  1107.  */
  1108. // When getting callbacks from NTExport / NWExport, these indices
  1109. // can be used to interpret the value array returned in the callback
  1110. // >>>>    NOTE:  These indices are NOT valid for Bexport callback!    <<<<
  1111. #define  NET_CLASS         0
  1112. #define  NET_COMMON_NAME   1
  1113. #define  NET_DISPLAY_NAME  2
  1114. #define  NET_HOME_SERVER   3
  1115. #define  NET_COMMENT       4     /* NTExport only */
  1116.  
  1117. #define  NTEXP_ENTRY_COUNT 5 /* number of parts in NT User export */
  1118. #define  NWEXP_ENTRY_COUNT 4 /* number of parts in NetWare user export */
  1119.  
  1120.  
  1121.  
  1122. /*******************************************************************************
  1123. *  
  1124. * NTIMPORT Interface definitions
  1125. *               
  1126. ********************************************************************************/
  1127.  
  1128. typedef struct _NTEXPORT_PARMSW
  1129. {
  1130.    DWORD             dwDAPISignature;
  1131.    DWORD             dwFlags;          // Bitmapped flags that control the user export
  1132.    HWND              hwndParent;       // Windows handle to use when displaying message boxes
  1133.    LPWSTR            pszExportFile;    // Name of file to create
  1134.                                        //   Ignored if using callbacks
  1135.    CALLBACKPROGRESS  ProgressCallBacks;// Progress call-back entry points
  1136.    ERROR_CALLBACK    ErrorCallback;
  1137.    EXPORT_CALLBACK   ExportCallback;   // Structure filled in by calling app to 
  1138.                                        // receive callback on each exported item
  1139.                                        // NOTE:  Callback functions are optional
  1140.                                        // The default export function (write to file)
  1141.                                        // will be called if these pointers are NULL
  1142.    LPWSTR            pszDCName;        // Name of Domain Controller from which to get users
  1143.                                        // NOTE:  Specification of Domain Controller overrides
  1144.                                        //        the NTDomain
  1145.    LPWSTR            pszNTDomain;      // Name of Domain from which to read users
  1146.                                        // If neither pszNTDomain and pszDCName are specified,
  1147.                                        //   users are extracted from the current login domain
  1148. } NTEXPORT_PARMSW, *PNTEXPORT_PARMSW, FAR *LPNTEXPORT_PARMSW;
  1149.  
  1150. typedef struct _NTEXPORT_PARMSA
  1151. {
  1152.    DWORD             dwDAPISignature;
  1153.    DWORD             dwFlags;          // Bitmapped flags that control the user export
  1154.    HWND              hwndParent;       // Windows handle to use when displaying message boxes
  1155.    LPSTR             pszExportFile;    // Name of file to create
  1156.                                        //   Ignored if using callbacks
  1157.    CALLBACKPROGRESS  ProgressCallBacks;// Progress call-back entry points
  1158.    ERROR_CALLBACK    ErrorCallback;
  1159.    EXPORT_CALLBACK   ExportCallback;   // Structure filled in by calling app to 
  1160.                                        // receive callback on each exported item
  1161.                                        // NOTE:  Callback functions are optional
  1162.                                        // The default export function (write to file)
  1163.                                        // will be called if these pointers are NULL
  1164.    LPSTR             pszDCName;        // NOTE:  Specification of Domain Controller overrides
  1165.                                        //        the NTDomain
  1166.                                        // Name of Domain from which to read users
  1167.    LPSTR             pszNTDomain;      // If neither pszNTDomain and pszDCName are specified,
  1168.                                        //   users are extracted from the current login domain
  1169.                                        
  1170. } NTEXPORT_PARMSA, *PNTEXPORT_PARMSA, FAR *LPNTEXPORT_PARMSA;
  1171.  
  1172. #ifdef UNICODE
  1173. typedef  NTEXPORT_PARMSW      NTEXPORT_PARMS;
  1174. typedef  PNTEXPORT_PARMSW     PNTEXPORT_PARMS;
  1175. typedef  LPNTEXPORT_PARMSW    LPNTEXPORT_PARMS;
  1176. #else
  1177. typedef  NTEXPORT_PARMSA      NTEXPORT_PARMS;
  1178. typedef  PNTEXPORT_PARMSA     PNTEXPORT_PARMS;
  1179. typedef  LPNTEXPORT_PARMSA    LPNTEXPORT_PARMS;
  1180. #endif
  1181.  
  1182. extern   DWORD APIENTRY    NTExportW (LPNTEXPORT_PARMSW pNTExportParms);
  1183. extern   DWORD APIENTRY    NTExportA (LPNTEXPORT_PARMSA pNTExportParms);
  1184.  
  1185. #ifdef UNICODE
  1186. #define NTExport              NTExportW
  1187. #else
  1188. #define NTExport              NTExportA
  1189. #endif
  1190.  
  1191.  
  1192. /*******************************************************************************
  1193. *  
  1194. * NWIMPORT Interface definitions
  1195. *               
  1196. ********************************************************************************/
  1197.  
  1198. typedef struct _NWEXPORT_PARMSW
  1199. {
  1200.    DWORD             dwDAPISignature;
  1201.    DWORD             dwFlags;          // Bitmapped flags that control the user export
  1202.    HWND              hwndParent;       // Windows handle to use when displaying message boxes
  1203.    LPWSTR            pszExportFile;    // Name of file to create
  1204.                                        //   Ignored if using callbacks
  1205.    CALLBACKPROGRESS  ProgressCallBacks;// Progress call-back entry points
  1206.    ERROR_CALLBACK    ErrorCallback;
  1207.    EXPORT_CALLBACK   ExportCallback;   // Structure filled in by calling app to 
  1208.                                        // receive callback on each exported item
  1209.                                        // NOTE:  Callback functions are optional
  1210.                                        // The default export function (write to file)
  1211.                                        // will be called if these pointers are NULL
  1212.    LPWSTR            pszFileServer;    // Name of the file server to connect to
  1213.    LPWSTR            pszUserName;      // User Name -- Must have administrator priviliges
  1214.    LPWSTR            pszPassword;      // Password to connect to the server
  1215. } NWEXPORT_PARMSW, *PNWEXPORT_PARMSW, *LPNWEXPORT_PARMSW;
  1216.  
  1217. typedef struct _NWEXPORT_PARMSA
  1218. {
  1219.    DWORD             dwDAPISignature;
  1220.    DWORD             dwFlags;          // Bitmapped flags that control the user export
  1221.    HWND              hwndParent;       // Windows handle to use when displaying message boxes
  1222.    LPSTR             pszExportFile;    // Name of file to create
  1223.                                        //   Ignored if using callbacks
  1224.    CALLBACKPROGRESS  ProgressCallBacks;// Progress call-back entry points
  1225.    ERROR_CALLBACK    ErrorCallback;
  1226.    EXPORT_CALLBACK   ExportCallback;   // Structure filled in by calling app to 
  1227.                                        // receive callback on each exported item
  1228.                                        // NOTE:  Callback functions are optional
  1229.                                        // The default export function (write to file)
  1230.                                        // will be called if these pointers are NULL
  1231.    LPSTR             pszFileServer;    // Name of the file server to connect to
  1232.    LPSTR             pszUserName;      // User Name -- Must have administrator priviliges
  1233.    LPSTR             pszPassword;      // Password to connect to the server
  1234. } NWEXPORT_PARMSA, *PNWEXPORT_PARMSA, *LPNWEXPORT_PARMSA;
  1235.  
  1236. #ifdef UNICODE
  1237. typedef  NWEXPORT_PARMSW      NWEXPORT_PARMS;
  1238. typedef  PNWEXPORT_PARMSW     PNWEXPORT_PARMS;
  1239. typedef  LPNWEXPORT_PARMSW    LPNWEXPORT_PARMS;
  1240. #else
  1241. typedef  NWEXPORT_PARMSA      NWEXPORT_PARMS;
  1242. typedef  PNWEXPORT_PARMSA     PNWEXPORT_PARMS;
  1243. typedef  LPNWEXPORT_PARMSA    LPNWEXPORT_PARMS;
  1244. #endif
  1245.  
  1246. extern   DWORD APIENTRY    NWExportW (LPNWEXPORT_PARMSW pNWExportParms);
  1247. extern   DWORD APIENTRY    NWExportA (LPNWEXPORT_PARMSA pNWExportParms);
  1248.  
  1249. #ifdef UNICODE
  1250. #define NWExport              NWExportW
  1251. #else
  1252. #define NWExport              NWExportA
  1253. #endif
  1254.  
  1255.  
  1256. // Definitions for the DAPIGetSiteInfo call
  1257.  
  1258. typedef struct _NAME_INFOA
  1259. {
  1260.    LPSTR    pszName;                            // Simple object name
  1261.    LPSTR    pszDNString;                        // DN of object
  1262.    LPSTR    pszDisplayName;                     // Display name of object
  1263. } NAME_INFOA, *PNAME_INFOA;
  1264.  
  1265. typedef struct _NAME_INFOW
  1266. {
  1267.    LPWSTR   pszName;                            // Simple object name
  1268.    LPWSTR   pszDNString;                        // DN of object
  1269.    LPWSTR   pszDisplayName;                     // Display name of object
  1270. } NAME_INFOW, *PNAME_INFOW;
  1271.  
  1272. typedef struct _PSITE_INFOA
  1273. {
  1274.    LPSTR       pszCountry;                      // Country code
  1275.    NAME_INFOA  objServer;                       // Name information for server
  1276.    NAME_INFOA  objSite;                         // Name information for site containing server
  1277.    NAME_INFOA  objEnterprise;                   // Name information for enterprise containing server
  1278. } SITE_INFOA, *PSITE_INFOA;
  1279.  
  1280. typedef struct _PSITE_INFOW
  1281. {
  1282.    LPWSTR      pszCountry;                      // Country code
  1283.    NAME_INFOW  objServer;                       // Name information for server
  1284.    NAME_INFOW  objSite;                         // Name information for site containing server
  1285.    NAME_INFOW  objEnterprise;                   // Name information for enterprise containing server
  1286. } SITE_INFOW, *PSITE_INFOW;
  1287.  
  1288. #ifdef UNICODE
  1289. typedef  NAME_INFOW        NAME_INFO;
  1290. typedef  PNAME_INFOW       PNAME_INFO;
  1291. typedef  SITE_INFOW        SITE_INFO;
  1292. typedef  PSITE_INFOW       PSITE_INFO;
  1293. #else
  1294. typedef  NAME_INFOA        NAME_INFO;
  1295. typedef  PNAME_INFOA       PNAME_INFO;
  1296. typedef  SITE_INFOA        SITE_INFO;
  1297. typedef  PSITE_INFOA       PSITE_INFO;
  1298. #endif
  1299.  
  1300. extern PDAPI_EVENTA APIENTRY DAPIGetSiteInfoA (
  1301.                               DWORD    dwFlags,                // Flags for request
  1302.                               LPSTR    pszDSA,                 // name of DSA from which to get information
  1303.                               PSITE_INFOA *   ppSiteInfo       // Address receiving pointer to pSiteInfo structure
  1304.                                                                // containing return data
  1305. );
  1306.  
  1307. extern PDAPI_EVENTW APIENTRY DAPIGetSiteInfoW (
  1308.                               DWORD    dwFlags,                // Flags for request
  1309.                               LPWSTR   pszDSA,                 // name of DSA from which to get information
  1310.                               PSITE_INFOW *   ppSiteInfo       // Address receiving pointer to pSiteInfo structure
  1311.                                                                // containing return dataname of DSA from which to read schema
  1312. );
  1313.  
  1314. #ifdef UNICODE
  1315. #define  DAPIGetSiteInfo DAPIGetSiteInfoW
  1316. #else
  1317. #define  DAPIGetSiteInfo DAPIGetSiteInfoA
  1318. #endif
  1319.  
  1320.  
  1321.  
  1322. #ifdef __cplusplus
  1323. }
  1324. #endif
  1325.  
  1326. #endif   // _DAPI_INCLUDED
  1327.