home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dbsamp.exe / DBSNAPIN / DBSNAPIN.C < prev    next >
C/C++ Source or Header  |  1995-03-13  |  63KB  |  2,147 lines

  1. /****************************************************************************
  2. **    File:    DBSNAPIN.C
  3. **
  4. **    Desc:    This snapin provides the dialogs and procedures needed to create
  5. **                and modify the following classes of objects--
  6. **
  7. **            DBServer - a class that is used for a Database Server
  8. **                to authenticate to the tree.
  9. **            Database - a class that is used as an object to represent
  10. **                a database in a Database Server.
  11. **
  12. **        DISCLAIMER
  13. **
  14. **    Novell, Inc. makes no representations or warranties with respect to
  15. **    any NetWare software, and specifically disclaims any express or
  16. **    implied warranties of merchantability, title, or fitness for a
  17. **    particular purpose.
  18. **
  19. **    Distribution of any NetWare software is forbidden without the
  20. **    express written consent of Novell, Inc.  Further, Novell reserves
  21. **    the right to discontinue distribution of any NetWare software.
  22. **
  23. **    Novell is not responsible for lost profits or revenue, loss of use
  24. **    of the software, loss of data, costs of re-creating lost data, the
  25. **    cost of any substitute equipment or program, or claims by any party
  26. **    other than you.  Novell strongly recommends a backup be made before
  27. **    any software is installed.   Technical support for this software
  28. **    may be provided at the discretion of Novell.
  29. **
  30. **    Programmers:
  31. **
  32. **        Ini    Who                                Firm
  33. **        --- ----------------- ------------------------------------------------
  34. **        CRG    Calvin Gaisford        Novell Developer Support.
  35. **
  36. **    History:
  37. **
  38. **        When         Who     What
  39. **        -------- ---     ---------------------------------------------------------
  40. **        1-04-95  CRG     Modification of this code for distibution. Much of this
  41. **                  code was taken from the snapin example that comes from
  42. **                                    the Novell SDK.  In fact, I just copied and pasted a lot
  43. **                                    of the code that is the same for all snapin modules.
  44. */
  45.  
  46.  
  47.  
  48. /***************************************************************************
  49. **  Libraries Linked in for .exe
  50. **
  51. **  NWCALLS.LIB
  52. **  NWLOCALE.LIB
  53. **  NWNET.LIB
  54. **    SNAPIN.LIB
  55. **
  56. */
  57.  
  58. /****************************************************************************
  59. **    Include headers
  60. */
  61.     /*-----------------------------------------------------------------------
  62.     **    WINDOWS
  63.     */
  64.     #include <windows.h>
  65.     #include <toolhelp.h>
  66.     #include <string.h>
  67.     #include <stdio.h>
  68.  
  69.     /*-----------------------------------------------------------------------
  70.     **    NetWare
  71.     */
  72.     #include <nwnet.h>
  73.     #include <nwsnapin.h>
  74.  
  75.     /*-----------------------------------------------------------------------
  76.     **    Program
  77.     */
  78.     #include "dbsnapin.h"
  79.  
  80.  
  81. /***************************************************************************
  82. **    Function Prototypes
  83. */
  84.  
  85. #ifdef __cplusplus
  86. extern "C"
  87. {
  88. #endif
  89.  
  90. N_EXTERN_LIBRARY( NWRCODE )
  91. SnapinDBServerProc(pnstr8 name, nuint16 msg, nparam p1, nparam p2);
  92.  
  93. N_EXTERN_LIBRARY( NWRCODE )
  94. SnapinDBProc(pnstr8 name, nuint16 msg, nparam p1, nparam p2);
  95.  
  96. N_EXTERN_LIBRARY( nuint32 )
  97. FADMINFlatBrowserLaunchProc( nuint32 userParam, nuint16 uMsg,
  98.                                                  nparam param1, nparam param2 );
  99. N_EXTERN_LIBRARY( nuint32 )
  100. FOPERFlatBrowserLaunchProc( nuint32 userParam, nuint16 uMsg,
  101.                                                  nparam param1, nparam param2 );
  102. N_EXTERN_LIBRARY( nuint32 )
  103. FNWFlatBrowserLaunchProc( nuint32 userParam, nuint16 uMsg,
  104.                                                  nparam param1, nparam param2 );
  105. N_EXTERN_LIBRARY( nuint32 )
  106. DSFlatBrowserLaunchProc( nuint32 userParam, nuint16 uMsg,
  107.                                                  nparam param1, nparam param2 );
  108. N_EXTERN_LIBRARY( nuint32 )
  109. DBSFlatBrowserLaunchProc( nuint32 userParam, nuint16 uMsg,
  110.                                                  nparam param1, nparam param2 );
  111.  
  112. BOOL _export FAR PASCAL AddDBSObjectDialogProc(HWND hwnd, UINT message,
  113.                                                                                         WPARAM wParam, LPARAM lParam);
  114. BOOL _export FAR PASCAL AddDBObjectDialogProc(HWND hwnd, UINT message,
  115.                                                                                         WPARAM wParam, LPARAM lParam);
  116. BOOL _export FAR PASCAL DBServerIdentificationDlg(HWND hwnd, UINT message,
  117.                                                                                          WPARAM wParam, LPARAM lParam);
  118. BOOL _export FAR PASCAL DatabaseIdentificationDlg(HWND hwnd, UINT message,
  119.                                                                                          WPARAM wParam, LPARAM lParam);
  120. BOOL _export FAR PASCAL DBServerDatabaseDlg(HWND hwnd, UINT message,
  121.                                                                                 WPARAM wParam, LPARAM lParam);
  122. BOOL _export FAR PASCAL DatabaseUserDlg(HWND hwnd, UINT message,
  123.                                                                                 WPARAM wParam, LPARAM lParam);
  124. BOOL AddDBServerObject(char *strName);
  125. BOOL AddDatabaseObject(char *strName, char *DBSName);
  126. int ReadDBSObjectData(void);
  127. int ReadDBObjectData(void);
  128. int ModifyObjectData(char *name);
  129. int ModifyDBObjectData(char *name);
  130.  
  131.  
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135.  
  136. /***************************************************************************
  137. **  Type Definitions And MACROS
  138. */
  139. typedef struct tagDBServerObjData
  140. {
  141.     HWND hDialogDatabase;
  142.     char name[256];
  143.     char bhnwsnameDefined;
  144.     char hnwsname[MAX_DN_CHARS];
  145.     char hnwsnameChange[MAX_DN_CHARS];
  146.     int  bDescrDefined;
  147.     char descr[1024];
  148.     char descrChange[1024];
  149.     int  bDatabaseDefined;
  150.     int  nDatabaseCount;
  151.     int  nDeltaCount;
  152.     char databaseList[MAX_DBUSER][256];
  153.     char databaseDeltas[MAX_DBUSER][256];
  154. } TDBServerObject;
  155.  
  156. typedef struct tagDatabaseObjData
  157. {
  158.     HWND hDialogUser;
  159.     char name[256];
  160.     char hdbname[MAX_DN_CHARS];
  161.     char admingroup[MAX_DN_CHARS];
  162.     char admingroupChange[MAX_DN_CHARS];
  163.     char opergroup[MAX_DN_CHARS];
  164.     char opergroupChange[MAX_DN_CHARS];
  165.     int  bOperDefined;
  166.     int  bAdminDefined;
  167.     int  bUserDefined;
  168.     int  nUserCount;
  169.     int  nDeltaCount;
  170.     char userList[MAX_DBUSER][256];
  171.     char userDeltas[MAX_DBUSER][256];
  172. } TDatabaseObject;
  173.  
  174.  
  175.  
  176. #define NUM_DBSERVER_PAGES   2
  177. #define NUM_DATABASE_PAGES     2
  178.  
  179. /***************************************************************************
  180. **  Globals Used in code
  181. */
  182. NWAPageStruct dbServerPages[NUM_DBSERVER_PAGES];
  183. NWAPageStruct databasePages[NUM_DATABASE_PAGES];
  184. static int createAnotherFlag=0;
  185. static int showDetailsFlag=0;
  186. static char nameBuf[256];
  187. static char DBSnameBuf[256];
  188. static TDBServerObject dbServerObjData;
  189. static TDatabaseObject databaseObjData;
  190. static bChangeDBSId = 0;
  191. static bChangeDBSHost = 0;
  192. static bChangeDBSDatabase = 0;
  193. static bChangeDBAdmin = 0;
  194. static bChangeDBOper = 0;
  195. static bChangeDBUser = 0;
  196. HINSTANCE hDLL;
  197. HINSTANCE hCtrlDLL;
  198.  
  199. /*-------------------------------------------------------------------------*/
  200. /*    DLL Entry Point                                                      */
  201. /*-------------------------------------------------------------------------*/
  202. int FAR PASCAL LibMain (HINSTANCE hInstance, WORD wDataSeg,
  203.                                                 WORD cbHeapSize, LPSTR lpCmdLine)
  204. {
  205.      hDLL = hInstance;
  206.      if(cbHeapSize != 0)
  207.             UnlockData (0);
  208.      return 1;
  209. };
  210.  
  211. /*-------------------------------------------------------------------------*/
  212. /* Function : InitSnapin(void)                                             */
  213. /* Description :                                                           */
  214. /*    Every Snapin DLL must provide this function. In this function,       */
  215. /*    snapin menu items (under Tools) are registered. Also, object procs   */
  216. /*    are registered.                                                      */
  217. /*                                                                         */
  218. /*-------------------------------------------------------------------------*/
  219. int _export FAR PASCAL InitSnapin()
  220. {
  221.  
  222.      /*----------------------------------------------------------*/
  223.      /* Registering DBServer Object Class Proc                   */
  224.      /*----------------------------------------------------------*/
  225.      NWARegisterObjectProc(NWA_DS_OBJECT_TYPE,
  226.                                                  "DBServer",
  227.                                                  "Novell, Inc. (C) All rights reserved.",
  228.                                                     hDLL,
  229.                                                     (NWASnapinObjectProc) SnapinDBServerProc,
  230.                                                     NWA_SNAPIN_VERSION);
  231.  
  232.      NWARegisterObjectProc(NWA_DS_OBJECT_TYPE,
  233.                                                     "Database",
  234.                                                     "Novell, Inc. (C) All rights reserved.",
  235.                                                     hDLL,
  236.                                                     (NWASnapinObjectProc) SnapinDBProc,
  237.                                                     NWA_SNAPIN_VERSION);
  238.  
  239.      return NWA_RET_SUCCESS;
  240. }
  241.  
  242.  
  243. /*-------------------------------------------------------------------------*/
  244. /* Function : SnapinDBServerProc(void)                                     */
  245. /* Description :                                                           */
  246. /*   DBServer Snapin Callback Proc                                         */
  247. /*-------------------------------------------------------------------------*/
  248. N_GLOBAL_LIBRARY( NWRCODE ) _export
  249. SnapinDBServerProc(pnstr8 name, nuint16 msg, nparam p1, nparam p2)
  250. {
  251.      static HBITMAP hBitmap;
  252.      static HBITMAP hAlias;
  253.     static HBITMAP hReadOnly;
  254.     switch(msg)
  255.     {
  256.         case NWA_MSG_INITSNAPIN:
  257.               {
  258.                  /*-------------------------------------------------*/
  259.                          /*           initialize pages                      */
  260.                  /*-------------------------------------------------*/
  261.                  dbServerPages[0].dlgProc = DBServerIdentificationDlg;
  262.                  dbServerPages[0].resName = "DBSERVER_IDENTIFICATION";
  263.                  dbServerPages[0].pageTitle = "Identification";
  264.  
  265.                  dbServerPages[1].dlgProc = DBServerDatabaseDlg;
  266.                  dbServerPages[1].resName = "DBSERVER_DATABASE";
  267.                  dbServerPages[1].pageTitle = "Databases";
  268.  
  269.                  /*-------------------------------------------------*/
  270.                  /*            Register bitmaps here                */
  271.                  /*-------------------------------------------------*/
  272.                  hBitmap   = LoadBitmap(hDLL, "DBServer");
  273.                  hAlias    = LoadBitmap(hDLL, "DBServerAlias");
  274.                  hReadOnly = LoadBitmap(hDLL, "DBServerRO");
  275.  
  276.                  NWAAddClassData ("DBServer", "Database Server", hBitmap, hAlias,
  277.                                                      hReadOnly );
  278.  
  279.                  return NWA_RET_SUCCESS;
  280.              }
  281.  
  282.             case NWA_MSG_CREATEOBJECT:
  283.                      {
  284.                          int      rcode;
  285.                          int      retValue;
  286.  
  287.                          retValue = DialogBox( hDLL,  "DIALOG_DBSERVER_ADD",
  288.                                                                  NULL, AddDBSObjectDialogProc );
  289.                          if ( retValue )
  290.                          {
  291.                              lstrcat(nameBuf, ".");
  292.                              lstrcat(nameBuf, name);
  293.                              rcode = AddDBServerObject(nameBuf);
  294.                              if ( rcode )
  295.                              {
  296.                                     //successfully added
  297.                                     lstrcpy((char*)p1, nameBuf);
  298.                                     if ( createAnotherFlag )
  299.                                          return NWA_RET_CREATEANOTHER;
  300.                                     else if ( showDetailsFlag )
  301.                                     {
  302.                                          showDetailsFlag=0;
  303.                                          return NWA_RET_SHOWDETAILS;
  304.                                     }
  305.                              }
  306.                              else
  307.                                  return NWA_ERR_ERROR;
  308.                          }
  309.                          return NWA_RET_SUCCESS;
  310.  
  311.                      }
  312.  
  313.             case NWA_MSG_GETVALIDOPERATIONS :
  314.                      {
  315.                          return ( NWA_OP_DETAILS | NWA_OP_RENAME | NWA_OP_DELETE |
  316.                                             NWA_OP_DSTYPE | NWA_OP_CREATE );
  317.                      }
  318.  
  319.             case NWA_MSG_GETPAGECOUNT:
  320.                      {
  321.                          /*-----------------------------*/
  322.                          /* Initialize DBServer Data    */
  323.                          /*-----------------------------*/
  324.                          lstrcpy(dbServerObjData.name, name);
  325.                          dbServerObjData.descr[0]='\0';
  326.                          dbServerObjData.nDatabaseCount=0;
  327.                          dbServerObjData.nDeltaCount=0;
  328.                          dbServerObjData.hnwsname[0]='\0';
  329.                          ReadDBSObjectData();
  330.                          return NUM_DBSERVER_PAGES;
  331.                      }
  332.  
  333.             case NWA_MSG_REGISTERPAGE:
  334.                      {
  335.                          NWAPageStruct  *pageInfo =   (NWAPageStruct *)p2;
  336.                          pageInfo->dlgProc    = dbServerPages[p1].dlgProc;
  337.                          pageInfo->resName    = dbServerPages[p1].resName;
  338.                          pageInfo->pageTitle  = dbServerPages[p1].pageTitle;
  339.                          pageInfo->hDLL = hDLL;
  340.                          pageInfo->initParam = 0;
  341.                          return NWA_RET_SUCCESS;
  342.                      }
  343.  
  344.             case NWA_MSG_MODIFY:
  345.                      {
  346.                          ModifyObjectData(name);
  347.                          return NWA_RET_SUCCESS;
  348.                      }
  349.  
  350.             case NWA_MSG_RENAME:
  351.                      {
  352.                          return NWA_RET_DODEFAULT;
  353.                      }
  354.  
  355.             case NWA_MSG_QUERYDELETE:
  356.                      {
  357.                          return TRUE;
  358.                      }
  359.  
  360.             case NWA_MSG_CLOSESNAPIN:
  361.                      {
  362.                          /*-------------------------------------------------*/
  363.                          /*      unregister bitmaps and delete them         */
  364.                          /*-------------------------------------------------*/
  365.  
  366.                          NWARemoveClassData ("DBServer", &hBitmap, &hAlias, &hReadOnly);
  367.                          if(hBitmap)
  368.                              DeleteObject(hBitmap);
  369.                          if(hAlias)
  370.                              DeleteObject(hAlias);
  371.                          return NWA_RET_SUCCESS;
  372.                      }
  373.  
  374.             default:
  375.                      break;
  376.      }
  377.      return NWA_RET_SUCCESS;
  378. }
  379.  
  380.  
  381. /*-------------------------------------------------------------------------*/
  382. /* Function : SnapinDBProc(void)                                     */
  383. /* Description :                                                           */
  384. /*   Database Snapin Callback Proc                                         */
  385. /*-------------------------------------------------------------------------*/
  386. N_GLOBAL_LIBRARY( NWRCODE ) _export
  387. SnapinDBProc(pnstr8 name, nuint16 msg, nparam p1, nparam p2)
  388. {
  389.      static HBITMAP hBitmap;
  390.      static HBITMAP hAlias;
  391.      static HBITMAP hReadOnly;
  392.      switch(msg)
  393.      {
  394.             case NWA_MSG_INITSNAPIN:
  395.                      {
  396.                          /*-------------------------------------------------*/
  397.                          /*           initialize pages                      */
  398.                          /*-------------------------------------------------*/
  399.                          databasePages[0].dlgProc = DatabaseIdentificationDlg;
  400.                          databasePages[0].resName = "DATABASE_IDENTIFICATION";
  401.                          databasePages[0].pageTitle = "Identification";
  402.  
  403.                          databasePages[1].dlgProc = DatabaseUserDlg;
  404.                          databasePages[1].resName = "DATABASE_USER";
  405.                          databasePages[1].pageTitle = "Users";
  406.  
  407.                          /*-------------------------------------------------*/
  408.                          /*            Register bitmaps here                */
  409.                          /*-------------------------------------------------*/
  410.                          hBitmap   = LoadBitmap(hDLL, "Database");
  411.                          hAlias    = LoadBitmap(hDLL, "DatabaseAlias");
  412.                          hReadOnly = LoadBitmap(hDLL, "DatabaseRO");
  413.  
  414.                          NWAAddClassData ("Database", "Database", hBitmap, hAlias,
  415.                                                              hReadOnly );
  416.  
  417.                          return NWA_RET_SUCCESS;
  418.                      }
  419.  
  420.             case NWA_MSG_CREATEOBJECT:
  421.                      {
  422.                          int      rcode;
  423.                          int      retValue;
  424.  
  425.                          retValue = DialogBox( hDLL,  "DIALOG_DATABASE_ADD",
  426.                                                                  NULL, AddDBObjectDialogProc );
  427.                          if ( retValue )
  428.                          {
  429.                              lstrcat(nameBuf, ".");
  430.                              lstrcat(nameBuf, name);
  431.                              rcode = AddDatabaseObject(nameBuf, DBSnameBuf);
  432.                              if ( rcode )
  433.                              {
  434.                                     //successfully added
  435.                                     lstrcpy((char*)p1, nameBuf);
  436.                                     if ( createAnotherFlag )
  437.                                          return NWA_RET_CREATEANOTHER;
  438.                              }
  439.                              else
  440.                                  return NWA_ERR_ERROR;
  441.                          }
  442.                          return NWA_RET_SUCCESS;
  443.  
  444.                      }
  445.  
  446.             case NWA_MSG_GETVALIDOPERATIONS :
  447.                      {
  448.                          return ( NWA_OP_DETAILS | NWA_OP_RENAME | NWA_OP_DELETE |
  449.                                             NWA_OP_DSTYPE | NWA_OP_CREATE );
  450.                      }
  451.  
  452.             case NWA_MSG_GETPAGECOUNT:
  453.                      {
  454.                          /*-----------------------------*/
  455.                          /* Initialize DBServer Data    */
  456.                          /*-----------------------------*/
  457.                          lstrcpy(databaseObjData.name, name);
  458.                          databaseObjData.nUserCount=0;
  459.                          databaseObjData.nDeltaCount=0;
  460.                          databaseObjData.hdbname[0]='\0';
  461.                          databaseObjData.admingroup[0]='\0';
  462.                          databaseObjData.opergroup[0]='\0';
  463.                          ReadDBObjectData();
  464.                          return NUM_DATABASE_PAGES;
  465.                      }
  466.  
  467.             case NWA_MSG_REGISTERPAGE:
  468.                      {
  469.                          NWAPageStruct  *pageInfo =   (NWAPageStruct *)p2;
  470.                          pageInfo->dlgProc    = databasePages[p1].dlgProc;
  471.                          pageInfo->resName    = databasePages[p1].resName;
  472.                          pageInfo->pageTitle  = databasePages[p1].pageTitle;
  473.                          pageInfo->hDLL = hDLL;
  474.                          pageInfo->initParam = 0;
  475.                          return NWA_RET_SUCCESS;
  476.                      }
  477.  
  478.             case NWA_MSG_MODIFY:
  479.                      {
  480.                          ModifyDBObjectData(name);
  481.                          return NWA_RET_SUCCESS;
  482.                      }
  483.  
  484.             case NWA_MSG_RENAME:
  485.                      {
  486.                          return NWA_RET_DODEFAULT;
  487.                      }
  488.  
  489.             case NWA_MSG_QUERYDELETE:
  490.                      {
  491.                          return TRUE;
  492.                      }
  493.  
  494.             case NWA_MSG_CLOSESNAPIN:
  495.                      {
  496.                          /*-------------------------------------------------*/
  497.                          /*      unregister bitmaps and delete them         */
  498.                          /*-------------------------------------------------*/
  499.  
  500.                          NWARemoveClassData ("Database", &hBitmap, &hAlias, &hReadOnly);
  501.                          if(hBitmap)
  502.                              DeleteObject(hBitmap);
  503.                          if(hAlias)
  504.                              DeleteObject(hAlias);
  505.                          return NWA_RET_SUCCESS;
  506.                      }
  507.  
  508.             default:
  509.                      break;
  510.      }
  511.      return NWA_RET_SUCCESS;
  512. }
  513.  
  514.  
  515. /*-------------------------------------------------------------------------*/
  516. /* Function : AddDBServerObject(void)                                      */
  517. /* Description :                                                           */
  518. /*   Adds DBServer Object in DS                                            */
  519. /*-------------------------------------------------------------------------*/
  520. BOOL AddDBServerObject(char *objName)
  521. {
  522.      UINT                dsErr=0;
  523.      Buf_T              *ObjectInfo;
  524.      NWDSContextHandle   context;
  525.      uint32              flags;
  526.  
  527.      context = NWDSCreateContext ();
  528.      dsErr = NWDSSetContext(context, DCK_NAME_CONTEXT, DS_ROOT_NAME);
  529.      dsErr = NWDSGetContext(context, DCK_FLAGS, (void *)&flags);
  530.  
  531.      flags |= DCV_TYPELESS_NAMES;
  532.      flags |= DCV_XLATE_STRINGS;
  533.      flags |= DCV_DEREF_ALIASES;
  534.      flags |= DCV_DEREF_BASE_CLASS;
  535.  
  536.      dsErr   = NWDSSetContext (context, DCK_FLAGS, (void *)&flags );
  537.  
  538.      dsErr = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &ObjectInfo);
  539.      dsErr = NWDSInitBuf(context, DSV_ADD_ENTRY, ObjectInfo);
  540.      if(ObjectInfo)
  541.      {
  542.             dsErr = NWDSPutAttrName(context, ObjectInfo, "Object Class");
  543.             dsErr = NWDSPutAttrVal(context, ObjectInfo, SYN_CLASS_NAME, "DBServer");
  544.             dsErr = NWDSAddObject(context, objName, NULL, 0, ObjectInfo);
  545.             dsErr = NWDSGenerateObjectKeyPair(context, objName, "",0L);
  546.             NWDSFreeBuf(ObjectInfo);
  547.      }
  548.      NWDSFreeContext(context);
  549.      if(dsErr)
  550.             return FALSE;
  551.      else
  552.             return TRUE;
  553. }
  554.  
  555. /*-------------------------------------------------------------------------*/
  556. /* Function : AddDatabaseObject(void)                                      */
  557. /* Description :                                                           */
  558. /*   Adds Database Object in DS.  Note that there is some modification     */
  559. /*   of the Database Server as well.  Also, an ACL entry is added for the  */
  560. /*   Database Server on the Database.  This is for functionality of the    */
  561. /*   Database sample program.                                                                                             */
  562. /*-------------------------------------------------------------------------*/
  563. BOOL AddDatabaseObject(char *objName, char *DBSName)
  564. {
  565.      UINT                dsErr=0;
  566.      Buf_T              *ObjectInfo;
  567.      Buf_T                            *DBSBuff;
  568.      NWDSContextHandle   context;
  569.      uint32              flags;
  570.      Object_ACL_T                 tmpACL;
  571.      char                                *protAttrName="[All Attributes Rights]";
  572.  
  573.      context = NWDSCreateContext ();
  574.      dsErr = NWDSSetContext(context, DCK_NAME_CONTEXT, DS_ROOT_NAME);
  575.      dsErr = NWDSGetContext(context, DCK_FLAGS, (void *)&flags);
  576.  
  577.      flags |= DCV_TYPELESS_NAMES;
  578.      flags |= DCV_XLATE_STRINGS;
  579.      flags |= DCV_DEREF_ALIASES;
  580.      flags |= DCV_DEREF_BASE_CLASS;
  581.  
  582.      dsErr   = NWDSSetContext (context, DCK_FLAGS, (void *)&flags );
  583.  
  584.      tmpACL.privileges = DS_ATTR_READ;
  585.      tmpACL.protectedAttrName = protAttrName;
  586.      tmpACL.subjectName = DBSName;
  587.  
  588.      dsErr = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &ObjectInfo);
  589.      dsErr = NWDSInitBuf(context, DSV_ADD_ENTRY, ObjectInfo);
  590.      if(ObjectInfo)
  591.      {
  592.             dsErr = NWDSPutAttrName(context, ObjectInfo, "Object Class");
  593.             dsErr = NWDSPutAttrVal(context, ObjectInfo, SYN_CLASS_NAME, "Database");
  594.             dsErr = NWDSPutAttrName(context, ObjectInfo, "Host Server");
  595.             dsErr = NWDSPutAttrVal(context, ObjectInfo, SYN_DIST_NAME, DBSName);
  596.             dsErr = NWDSPutAttrName(context, ObjectInfo, "ACL");
  597.             dsErr = NWDSPutAttrVal(context, ObjectInfo, SYN_OBJECT_ACL, &tmpACL);
  598.             dsErr = NWDSAddObject(context, objName, NULL, 0, ObjectInfo);
  599.             if(!dsErr)
  600.             {
  601.                 dsErr = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &DBSBuff);
  602.                 dsErr = NWDSInitBuf(context, DSV_ADD_ENTRY, DBSBuff);
  603.                 if(DBSBuff)
  604.                 {
  605.                     dsErr = NWDSPutChange(context, DBSBuff, DS_ADD_VALUE, "User");
  606.                     dsErr = NWDSPutAttrVal(context, DBSBuff, SYN_DIST_NAME, objName);
  607.                     dsErr = NWDSModifyObject(context, DBSName, NULL, 0, DBSBuff);
  608.                     if(dsErr)
  609.                     {
  610.                         dsErr = NWDSRemoveObject(context, objName);
  611.                     }
  612.                     NWDSFreeBuf(DBSBuff);
  613.                 }
  614.                 NWDSFreeBuf(ObjectInfo);
  615.             }
  616.      }
  617.      NWDSFreeContext(context);
  618.      if(dsErr)
  619.             return FALSE;
  620.      else
  621.             return TRUE;
  622. }
  623.  
  624.  
  625. /*-------------------------------------------------------------------------*/
  626. /* Function : ModifyObjectData(void)                                       */
  627. /* Description :                                                           */
  628. /*  Modifys a DBServer Object Atribute Values                              */
  629. /*-------------------------------------------------------------------------*/
  630. int ModifyObjectData(char *name)
  631. {
  632.     NWDSContextHandle context;
  633.     int               err=0;
  634.     Buf_T             *inpBuf;
  635.     uint32            flags;
  636.  
  637.     context = NWDSCreateContext();
  638.     if ( (int)context == ERR_CONTEXT_CREATION )
  639.         return ((int) context);
  640.     err=NWDSSetContext(context, DCK_NAME_CONTEXT, DS_ROOT_NAME);
  641.     if ( err < 0 )
  642.     {
  643.         NWDSFreeContext(context);
  644.         return err;
  645.     }
  646.     err = NWDSGetContext(context, DCK_FLAGS, (void *)&flags);
  647.     flags |= DCV_TYPELESS_NAMES;
  648.     flags |= DCV_XLATE_STRINGS;
  649.     flags |= DCV_DEREF_ALIASES;
  650.     flags |= DCV_DEREF_BASE_CLASS;
  651.     err   = NWDSSetContext (context, DCK_FLAGS, (void *)&flags );
  652.     err=NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &inpBuf);
  653.     if ( err < 0 )
  654.     {
  655.         NWDSFreeContext(context);
  656.         return err;
  657.     }
  658.     err=NWDSInitBuf(context, DSV_MODIFY_ENTRY, inpBuf);
  659.     if ( err < 0 )
  660.     {
  661.         NWDSFreeContext(context);
  662.         NWDSFreeBuf(inpBuf);
  663.         return err;
  664.     }
  665.     /*---------------------------------------------------------------*/
  666.     /* Modify Identification Page                                    */
  667.     /*---------------------------------------------------------------*/
  668.     if ( bChangeDBSId )
  669.     {
  670.         if ( dbServerObjData.bDescrDefined )
  671.         {
  672.             err = NWDSPutChange(context, inpBuf, DS_REMOVE_VALUE, "Description");
  673.             if ( err < 0 )
  674.             {
  675.                 NWDSFreeContext(context);
  676.                 NWDSFreeBuf(inpBuf);
  677.                 return err;
  678.             }
  679.             err = NWDSPutAttrVal(context, inpBuf, SYN_CI_STRING, dbServerObjData.descr);
  680.             if ( err < 0 )
  681.             {
  682.                 NWDSFreeContext(context);
  683.                 NWDSFreeBuf(inpBuf);
  684.                 return err;
  685.             }
  686.         }
  687.         if(strlen(dbServerObjData.descrChange) > 0)
  688.         {
  689.             err = NWDSPutChange(context, inpBuf, DS_ADD_VALUE, "Description");
  690.             if ( err < 0 )
  691.             {
  692.                 NWDSFreeContext(context);
  693.                 NWDSFreeBuf(inpBuf);
  694.                 return err;
  695.             }
  696.             err = NWDSPutAttrVal(context, inpBuf, SYN_CI_STRING, dbServerObjData.descrChange);
  697.             if ( err < 0 )
  698.             {
  699.                 NWDSFreeContext(context);
  700.                 NWDSFreeBuf(inpBuf);
  701.                 return err;
  702.             }
  703.         }
  704.     }
  705.     if( bChangeDBSHost )
  706.     {
  707.         if ( dbServerObjData.bhnwsnameDefined )
  708.         {
  709.             err = NWDSPutChange(context, inpBuf, DS_REMOVE_VALUE, "Host Server");
  710.             if ( err < 0 )
  711.             {
  712.                 NWDSFreeContext(context);
  713.                 NWDSFreeBuf(inpBuf);
  714.                 return err;
  715.             }
  716.             err = NWDSPutAttrVal(context, inpBuf, SYN_DIST_NAME, dbServerObjData.hnwsname);
  717.             if ( err < 0 )
  718.             {
  719.                 NWDSFreeContext(context);
  720.                 NWDSFreeBuf(inpBuf);
  721.                 return err;
  722.             }
  723.         }
  724.         if(strlen(dbServerObjData.hnwsnameChange) > 0)
  725.         {
  726.             err = NWDSPutChange(context, inpBuf, DS_ADD_VALUE, "Host Server");
  727.             if ( err < 0 )
  728.             {
  729.                 NWDSFreeContext(context);
  730.                 NWDSFreeBuf(inpBuf);
  731.                 return err;
  732.             }
  733.             err = NWDSPutAttrVal(context, inpBuf, SYN_DIST_NAME, dbServerObjData.hnwsnameChange);
  734.             if ( err < 0 )
  735.             {
  736.                 NWDSFreeContext(context);
  737.                 NWDSFreeBuf(inpBuf);
  738.                 return err;
  739.             }
  740.         }
  741.     }
  742.  
  743.     err= NWDSModifyObject(context, name, NULL, 0, inpBuf);
  744.     if( err < 0 )
  745.         MessageBox(NULL, "Error Making Modification", "DBSnapin Error", MB_OK);
  746.  
  747.     NWDSFreeContext(context);
  748.     NWDSFreeBuf(inpBuf);
  749.     return err;
  750. }
  751.  
  752.  
  753. /*-------------------------------------------------------------------------*/
  754. /* Function : ModifyDBObjectData(void)                                       */
  755. /* Description :                                                           */
  756. /*  Modifys a Database Object Atribute Values                              */
  757. /*-------------------------------------------------------------------------*/
  758. int ModifyDBObjectData(char *name)
  759. {
  760.     NWDSContextHandle context;
  761.     int               err=0,j;
  762.     Buf_T             *inpBuf;
  763.     uint32            flags;
  764.     uint32            syntaxID;
  765.  
  766.     context = NWDSCreateContext();
  767.     if ( (int) context == ERR_CONTEXT_CREATION )
  768.         return ((int) context);
  769.  
  770.     err=NWDSSetContext(context, DCK_NAME_CONTEXT, DS_ROOT_NAME);
  771.     if ( err < 0 )
  772.     {
  773.         NWDSFreeContext(context);
  774.         return err;
  775.     }
  776.  
  777.     err = NWDSGetContext(context, DCK_FLAGS, (void *)&flags);
  778.  
  779.     flags |= DCV_TYPELESS_NAMES;
  780.     flags |= DCV_XLATE_STRINGS;
  781.     flags |= DCV_DEREF_ALIASES;
  782.     flags |= DCV_DEREF_BASE_CLASS;
  783.  
  784.     err   = NWDSSetContext (context, DCK_FLAGS, (void *)&flags );
  785.  
  786.     err=NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &inpBuf);
  787.     if ( err < 0 )
  788.     {
  789.         NWDSFreeContext(context);
  790.         return err;
  791.     }
  792.  
  793.     err=NWDSInitBuf(context, DSV_MODIFY_ENTRY, inpBuf);
  794.     if ( err < 0 )
  795.     {
  796.         NWDSFreeContext(context);
  797.         NWDSFreeBuf(inpBuf);
  798.         return err;
  799.     }
  800.  
  801.     /*---------------------------------*/
  802.     /* Get syntaxID of User           */
  803.     /*---------------------------------*/
  804.     err = NWDSGetSyntaxID(context, "User", &syntaxID);
  805.     if ( err < 0 )
  806.     {
  807.         NWDSFreeContext(context);
  808.         NWDSFreeBuf(inpBuf);
  809.         return err;
  810.     }
  811.  
  812.     /*-------------------------------------------------------------------*/
  813.     /* Modify User Attribute values                                     */
  814.     /*-------------------------------------------------------------------*/
  815.     if ( bChangeDBUser )
  816.     {
  817.         if ( databaseObjData.nUserCount )
  818.         {
  819.             // there were some Users for the object
  820.             // remove them first
  821.             err = NWDSPutChange(context, inpBuf, DS_REMOVE_VALUE, "User");
  822.             if ( err < 0 )
  823.             {
  824.                 NWDSFreeContext(context);
  825.                 NWDSFreeBuf(inpBuf);
  826.                 return err;
  827.             }
  828.  
  829.             for(j=0; j<databaseObjData.nUserCount; j++)
  830.             {
  831.                 err = NWDSPutAttrVal(context, inpBuf, syntaxID,
  832.                                                          databaseObjData.userList[j]);
  833.                 if ( err < 0 )
  834.                 {
  835.                     NWDSFreeContext(context);
  836.                     NWDSFreeBuf(inpBuf);
  837.                     return err;
  838.                 }
  839.             }
  840.  
  841.             // Add new list of users selected
  842.             // if any
  843.  
  844.             if ( databaseObjData.nDeltaCount )
  845.             {
  846.                 err = NWDSPutChange(context, inpBuf, DS_ADD_VALUE, "User");
  847.                 if ( err < 0 )
  848.                 {
  849.                     NWDSFreeContext(context);
  850.                     NWDSFreeBuf(inpBuf);
  851.                     return err;
  852.                 }
  853.  
  854.                 for(j=0; j<databaseObjData.nDeltaCount; j++)
  855.                 {
  856.                     err = NWDSPutAttrVal(context, inpBuf, syntaxID,
  857.                                                          databaseObjData.userDeltas[j]);
  858.                     if ( err < 0 )
  859.                     {
  860.                         NWDSFreeContext(context);
  861.                         NWDSFreeBuf(inpBuf);
  862.                         return err;
  863.                     }
  864.                 }
  865.             }
  866.         }
  867.         else
  868.         {
  869.             // There were no users for the object to start with.
  870.             // Add new list of users selected ( if any )
  871.  
  872.             if ( databaseObjData.nDeltaCount )
  873.             {
  874.                 err = NWDSPutChange(context, inpBuf, DS_ADD_VALUE, "User");
  875.                 if ( err < 0 )
  876.                 {
  877.                     NWDSFreeContext(context);
  878.                     NWDSFreeBuf(inpBuf);
  879.                     return err;
  880.                 }
  881.  
  882.                 for(j=0; j<databaseObjData.nDeltaCount; j++)
  883.                 {
  884.                     err = NWDSPutAttrVal(context, inpBuf, syntaxID,
  885.                                                          databaseObjData.userDeltas[j]);
  886.                     if ( err < 0 )
  887.                     {
  888.                         NWDSFreeContext(context);
  889.                         NWDSFreeBuf(inpBuf);
  890.                         return err;
  891.                     }
  892.                 }
  893.             }
  894.         }
  895.     }
  896.     /*---------------------------------------------------------------*/
  897.     /* Modify DBAdmin Attribute                                  */
  898.     /*---------------------------------------------------------------*/
  899.     if ( bChangeDBAdmin )
  900.     {
  901.         if ( databaseObjData.bAdminDefined )
  902.         {
  903.             err = NWDSPutChange(context, inpBuf, DS_REMOVE_VALUE, "DBAdmin");
  904.             if ( err < 0 )
  905.             {
  906.                 NWDSFreeContext(context);
  907.                 NWDSFreeBuf(inpBuf);
  908.                 return err;
  909.             }
  910.             err = NWDSPutAttrVal(context, inpBuf, SYN_CI_STRING, databaseObjData.admingroup);
  911.             if ( err < 0 )
  912.             {
  913.                 NWDSFreeContext(context);
  914.                 NWDSFreeBuf(inpBuf);
  915.                 return err;
  916.             }
  917.         }
  918.         if(strlen(databaseObjData.admingroupChange) > 0)
  919.         {
  920.             err = NWDSPutChange(context, inpBuf, DS_ADD_VALUE, "DBAdmin");
  921.             if ( err < 0 )
  922.             {
  923.                 NWDSFreeContext(context);
  924.                 NWDSFreeBuf(inpBuf);
  925.                 return err;
  926.             }
  927.             err = NWDSPutAttrVal(context, inpBuf, SYN_CI_STRING, databaseObjData.admingroupChange);
  928.             if ( err < 0 )
  929.             {
  930.                 NWDSFreeContext(context);
  931.                 NWDSFreeBuf(inpBuf);
  932.                 return err;
  933.             }
  934.         }
  935.     }
  936.     if ( bChangeDBOper )
  937.     {
  938.         if ( databaseObjData.bOperDefined )
  939.         {
  940.             err = NWDSPutChange(context, inpBuf, DS_REMOVE_VALUE, "DBOperator");
  941.             if ( err < 0 )
  942.             {
  943.                 NWDSFreeContext(context);
  944.                 NWDSFreeBuf(inpBuf);
  945.                 return err;
  946.             }
  947.             err = NWDSPutAttrVal(context, inpBuf, SYN_CI_STRING, databaseObjData.opergroup);
  948.             if ( err < 0 )
  949.             {
  950.                 NWDSFreeContext(context);
  951.                 NWDSFreeBuf(inpBuf);
  952.                 return err;
  953.             }
  954.         }
  955.         if(strlen(databaseObjData.opergroupChange) > 0)
  956.         {
  957.             err = NWDSPutChange(context, inpBuf, DS_ADD_VALUE, "DBOperator");
  958.             if ( err < 0 )
  959.             {
  960.                 NWDSFreeContext(context);
  961.                 NWDSFreeBuf(inpBuf);
  962.                 return err;
  963.             }
  964.             err = NWDSPutAttrVal(context, inpBuf, SYN_CI_STRING, databaseObjData.opergroupChange);
  965.             if ( err < 0 )
  966.             {
  967.                 NWDSFreeContext(context);
  968.                 NWDSFreeBuf(inpBuf);
  969.                 return err;
  970.             }
  971.         }
  972.     }
  973.     err= NWDSModifyObject(context, name, NULL, 0, inpBuf);
  974.     if( err < 0 )
  975.         MessageBox(NULL, "Error Making Modification", "DBSnapin Error", MB_OK);
  976.  
  977.     NWDSFreeContext(context);
  978.     NWDSFreeBuf(inpBuf);
  979.     return err;
  980. }
  981.  
  982.  
  983. /*-------------------------------------------------------------------------*/
  984. /* Function : AddDBSObjectDialogProc(void)                                    */
  985. /* Description :                                                           */
  986. /*    Create Database Server Object Dialog Proc                            */
  987. /*-------------------------------------------------------------------------*/
  988. BOOL _export FAR PASCAL AddDBSObjectDialogProc(HWND hwnd, UINT message,
  989.                                                                                 WPARAM wParam, LPARAM lParam)
  990. {
  991.      int state;
  992.      switch(message)
  993.      {
  994.             case WM_INITDIALOG:
  995.                 {
  996.                     nameBuf[0]='\0';
  997.                     SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER, BM_SETCHECK,
  998.                                                          createAnotherFlag, 0L);
  999.                     SendDlgItemMessage(hwnd, IDC_ADD_DETAILS, BM_SETCHECK,
  1000.                                                          showDetailsFlag, 0L);
  1001.                     return TRUE;
  1002.                 }
  1003.  
  1004.             case WM_COMMAND:
  1005.                 {
  1006.                     switch( wParam )
  1007.                     {
  1008.                         case IDC_CREATE :
  1009.                             GetDlgItemText(hwnd, IDC_DBSERVER_NAME, nameBuf, 255);
  1010.                             createAnotherFlag=(int)SendDlgItemMessage(hwnd,
  1011.                                                                                                                 IDC_ADD_ANOTHER,
  1012.                                                                                                                 BM_GETCHECK, 0, 0L);
  1013.                             showDetailsFlag=(int)SendDlgItemMessage(hwnd, IDC_ADD_DETAILS,
  1014.                                                                                                             BM_GETCHECK, 0, 0L);
  1015.                             EndDialog(hwnd, TRUE);
  1016.                             return TRUE;
  1017.  
  1018.                         case IDC_CANCEL :
  1019.                             createAnotherFlag=0;
  1020.                             showDetailsFlag=0;
  1021.                             EndDialog(hwnd, FALSE);
  1022.                             return TRUE;
  1023.  
  1024.                         case IDC_ADD_DETAILS :
  1025.                             state =(int)  SendDlgItemMessage(hwnd, IDC_ADD_DETAILS,
  1026.                                                                                  BM_GETCHECK, 0, 0L);
  1027.                             SendDlgItemMessage(hwnd, IDC_ADD_DETAILS, BM_SETCHECK,
  1028.                                                                  !state, 0L);
  1029.                             if ( !state )
  1030.                                 SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER, BM_SETCHECK,
  1031.                                                                      state, 0L);
  1032.                             EnableWindow( GetDlgItem(hwnd, IDC_ADD_ANOTHER), state);
  1033.                             break;
  1034.  
  1035.                         case IDC_ADD_ANOTHER :
  1036.                             state = ( int ) SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER,
  1037.                                                                                  BM_GETCHECK, 0, 0L);
  1038.                             SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER, BM_SETCHECK,
  1039.                                                                  !state, 0L);
  1040.                             EnableWindow( GetDlgItem(hwnd, IDC_ADD_DETAILS), state);
  1041.                             break;
  1042.                     }
  1043.                 }
  1044.  
  1045.                 return TRUE;
  1046.  
  1047.      }
  1048.      return FALSE ;
  1049. }
  1050.  
  1051.  
  1052. /*-------------------------------------------------------------------------*/
  1053. /* Function : AddDBObjectDialogProc(void)                                    */
  1054. /* Description :                                                           */
  1055. /*    Create Database Object Dialog Proc                                     */
  1056. /*-------------------------------------------------------------------------*/
  1057. BOOL _export FAR PASCAL AddDBObjectDialogProc(HWND hwnd, UINT message,
  1058.                                                                                 WPARAM wParam, LPARAM lParam)
  1059. {
  1060.     NWDSContextHandle context;
  1061.     int               err=0;
  1062.     char contextStr[256];
  1063.      int state;
  1064.      switch(message)
  1065.      {
  1066.             case WM_INITDIALOG:
  1067.                 {
  1068.                     nameBuf[0]='\0';
  1069.                     SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER, BM_SETCHECK,
  1070.                                                          createAnotherFlag, 0L);
  1071.                     return TRUE;
  1072.                 }
  1073.  
  1074.             case WM_COMMAND:
  1075.                 {
  1076.                     switch( wParam )
  1077.                     {
  1078.                         case IDC_CREATE :
  1079.                             GetDlgItemText(hwnd, IDC_DATABASE_NAME, nameBuf, 255);
  1080.                             GetDlgItemText(hwnd, IDC_DBS_NAME, DBSnameBuf, 255);
  1081.                             createAnotherFlag=(int)SendDlgItemMessage(hwnd,
  1082.                                                                                                                 IDC_ADD_ANOTHER,
  1083.                                                                                                                 BM_GETCHECK, 0, 0L);
  1084.                             EndDialog(hwnd, TRUE);
  1085.                             return TRUE;
  1086.  
  1087.                         case IDC_CANCEL :
  1088.                             createAnotherFlag=0;
  1089.                             EndDialog(hwnd, FALSE);
  1090.                             return TRUE;
  1091.  
  1092.                         case IDC_ADD_ANOTHER :
  1093.                             state = ( int ) SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER,
  1094.                                                                                  BM_GETCHECK, 0, 0L);
  1095.                             SendDlgItemMessage(hwnd, IDC_ADD_ANOTHER, BM_SETCHECK,
  1096.                                                                  !state, 0L);
  1097.                             EnableWindow( GetDlgItem(hwnd, IDC_ADD_DETAILS), state);
  1098.                             break;
  1099.  
  1100.                         case IDC_FIND_DBS :
  1101.                                 context = NWDSCreateContext();
  1102.                                 if ( (int) context == ERR_CONTEXT_CREATION )
  1103.                                     break;
  1104.  
  1105.                                 err = NWDSGetContext(context, DCK_NAME_CONTEXT, contextStr);
  1106.                                 if ( err < 0 )
  1107.                                 {
  1108.                                     NWDSFreeContext(context);
  1109.                                     break;
  1110.                                 }
  1111.                                 databaseObjData.hDialogUser = hwnd;
  1112.                                 NWALaunchDSFlatBrowser(hwnd,
  1113.                                                                             (long) &databaseObjData,
  1114.                                                                             contextStr,
  1115.                                                                             NULL,
  1116.                                                                             NULL,
  1117.                                                                             "Selected Database Server",
  1118.                                                                             NWA_FB_SINGLE_SELECT,
  1119.                                                                             DBSFlatBrowserLaunchProc);
  1120.                             NWDSFreeContext(context);
  1121.                             break;
  1122.                     }
  1123.                 }
  1124.  
  1125.                 return TRUE;
  1126.  
  1127.      }
  1128.      return FALSE ;
  1129. }
  1130.  
  1131.  
  1132. /*-------------------------------------------------------------------------*/
  1133. /* Function : DBServerIdentificationDlg                                    */
  1134. /* Description :                                                           */
  1135. /*  Database Server Identification Page Dialog Proc                        */
  1136. /*-------------------------------------------------------------------------*/
  1137. BOOL _export FAR PASCAL DBServerIdentificationDlg(HWND hwnd, UINT message,
  1138.                                                                                 WPARAM wParam, LPARAM lParam)
  1139. {
  1140.     NWDSContextHandle context;
  1141.     int               err=0;
  1142.     char contextStr[256];
  1143.  
  1144.      switch(message)
  1145.      {
  1146.             case WM_INITDIALOG:
  1147.                 {
  1148.                     dbServerObjData.hDialogDatabase = hwnd;
  1149.                     SetDlgItemText(hwnd, IDC_NAME, dbServerObjData.name);
  1150.                     SetDlgItemText(hwnd, IDC_DESCR, dbServerObjData.descr);
  1151.                     SetDlgItemText(hwnd, HOST_NETWARE_NAME, dbServerObjData.hnwsname);
  1152.                     SendDlgItemMessage (hwnd, IDC_DESCR, EM_LIMITTEXT, 1024, 0L);
  1153.                     bChangeDBSId = 0;
  1154.                     bChangeDBSHost = 0;
  1155.                     return TRUE;
  1156.                 }
  1157.  
  1158.             case NWA_WM_F1HELP:
  1159.                 {
  1160.                     MessageBox(NULL, "Description:\n\tA text field to hold a\n\tdescription of the Server.\nHost NetWare Server:\n\tHolds the distinguished\n\tname (DN)of the NetWare\n\tServer the Database is\n\tloaded on.", "Database Server Help", MB_OK);
  1161.                     return TRUE;
  1162.                 }
  1163.  
  1164.             case WM_COMMAND:
  1165.             switch (wParam)
  1166.             {
  1167.                      case IDC_DESCR:
  1168.                                 if(HIWORD(lParam) == EN_CHANGE)
  1169.                                 {
  1170.                                     bChangeDBSId = 1;
  1171.                                     //GetDlgItemText(hwnd, IDC_DESCR, dbServerObjData.descr, 1024);
  1172.                                     SendMessage(hwnd, NWA_WM_SETPAGEMODIFY, (WORD)hwnd, MAKELONG(0,TRUE));
  1173.                                 }
  1174.                                 break;
  1175.  
  1176.                      case HOST_NETWARE_NAME:
  1177.                                 if(HIWORD(lParam) == EN_CHANGE)
  1178.                                 {
  1179.                                     bChangeDBSHost = 1;
  1180.                                     //GetDlgItemText(hwnd, HOST_NETWARE_NAME, dbServerObjData.hnwsname, MAX_DN_CHARS);
  1181.                                     SendMessage(hwnd, NWA_WM_SETPAGEMODIFY, (WORD)hwnd, MAKELONG(0,TRUE));
  1182.                                 }
  1183.                                 break;
  1184.  
  1185.                      case IDC_FIND_NETWARE:
  1186.                             context = NWDSCreateContext();
  1187.                             if ( (int) context == ERR_CONTEXT_CREATION )
  1188.                                 break;
  1189.                             err = NWDSGetContext(context, DCK_NAME_CONTEXT, contextStr);
  1190.                             if ( err < 0 )
  1191.                             {
  1192.                                 NWDSFreeContext(context);
  1193.                                 break;
  1194.                             }
  1195.                             NWALaunchDSFlatBrowser(hwnd,
  1196.                                          (long) &dbServerObjData,
  1197.                                          contextStr,
  1198.                                          NULL,
  1199.                                          NULL,
  1200.                                          "Selected Object",
  1201.                                          NWA_FB_SINGLE_SELECT,
  1202.                                          FNWFlatBrowserLaunchProc);
  1203.                             break;
  1204.             }
  1205.             break;
  1206.  
  1207.             case NWA_WM_CANCLOSE:
  1208.             {
  1209.                 // xfer data to program memory
  1210.                 GetDlgItemText(hwnd, IDC_DESCR, dbServerObjData.descrChange, 1024);
  1211.                 GetDlgItemText(hwnd, HOST_NETWARE_NAME, dbServerObjData.hnwsnameChange, MAX_DN_CHARS);
  1212.                 return TRUE;
  1213.             }
  1214.      }
  1215.      return FALSE ;
  1216. }
  1217.  
  1218.  
  1219.  
  1220. /*-------------------------------------------------------------------------*/
  1221. /* Function : DatabaseIdentificationDlg                                    */
  1222. /* Description :                                                           */
  1223. /*  Database Identification Page Dialog Proc                               */
  1224. /*-------------------------------------------------------------------------*/
  1225. BOOL _export FAR PASCAL DatabaseIdentificationDlg(HWND hwnd, UINT message,
  1226.                                                                                          WPARAM wParam, LPARAM lParam)
  1227. {
  1228.     NWDSContextHandle context;
  1229.     int               err=0;
  1230.     char contextStr[MAX_DN_CHARS];
  1231.  
  1232.      switch(message)
  1233.      {
  1234.             case WM_INITDIALOG:
  1235.                 {
  1236.                     databaseObjData.hDialogUser = hwnd;
  1237.                     SetDlgItemText(hwnd, IDC_DBNAME, databaseObjData.name);
  1238.                     SetDlgItemText(hwnd, IDC_HOST_DBSERVER, databaseObjData.hdbname);
  1239.                     SetDlgItemText(hwnd, IDC_ADMIN_NAME, databaseObjData.admingroup);
  1240.                     SetDlgItemText(hwnd, IDC_OPER_NAME, databaseObjData.opergroup);
  1241.                     bChangeDBAdmin = 0;
  1242.                     bChangeDBOper = 0;
  1243.                     return TRUE;
  1244.                 }
  1245.  
  1246.             case NWA_WM_F1HELP:
  1247.                 {
  1248.                     MessageBox(NULL, "Sample Identification Page help", "Database Help", MB_OK);
  1249.                     return TRUE;
  1250.                 }
  1251.  
  1252.             case WM_COMMAND:
  1253.             switch (wParam)
  1254.             {
  1255.                 case IDC_ADMIN_NAME:
  1256.                     if(HIWORD(lParam) == EN_CHANGE)
  1257.                     {
  1258.                          bChangeDBAdmin = 1;
  1259.                          SendMessage(hwnd, NWA_WM_SETPAGEMODIFY, (WORD)hwnd, MAKELONG(0,TRUE));
  1260.                     }
  1261.                     break;
  1262.                 case IDC_FIND_ADMIN:
  1263.                     context = NWDSCreateContext();
  1264.                     if ( (int) context == ERR_CONTEXT_CREATION )
  1265.                         break;
  1266.                     err = NWDSGetContext(context, DCK_NAME_CONTEXT, contextStr);
  1267.                     if ( err < 0 )
  1268.                     {
  1269.                         NWDSFreeContext(context);
  1270.                         break;
  1271.                     }
  1272.                     NWALaunchDSFlatBrowser(hwnd,
  1273.                                  (long) &databaseObjData,
  1274.                                  contextStr,
  1275.                                  NULL,
  1276.                                  NULL,
  1277.                                  "Selected Object",
  1278.                                  NWA_FB_SINGLE_SELECT,
  1279.                                  FADMINFlatBrowserLaunchProc);
  1280.                     break;
  1281.  
  1282.                 case IDC_OPER_NAME:
  1283.                     if(HIWORD(lParam) == EN_CHANGE)
  1284.                     {
  1285.                          bChangeDBOper = 1;
  1286.                          SendMessage(hwnd, NWA_WM_SETPAGEMODIFY, (WORD)hwnd, MAKELONG(0,TRUE));
  1287.                     }
  1288.                     break;
  1289.  
  1290.                 case IDC_FIND_OPER:
  1291.                     context = NWDSCreateContext();
  1292.                     if ( (int) context == ERR_CONTEXT_CREATION )
  1293.                         break;
  1294.                     err = NWDSGetContext(context, DCK_NAME_CONTEXT, contextStr);
  1295.                     if ( err < 0 )
  1296.                     {
  1297.                         NWDSFreeContext(context);
  1298.                         break;
  1299.                     }
  1300.                     NWALaunchDSFlatBrowser(hwnd,
  1301.                                  (long) &databaseObjData,
  1302.                                  contextStr,
  1303.                                  NULL,
  1304.                                  NULL,
  1305.                                  "Selected Object",
  1306.                                  NWA_FB_SINGLE_SELECT,
  1307.                                  FOPERFlatBrowserLaunchProc);
  1308.                     break;
  1309.             }
  1310.                 break;
  1311.  
  1312.             case NWA_WM_CANCLOSE:
  1313.             {
  1314.                 // xfer data to program memory
  1315.                 GetDlgItemText(hwnd, IDC_ADMIN_NAME, databaseObjData.admingroupChange, MAX_DN_CHARS);
  1316.                 GetDlgItemText(hwnd, IDC_OPER_NAME, databaseObjData.opergroupChange, MAX_DN_CHARS);
  1317.                 return TRUE;
  1318.             }
  1319.      }
  1320.      return FALSE ;
  1321. }
  1322.  
  1323.  
  1324.  
  1325. /*-------------------------------------------------------------------------*/
  1326. /* Function : DatabaseUserDlg                                              */
  1327. /* Description :                                                           */
  1328. /*      Database User Page Dialog Proc                                     */
  1329. /*-------------------------------------------------------------------------*/
  1330. BOOL _export FAR PASCAL DatabaseUserDlg(HWND hwnd, UINT message,
  1331.                                                                                 WPARAM wParam, LPARAM lParam)
  1332. {
  1333.     NWDSContextHandle context;
  1334.     int               err=0;
  1335.     char contextStr[256];
  1336.  
  1337.      switch(message)
  1338.      {
  1339.             case WM_INITDIALOG:
  1340.                 {
  1341.                     int i;
  1342.                     bChangeDBUser = 0;
  1343.                     databaseObjData.hDialogUser = hwnd;
  1344.                     for ( i=0; i<databaseObjData.nUserCount; i++)
  1345.                         SendDlgItemMessage(hwnd, IDC_USERLIST, LB_ADDSTRING, 0,
  1346.                                                              (LPARAM) databaseObjData.userList[i] );
  1347.                     return TRUE;
  1348.                 }
  1349.  
  1350.             case NWA_WM_F1HELP:
  1351.                 {
  1352.                     MessageBox(NULL, "Sample Database User Page help", "Database Help", MB_OK);
  1353.                     return TRUE;
  1354.                 }
  1355.  
  1356.             case WM_COMMAND:
  1357.             switch (wParam)
  1358.             {
  1359.                     case IDC_ADDUSER :
  1360.                         {
  1361.                             // launch flat browser with User and User Group
  1362.                             context = NWDSCreateContext();
  1363.                             if ( (int) context == ERR_CONTEXT_CREATION )
  1364.                                 break;
  1365.                             err = NWDSGetContext(context, DCK_NAME_CONTEXT, contextStr);
  1366.                             if ( err < 0 )
  1367.                             {
  1368.                                 NWDSFreeContext(context);
  1369.                                 break;
  1370.                             }
  1371.                             NWALaunchDSFlatBrowser(hwnd,
  1372.                                                                          (long) &databaseObjData,
  1373.                                                                          contextStr,
  1374.                                                                          NULL,
  1375.                                                                          NULL,
  1376.                                                                          "Selected Object",
  1377.                                                                          NWA_FB_MULTIPLE_SELECT,
  1378.                                                                          DSFlatBrowserLaunchProc);
  1379.                         }
  1380.                         NWDSFreeContext(context);
  1381.                         break;
  1382.  
  1383.                     case IDC_DELUSER :
  1384.                         {
  1385.                             int selCount, i;
  1386.                             int *pIndex;
  1387.                             HGLOBAL hmem;
  1388.  
  1389.                             selCount= (int)SendDlgItemMessage(hwnd, IDC_USERLIST,
  1390.                                                                          LB_GETSELCOUNT, 0, 0L );
  1391.                             if ( selCount !=LB_ERR )
  1392.                             {
  1393.                                 SendMessage(hwnd, NWA_WM_SETPAGEMODIFY, (WORD) hwnd,
  1394.                                                         MAKELONG(0,TRUE));
  1395.                                 hmem= GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT,
  1396.                                                                      selCount * sizeof(int));
  1397.                                 pIndex= (int  *) GlobalLock( hmem );
  1398.                                 selCount= (int)SendDlgItemMessage(hwnd, IDC_USERLIST,
  1399.                                                                                  LB_GETSELITEMS, selCount,
  1400.                                                                                  (long) (int FAR *) pIndex );
  1401.                                 for(i=selCount; i > 0 ; i--)
  1402.                                     SendDlgItemMessage(hwnd, IDC_USERLIST, LB_DELETESTRING,
  1403.                                                                          pIndex[i-1], 0L);
  1404.                                 GlobalUnlock(hmem);
  1405.                                 GlobalFree(hmem);
  1406.                             }
  1407.                         }
  1408.                         break;
  1409.             }
  1410.                 return TRUE;
  1411.  
  1412.             case NWA_WM_CANCLOSE:
  1413.                 // xfer data from dialog memory to program memory
  1414.                 // so NWA_MSG_MODIFY can save it in DS if required.
  1415.                 {
  1416.                     int itemCount, i;
  1417.                     bChangeDBUser = 1;
  1418.                     itemCount = (int) SendDlgItemMessage(hwnd, IDC_USERLIST, LB_GETCOUNT,
  1419.                                                                                  0, 0L);
  1420.                     databaseObjData.nDeltaCount=itemCount;
  1421.                     for(i=0; ( i<databaseObjData.nDeltaCount ) &&
  1422.                                      ( i < MAX_DBUSER ) ; i++ )
  1423.                         SendDlgItemMessage(hwnd, IDC_USERLIST, LB_GETTEXT,
  1424.                                                              i, (LPARAM) databaseObjData.userDeltas[i]);
  1425.                     return TRUE;
  1426.                 }
  1427.      }
  1428.      return FALSE ;
  1429. }
  1430.  
  1431.  
  1432.  
  1433. /*-------------------------------------------------------------------------*/
  1434. /* Function : DBServerDatabaseDlg                                          */
  1435. /* Description :                                                           */
  1436. /*      Database Server's Database Page Dialog Proc                        */
  1437. /*-------------------------------------------------------------------------*/
  1438. BOOL _export FAR PASCAL DBServerDatabaseDlg(HWND hwnd, UINT message,
  1439.                                                                                 WPARAM wParam, LPARAM lParam)
  1440. {
  1441.      switch(message)
  1442.      {
  1443.             case WM_INITDIALOG:
  1444.                 {
  1445.                     int i;
  1446.                     bChangeDBSDatabase=0;
  1447.                     dbServerObjData.hDialogDatabase = hwnd;
  1448.                     for ( i=0; i<dbServerObjData.nDatabaseCount; i++)
  1449.                         SendDlgItemMessage(hwnd, IDC_DATABASELIST, LB_ADDSTRING, 0,
  1450.                                                              (LPARAM) dbServerObjData.databaseList[i] );
  1451.                     return TRUE;
  1452.                 }
  1453.  
  1454.             case NWA_WM_F1HELP:
  1455.                 {
  1456.                     MessageBox(NULL, "This is a list of the Databases that are served\nby this Database Server.  Databases are added and deleted\nfrom this list by actually creating and deleting database\nobjects.", "Database Server Help", MB_OK);
  1457.                     return TRUE;
  1458.                 }
  1459.  
  1460.             case NWA_WM_CANCLOSE:
  1461.                 // xfer data from dialog memory to program memory
  1462.                 // so NWA_MSG_MODIFY can save it in DS if required.
  1463.                 {
  1464.                     int itemCount, i;
  1465.                     bChangeDBSDatabase=1;
  1466.                     itemCount = (int)SendDlgItemMessage(hwnd, IDC_DATABASELIST, LB_GETCOUNT,
  1467.                                                                                  0, 0L);
  1468.                     dbServerObjData.nDeltaCount=itemCount;
  1469.                     for(i=0; ( i<dbServerObjData.nDeltaCount ) &&
  1470.                                      ( i < MAX_DBUSER ) ; i++ )
  1471.                         SendDlgItemMessage(hwnd, IDC_DATABASELIST, LB_GETTEXT,
  1472.                                                              i, (LPARAM) dbServerObjData.databaseDeltas[i]);
  1473.                     return TRUE;
  1474.                 }
  1475.      }
  1476.      return FALSE ;
  1477. }
  1478.  
  1479.  
  1480. /*-------------------------------------------------------------------------*/
  1481. /* Function : FADMINFlatBrowserLaunchProc                                                */
  1482. /* Description :                                                           */
  1483. /*  DSFlat Browser Callback Proc                                           */
  1484. /*-------------------------------------------------------------------------*/
  1485. N_EXTERN_LIBRARY( nuint32 ) _export
  1486. FADMINFlatBrowserLaunchProc
  1487. (
  1488.     nuint32 userParam,
  1489.     nuint16 msg,
  1490.     nparam param1,
  1491.     nparam param2
  1492. )
  1493. {
  1494.      int fltCount;
  1495.      NWASelObject *pObj;
  1496.      TDatabaseObject * puData;
  1497.  
  1498.      fltCount=1;
  1499.  
  1500.      switch( msg )
  1501.      {
  1502.          case NWA_MSG_FBFILTER_COUNT :
  1503.              {
  1504.                  *((int *)param1) = fltCount;
  1505.                  break;
  1506.              }
  1507.  
  1508.          case NWA_MSG_FBFILTER_VALUE :
  1509.              {
  1510.                  switch( param1 )
  1511.                  {
  1512.                      case 0L:
  1513.                          strcpy( (char *) param2, "Group");
  1514.                          break;
  1515.                  }
  1516.                  break;
  1517.              }
  1518.  
  1519.          case NWA_MSG_FBOBJECT_VALUE :
  1520.              {
  1521.                  pObj= ( NWASelObject * ) param2;
  1522.                  puData = (TDatabaseObject *) userParam;
  1523.                  SetDlgItemText(puData->hDialogUser, IDC_ADMIN_NAME, pObj->objName);
  1524.                  break;
  1525.              }
  1526.      }
  1527.      return (0);
  1528. }
  1529.  
  1530.  
  1531. /*-------------------------------------------------------------------------*/
  1532. /* Function : FOPERFlatBrowserLaunchProc                                                */
  1533. /* Description :                                                           */
  1534. /*  DSFlat Browser Callback Proc                                           */
  1535. /*-------------------------------------------------------------------------*/
  1536. N_EXTERN_LIBRARY( nuint32 ) _export
  1537. FOPERFlatBrowserLaunchProc
  1538. (
  1539.     nuint32 userParam,
  1540.     nuint16 msg,
  1541.     nparam param1,
  1542.     nparam param2
  1543. )
  1544. {
  1545.      int fltCount;
  1546.      NWASelObject *pObj;
  1547.      TDatabaseObject * puData;
  1548.  
  1549.      fltCount=1;
  1550.  
  1551.      switch( msg )
  1552.      {
  1553.          case NWA_MSG_FBFILTER_COUNT :
  1554.              {
  1555.                  *((int *)param1) = fltCount;
  1556.                  break;
  1557.              }
  1558.  
  1559.          case NWA_MSG_FBFILTER_VALUE :
  1560.              {
  1561.                  switch( param1 )
  1562.                  {
  1563.                      case 0L:
  1564.                          strcpy( (char *) param2, "Group");
  1565.                          break;
  1566.                  }
  1567.                  break;
  1568.              }
  1569.  
  1570.          case NWA_MSG_FBOBJECT_VALUE :
  1571.              {
  1572.                  pObj= ( NWASelObject * ) param2;
  1573.                  puData = (TDatabaseObject *) userParam;
  1574.                  SetDlgItemText(puData->hDialogUser, IDC_OPER_NAME, pObj->objName);
  1575.                  break;
  1576.              }
  1577.      }
  1578.      return (0);
  1579. }
  1580.  
  1581.  
  1582. /*-------------------------------------------------------------------------*/
  1583. /* Function : FNWFlatBrowserLaunchProc                                      */
  1584. /* Description :                                                           */
  1585. /*  DSFlat Browser Callback Proc                                           */
  1586. /*-------------------------------------------------------------------------*/
  1587. N_EXTERN_LIBRARY( nuint32 ) _export
  1588. FNWFlatBrowserLaunchProc
  1589. (
  1590.     nuint32 userParam,
  1591.     nuint16 msg,
  1592.     nparam param1,
  1593.     nparam param2
  1594. )
  1595. {
  1596.      int fltCount;
  1597.      NWASelObject *pObj;
  1598.      TDBServerObject * puData;
  1599.  
  1600.      fltCount=1;
  1601.  
  1602.      switch( msg )
  1603.      {
  1604.          case NWA_MSG_FBFILTER_COUNT :
  1605.              {
  1606.                  *((int *)param1) = fltCount;
  1607.                  break;
  1608.              }
  1609.  
  1610.          case NWA_MSG_FBFILTER_VALUE :
  1611.              {
  1612.                  switch( param1 )
  1613.                  {
  1614.                      case 0L:
  1615.                          strcpy( (char *) param2, "NCP Server");
  1616.                          break;
  1617.                  }
  1618.                  break;
  1619.              }
  1620.  
  1621.          case NWA_MSG_FBOBJECT_VALUE :
  1622.              {
  1623.                  pObj= ( NWASelObject * ) param2;
  1624.                  puData = (TDBServerObject *) userParam;
  1625.  
  1626.                  SetDlgItemText(puData->hDialogDatabase, HOST_NETWARE_NAME, pObj->objName);
  1627.                  break;
  1628.              }
  1629.      }
  1630.      return (0);
  1631. }
  1632.  
  1633.  
  1634. /*-------------------------------------------------------------------------*/
  1635. /* Function : DSFlatBrowserLaunchProc                                      */
  1636. /* Description :                                                           */
  1637. /*  DSFlat Browser Callback Proc                                           */
  1638. /*-------------------------------------------------------------------------*/
  1639. N_EXTERN_LIBRARY( nuint32 ) _export
  1640. DBSFlatBrowserLaunchProc
  1641. (
  1642.     nuint32 userParam,
  1643.     nuint16 msg,
  1644.     nparam param1,
  1645.     nparam param2
  1646. )
  1647. {
  1648.      int fltCount;
  1649.      NWASelObject *pObj;
  1650.      TDBServerObject * puData;
  1651.  
  1652.      fltCount=1;
  1653.  
  1654.      switch( msg )
  1655.      {
  1656.          case NWA_MSG_FBFILTER_COUNT :
  1657.              {
  1658.                  *((int *)param1) = fltCount;
  1659.                  break;
  1660.              }
  1661.  
  1662.          case NWA_MSG_FBFILTER_VALUE :
  1663.              {
  1664.                  switch( param1 )
  1665.                  {
  1666.                      case 0L:
  1667.                          strcpy( (char *) param2, "DBServer");
  1668.                          break;
  1669.                  }
  1670.                  break;
  1671.              }
  1672.  
  1673.          case NWA_MSG_FBOBJECT_VALUE :
  1674.              {
  1675.                  pObj= ( NWASelObject * ) param2;
  1676.                  puData = (TDBServerObject *) userParam;
  1677.  
  1678.                  SetDlgItemText(puData->hDialogDatabase, IDC_DBS_NAME, pObj->objName);
  1679.                  break;
  1680.              }
  1681.      }
  1682.      return (0);
  1683. }
  1684.  
  1685.  
  1686. /*-------------------------------------------------------------------------*/
  1687. /* Function : DSFlatBrowserLaunchProc                                      */
  1688. /* Description :                                                           */
  1689. /*  DSFlat Browser Callback Proc                                           */
  1690. /*-------------------------------------------------------------------------*/
  1691. N_EXTERN_LIBRARY( nuint32 ) _export
  1692. DSFlatBrowserLaunchProc
  1693. (
  1694.     nuint32 userParam,
  1695.     nuint16 msg,
  1696.     nparam param1,
  1697.     nparam param2
  1698. )
  1699. {
  1700.      int fltCount;
  1701.      static long objCount;
  1702.      NWASelObject *pObj;
  1703.      TDatabaseObject * puData;
  1704.  
  1705.      fltCount=1;
  1706.  
  1707.      switch( msg )
  1708.      {
  1709.          case NWA_MSG_FBFILTER_COUNT :
  1710.              {
  1711.                  *((int *)param1) = fltCount;
  1712.                  break;
  1713.              }
  1714.  
  1715.          case NWA_MSG_FBFILTER_VALUE :
  1716.              {
  1717.                  switch( param1 )
  1718.                  {
  1719.                      case 0L:
  1720.                          strcpy( (char *) param2, "User");
  1721.                          break;
  1722.                  }
  1723.                  break;
  1724.              }
  1725.  
  1726.          case NWA_MSG_FBOBJECT_COUNT :
  1727.              {
  1728.                  puData = (TDatabaseObject *) userParam;
  1729.                  objCount= param1;
  1730.                  SendMessage(puData->hDialogUser,
  1731.                                          NWA_WM_SETPAGEMODIFY, (WORD)puData->hDialogUser,
  1732.                                          MAKELONG(0,TRUE));
  1733.                  break;
  1734.              }
  1735.  
  1736.          case NWA_MSG_FBOBJECT_VALUE :
  1737.              {
  1738.                  pObj= ( NWASelObject * ) param2;
  1739.                  puData = (TDatabaseObject *) userParam;
  1740.  
  1741.                  SendDlgItemMessage(puData->hDialogUser, IDC_USERLIST, LB_INSERTSTRING, -1,
  1742.                                                      (LPARAM)((LPSTR) pObj->objName));
  1743.                  break;
  1744.              }
  1745.      }
  1746.      return (0);
  1747. }
  1748.  
  1749.  
  1750. /*-------------------------------------------------------------------------*/
  1751. /* Function : ReadDBSObjectData                                               */
  1752. /* Description :                                                           */
  1753. /*   Function for reading / modifying object data in DS                    */
  1754. /*-------------------------------------------------------------------------*/
  1755. int ReadDBSObjectData()
  1756. {
  1757.     NWDSContextHandle context;
  1758.     int               err=0, i, j;
  1759.     int32             iterHandle=-1L;
  1760.     Buf_T             *resBuf, *nameBuf;
  1761.     char              *attributes[]={"Host Server", "Description", "User"};
  1762.     uint32            totAttr, valCount, synID;
  1763.     char              attrName[MAX_DN_CHARS+1];
  1764.     uint32            flags;
  1765.  
  1766.     context = NWDSCreateContext();
  1767.     if ( (int) context == ERR_CONTEXT_CREATION )
  1768.         return ( (int) context );
  1769.  
  1770.     err=NWDSSetContext(context, DCK_NAME_CONTEXT, DS_ROOT_NAME);
  1771.     if ( err < 0 )
  1772.     {
  1773.         NWDSFreeContext(context);
  1774.         return err;
  1775.     }
  1776.  
  1777.     err = NWDSGetContext(context, DCK_FLAGS, (void *)&flags);
  1778.     if ( err < 0 )
  1779.     {
  1780.         NWDSFreeContext(context);
  1781.         return err;
  1782.     }
  1783.  
  1784.     flags |= DCV_TYPELESS_NAMES;
  1785.     flags |= DCV_XLATE_STRINGS;
  1786.     flags |= DCV_DEREF_ALIASES;
  1787.     flags |= DCV_DEREF_BASE_CLASS;
  1788.  
  1789.     err   = NWDSSetContext (context, DCK_FLAGS, (void *)&flags );
  1790.     if ( err < 0 )
  1791.     {
  1792.         NWDSFreeContext(context);
  1793.         return err;
  1794.     }
  1795.  
  1796.     err=NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &resBuf);
  1797.     if ( err < 0 )
  1798.     {
  1799.         NWDSFreeContext(context);
  1800.         return err;
  1801.     }
  1802.  
  1803.     err=NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &nameBuf);
  1804.     if ( err < 0 )
  1805.     {
  1806.         NWDSFreeContext(context);
  1807.         NWDSFreeBuf(resBuf);
  1808.         return err;
  1809.     }
  1810.  
  1811.     /*----------------------------------------------------------------------*/
  1812.     /* Initialize input buffer and check for errors. The output buffer does */
  1813.     /* not need to be initialized. This buffer will be initialized to       */
  1814.     /* DSV_READ operations                                                  */
  1815.     /*----------------------------------------------------------------------*/
  1816.  
  1817.     err=NWDSInitBuf(context, DSV_READ, nameBuf);
  1818.     if ( err < 0 )
  1819.     {
  1820.         NWDSFreeContext(context);
  1821.         NWDSFreeBuf(resBuf);
  1822.         NWDSFreeBuf(nameBuf);
  1823.         return err;
  1824.     }
  1825.  
  1826.     /*----------------------------------------------------------------------*/
  1827.     /* Put object attributes that are to be read into input buffer.         */
  1828.     /* Check for errors.                                                    */
  1829.     /*----------------------------------------------------------------------*/
  1830.     for(i=0; i < 3; i++)
  1831.     {
  1832.         err= NWDSPutAttrName(context, nameBuf, attributes[i]);
  1833.         if ( err < 0 )
  1834.         {
  1835.             NWDSFreeContext(context);
  1836.             NWDSFreeBuf(resBuf);
  1837.             NWDSFreeBuf(nameBuf);
  1838.             return err;
  1839.         }
  1840.     }
  1841.  
  1842.     /*----------------------------------------------------------------------*/
  1843.     /* Read the data.                                                       */
  1844.     /*----------------------------------------------------------------------*/
  1845.  
  1846.     dbServerObjData.bDescrDefined=0;
  1847.     dbServerObjData.bDatabaseDefined=0;
  1848.     dbServerObjData.bhnwsnameDefined=0;
  1849.     iterHandle=NO_MORE_ITERATIONS;
  1850.     do
  1851.     {
  1852.         err=NWDSRead(context, dbServerObjData.name, DS_ATTRIBUTE_VALUES,
  1853.                                  FALSE, nameBuf, &iterHandle, resBuf);
  1854.         if ( err < 0 )
  1855.         {
  1856.             NWDSFreeContext(context);
  1857.             NWDSFreeBuf(resBuf);
  1858.             NWDSFreeBuf(nameBuf);
  1859.             return err;
  1860.         }
  1861.  
  1862.         /*--------------------------------------------------------------------*/
  1863.         /* pull stuff out of the output buffer, checking for errors.          */
  1864.         /* First, get total no of attributes in the buffer.                   */
  1865.         /*--------------------------------------------------------------------*/
  1866.         err=NWDSGetAttrCount(context, resBuf, &totAttr);
  1867.         if ( err < 0 )
  1868.         {
  1869.             NWDSFreeContext(context);
  1870.             NWDSFreeBuf(resBuf);
  1871.             NWDSFreeBuf(nameBuf);
  1872.             return err;
  1873.         }
  1874.  
  1875.         for(i=0; i< totAttr; i++)
  1876.         {
  1877.             err=NWDSGetAttrName(context, resBuf, attrName, &valCount, &synID);
  1878.             if ( err < 0 )
  1879.             {
  1880.                 NWDSFreeContext(context);
  1881.                 NWDSFreeBuf(resBuf);
  1882.                 NWDSFreeBuf(nameBuf);
  1883.                 return err;
  1884.             }
  1885.                 if(!lstrcmp(attrName,"Description"))
  1886.                 {
  1887.                     dbServerObjData.bDescrDefined=1;
  1888.                     err=NWDSGetAttrVal(context, resBuf, synID, dbServerObjData.descr);
  1889.                     if ( err < 0 )
  1890.                     {
  1891.                         NWDSFreeContext(context);
  1892.                         NWDSFreeBuf(resBuf);
  1893.                         NWDSFreeBuf(nameBuf);
  1894.                         return err;
  1895.                     }
  1896.                 }
  1897.                 else if(!lstrcmp(attrName,"Host Server"))
  1898.                 {
  1899.                     dbServerObjData.bhnwsnameDefined=1;
  1900.                     err=NWDSGetAttrVal(context, resBuf, synID, dbServerObjData.hnwsname);
  1901.                     if ( err < 0 )
  1902.                     {
  1903.                         NWDSFreeContext(context);
  1904.                         NWDSFreeBuf(resBuf);
  1905.                         NWDSFreeBuf(nameBuf);
  1906.                         return err;
  1907.                     }
  1908.                 }
  1909.                 else if(!lstrcmp(attrName,"User"))
  1910.                 {
  1911.                     dbServerObjData.bDatabaseDefined=1;
  1912.                     dbServerObjData.nDatabaseCount = (int) valCount;
  1913.                     for ( j=0; j<valCount; j++)
  1914.                     {
  1915.                         err=NWDSGetAttrVal(context, resBuf, synID,
  1916.                                                              dbServerObjData.databaseList[j]);
  1917.                         if ( err < 0 )
  1918.                         {
  1919.                             NWDSFreeContext(context);
  1920.                             NWDSFreeBuf(resBuf);
  1921.                             NWDSFreeBuf(nameBuf);
  1922.                             return err;
  1923.                         }
  1924.                     }
  1925.                 }
  1926.                 else
  1927.                 {
  1928.                     // Should not come here
  1929.                     // Get the value anyway and ignore
  1930.                     err=NWDSGetAttrVal(context, resBuf, synID, dbServerObjData.descrChange);
  1931.                 }
  1932.         }
  1933.     } while ( iterHandle != NO_MORE_ITERATIONS );
  1934.  
  1935.     NWDSFreeContext(context);
  1936.     NWDSFreeBuf(resBuf);
  1937.     NWDSFreeBuf(nameBuf);
  1938.     return 0;
  1939. }
  1940.  
  1941.  
  1942.  
  1943. /*-------------------------------------------------------------------------*/
  1944. /* Function : ReadDBObjectData                                               */
  1945. /* Description :                                                           */
  1946. /*   Function for reading / modifying object data in DS                    */
  1947. /*-------------------------------------------------------------------------*/
  1948. int ReadDBObjectData()
  1949. {
  1950.     NWDSContextHandle context;
  1951.     int               err=0, i, j;
  1952.     int32             iterHandle=-1L;
  1953.     Buf_T             *resBuf, *nameBuf;
  1954.     char              *attributes[]={"User","Host Server", "DBAdmin", "DBOperator"};
  1955.     uint32            totAttr, valCount, synID;
  1956.     char              attrName[MAX_DN_CHARS+1];
  1957.     uint32            flags;
  1958.  
  1959.     context = NWDSCreateContext();
  1960.     if ( (int) context == ERR_CONTEXT_CREATION )
  1961.         return ( (int) context );
  1962.  
  1963.     err=NWDSSetContext(context, DCK_NAME_CONTEXT, DS_ROOT_NAME);
  1964.     if ( err < 0 )
  1965.     {
  1966.         NWDSFreeContext(context);
  1967.         return err;
  1968.     }
  1969.  
  1970.     err = NWDSGetContext(context, DCK_FLAGS, (void *)&flags);
  1971.     if ( err < 0 )
  1972.     {
  1973.         NWDSFreeContext(context);
  1974.         return err;
  1975.     }
  1976.  
  1977.     flags |= DCV_TYPELESS_NAMES;
  1978.     flags |= DCV_XLATE_STRINGS;
  1979.     flags |= DCV_DEREF_ALIASES;
  1980.     flags |= DCV_DEREF_BASE_CLASS;
  1981.  
  1982.     err   = NWDSSetContext (context, DCK_FLAGS, (void *)&flags );
  1983.     if ( err < 0 )
  1984.     {
  1985.         NWDSFreeContext(context);
  1986.         return err;
  1987.     }
  1988.  
  1989.     err=NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &resBuf);
  1990.     if ( err < 0 )
  1991.     {
  1992.         NWDSFreeContext(context);
  1993.         return err;
  1994.     }
  1995.  
  1996.     err=NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &nameBuf);
  1997.     if ( err < 0 )
  1998.     {
  1999.         NWDSFreeContext(context);
  2000.         NWDSFreeBuf(resBuf);
  2001.         return err;
  2002.     }
  2003.  
  2004.     /*----------------------------------------------------------------------*/
  2005.     /* Initialize input buffer and check for errors. The output buffer does */
  2006.     /* not need to be initialized. This buffer will be initialized to       */
  2007.     /* DSV_READ operations                                                  */
  2008.     /*----------------------------------------------------------------------*/
  2009.  
  2010.     err=NWDSInitBuf(context, DSV_READ, nameBuf);
  2011.     if ( err < 0 )
  2012.     {
  2013.         NWDSFreeContext(context);
  2014.         NWDSFreeBuf(resBuf);
  2015.         NWDSFreeBuf(nameBuf);
  2016.         return err;
  2017.     }
  2018.  
  2019.     /*----------------------------------------------------------------------*/
  2020.     /* Put object attributes that are to be read into input buffer.         */
  2021.     /* Check for errors.                                                    */
  2022.     /*----------------------------------------------------------------------*/
  2023.     for(i=0; i < 4; i++)
  2024.     {
  2025.         err= NWDSPutAttrName(context, nameBuf, attributes[i]);
  2026.         if ( err < 0 )
  2027.         {
  2028.             NWDSFreeContext(context);
  2029.             NWDSFreeBuf(resBuf);
  2030.             NWDSFreeBuf(nameBuf);
  2031.             return err;
  2032.         }
  2033.     }
  2034.  
  2035.     /*----------------------------------------------------------------------*/
  2036.     /* Read the data.                                                       */
  2037.     /*----------------------------------------------------------------------*/
  2038.  
  2039.     databaseObjData.bOperDefined=0;
  2040.     databaseObjData.bAdminDefined=0;
  2041.     databaseObjData.bUserDefined=0;
  2042.     iterHandle=NO_MORE_ITERATIONS;
  2043.     do
  2044.     {
  2045.         err=NWDSRead(context, databaseObjData.name, DS_ATTRIBUTE_VALUES,
  2046.                                  FALSE, nameBuf, &iterHandle, resBuf);
  2047.         if ( err < 0 )
  2048.         {
  2049.             NWDSFreeContext(context);
  2050.             NWDSFreeBuf(resBuf);
  2051.             NWDSFreeBuf(nameBuf);
  2052.             return err;
  2053.         }
  2054.  
  2055.         /*--------------------------------------------------------------------*/
  2056.         /* pull stuff out of the output buffer, checking for errors.          */
  2057.         /* First, get total no of attributes in the buffer.                   */
  2058.         /*--------------------------------------------------------------------*/
  2059.         err=NWDSGetAttrCount(context, resBuf, &totAttr);
  2060.         if ( err < 0 )
  2061.         {
  2062.             NWDSFreeContext(context);
  2063.             NWDSFreeBuf(resBuf);
  2064.             NWDSFreeBuf(nameBuf);
  2065.             return err;
  2066.         }
  2067.  
  2068.         for(i=0; i< totAttr; i++)
  2069.         {
  2070.             err=NWDSGetAttrName(context, resBuf, attrName, &valCount, &synID);
  2071.             if ( err < 0 )
  2072.             {
  2073.                 NWDSFreeContext(context);
  2074.                 NWDSFreeBuf(resBuf);
  2075.                 NWDSFreeBuf(nameBuf);
  2076.                 return err;
  2077.             }
  2078.  
  2079.             if ( lstrcmp(attrName, "User") == 0 )
  2080.             {
  2081.                 databaseObjData.bUserDefined=1;
  2082.                 databaseObjData.nUserCount = (int) valCount;
  2083.                 for ( j=0; j<valCount; j++)
  2084.                 {
  2085.                     err=NWDSGetAttrVal(context, resBuf, synID,
  2086.                                                          databaseObjData.userList[j]);
  2087.                     if ( err < 0 )
  2088.                     {
  2089.                         NWDSFreeContext(context);
  2090.                         NWDSFreeBuf(resBuf);
  2091.                         NWDSFreeBuf(nameBuf);
  2092.                         return err;
  2093.                     }
  2094.                 }
  2095.             }
  2096.             else if ( lstrcmp(attrName, "Host Server") == 0 )
  2097.             {
  2098.                 err=NWDSGetAttrVal(context, resBuf, synID, databaseObjData.hdbname);
  2099.                 if ( err < 0 )
  2100.                 {
  2101.                     NWDSFreeContext(context);
  2102.                     NWDSFreeBuf(resBuf);
  2103.                     NWDSFreeBuf(nameBuf);
  2104.                     return err;
  2105.                 }
  2106.             }
  2107.             else if ( lstrcmp(attrName, "DBAdmin") == 0 )
  2108.             {
  2109.                 databaseObjData.bAdminDefined=1;
  2110.                 err=NWDSGetAttrVal(context, resBuf, synID, databaseObjData.admingroup);
  2111.                 if ( err < 0 )
  2112.                 {
  2113.                     NWDSFreeContext(context);
  2114.                     NWDSFreeBuf(resBuf);
  2115.                     NWDSFreeBuf(nameBuf);
  2116.                     return err;
  2117.                 }
  2118.             }
  2119.             else if ( lstrcmp(attrName, "DBOperator") == 0 )
  2120.             {
  2121.                 databaseObjData.bOperDefined=1;
  2122.                 err=NWDSGetAttrVal(context, resBuf, synID, databaseObjData.opergroup);
  2123.                 if ( err < 0 )
  2124.                 {
  2125.                     NWDSFreeContext(context);
  2126.                     NWDSFreeBuf(resBuf);
  2127.                     NWDSFreeBuf(nameBuf);
  2128.                     return err;
  2129.                 }
  2130.             }
  2131.             else
  2132.             {
  2133.                 // Should not come here
  2134.                 // Get the value anyway and ignore
  2135.                 err=NWDSGetAttrVal(context, resBuf, synID, databaseObjData.opergroup);
  2136.             }
  2137.         }
  2138.     } while ( iterHandle != NO_MORE_ITERATIONS );
  2139.  
  2140.     NWDSFreeContext(context);
  2141.     NWDSFreeBuf(resBuf);
  2142.     NWDSFreeBuf(nameBuf);
  2143.     return 0;
  2144. }
  2145.  
  2146.  
  2147.