home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / ndsvw.exe / NDSVIEW.C next >
Text File  |  1995-03-27  |  23KB  |  720 lines

  1. /****************************************************************************
  2. **    File:    NDSVIEW.C
  3. **
  4. **    Desc:    This program lists all of the attributes of all objects in
  5. **        a specific context in the tree.  It is written as a snapin module for
  6. **        nwadmin so the currenly selected object in NWAdmin is the object
  7. **        used to display the attributes.
  8. **
  9. **        After complilation, the snapin is installed by editing the nwadmin.ini
  10. **        file located in the c:\windows (or wherever installed) directory.  The
  11. **        modification lookes something like this:
  12. **
  13. **    [Snapin Object DLLs]
  14. **        NDSVIEW=D:\DEV\WIN\NDSVIEW\NDSVIEW.DLL
  15. **
  16. **        where "D:\DEV\WIN\NDSVIEW" is the path to the dll to be loaded.
  17. **
  18. **
  19. **        DISCLAIMER
  20. **
  21. **    Novell, Inc. makes no representations or warranties with respect to
  22. **    any NetWare software, and specifically disclaims any express or
  23. **    implied warranties of merchantability, title, or fitness for a
  24. **    particular purpose.
  25. **
  26. **    Distribution of any NetWare software is forbidden without the
  27. **    express written consent of Novell, Inc.  Further, Novell reserves
  28. **    the right to discontinue distribution of any NetWare software.
  29. **
  30. **    Novell is not responsible for lost profits or revenue, loss of use
  31. **    of the software, loss of data, costs of re-creating lost data, the
  32. **    cost of any substitute equipment or program, or claims by any party
  33. **    other than you.  Novell strongly recommends a backup be made before
  34. **    any software is installed.   Technical support for this software
  35. **    may be provided at the discretion of Novell.
  36. **
  37. **    History:
  38. **
  39. **        When            Who    What
  40. **        -----------------------------------------------------------------------
  41. **        10-20-94    CRG    Original code adapted from dsview.c
  42. **        03-27-95    CRG    Cleaned up memory allocation.
  43. */
  44.  
  45. #define NWWIN
  46.  
  47. /***************************************************************************
  48. **  Libraries Linked in for .exe
  49. **
  50. **  NWCALLS.LIB
  51. **  NWLOCALE.LIB
  52. **  NWNET.LIB
  53. **    SNAPIN.LIB
  54. **
  55. */
  56.  
  57. /****************************************************************************
  58. **    Include headers, macros, function prototypes, etc.
  59. */
  60.  
  61.     /*------------------------------------------------------------------------
  62.     **    ANSI
  63.     */
  64.     #include <windows.h>
  65.     #include <dos.h>
  66.     #include <io.h>
  67.     #include <toolhelp.h>
  68.     #include <string.h>
  69.     #include <stdio.h>
  70.     #include <malloc.h>
  71.  
  72.  
  73.     /*------------------------------------------------------------------------
  74.     **    NetWare
  75.     */
  76.     #include <nwnet.h>
  77.     #include <nwsnapin.h>
  78.     #include "ndsview.h"
  79.  
  80.     /*------------------------------------------------------------------------
  81.     **    Prototypes
  82.     */
  83.     BOOL FAR PASCAL _export NDSViewDlgProc(HWND hDlg, UINT message, UINT wParam,
  84.                                 LONG lParam);
  85.     N_EXTERN_LIBRARY( void ) NDSViewMenuAction(void);
  86.     N_EXTERN_LIBRARY( void ) NDSViewMenuValid(pnuint16 pFlags);
  87.     WORD InitDialogStuff(HWND hDlg);
  88.     WORD InitAttrListBox(HWND hDlg);
  89.     WORD UpdateValueListBox(HWND hDlg);
  90.     void DecodeRights(char *attrName, char *rightsstring, NWDS_PRIVILEGES    privs);
  91.     long HandleCcode(HWND hDlg, NWDSCCODE ccode, char *procName);
  92.  
  93.     /*------------------------------------------------------------------------
  94.     **    Globals
  95.     */
  96.  
  97.     HINSTANCE                hDLL;
  98.     char                        currObjName[MAX_DN_CHARS];
  99.     NWDSContextHandle        gContext;
  100.  
  101.  
  102.  
  103. /***************************************************************************
  104. **    DLL Entry Point
  105. */
  106. int FAR PASCAL LibMain (HINSTANCE hInstance, WORD wDataSeg,
  107.                                 WORD cbHeapSize, LPSTR lpCmdLine)
  108. {
  109.     hDLL = hInstance;
  110.     if(cbHeapSize != 0)
  111.         UnlockData (0);
  112.     return 1;
  113. };
  114.  
  115.  
  116.  
  117. /***************************************************************************
  118. **    Every Snapin DLL must provide this function. In this function,
  119. **    snapin menu items (under Tools) are registered. Also, object procs
  120. **    are registered.
  121. */
  122. int _export FAR PASCAL InitSnapin()
  123. {
  124.     nuint16 MenuIDNDSView=0;
  125.  
  126.     /*-----------------------------------------------------------------------
  127.     ** Registering Menu Item
  128.     */
  129.     NWARegisterMenu(NWA_VIEW_BROWSER,
  130.                             0,
  131.                             NULL,
  132.                             MF_STRING,
  133.                             &MenuIDNDSView,
  134.                             "View &Attributes",
  135.                             "View Object's Attributes",
  136.                             NDSViewMenuAction,
  137.                             NDSViewMenuValid,
  138.                             NWA_SNAPIN_VERSION);
  139.  
  140.  
  141.     return NWA_RET_SUCCESS;
  142. }
  143.  
  144.  
  145.  
  146. /******************************************************************************
  147. **    Creates the main dialog for NDSView.  Also sets up the Callback procedure
  148. **        NDSViewDlgProc to handle dialog messages.
  149. */
  150. N_GLOBAL_LIBRARY( void ) _export
  151. NDSViewMenuAction( void )
  152. {
  153.     static FARPROC lpfnNDSViewDlgProc;
  154.  
  155.     lpfnNDSViewDlgProc = MakeProcInstance((FARPROC)NDSViewDlgProc, hDLL);
  156.     DialogBox(hDLL, "NDSVIEW_DIALOG", GetActiveWindow(), lpfnNDSViewDlgProc);
  157.     FreeProcInstance(lpfnNDSViewDlgProc);
  158. }
  159.  
  160.  
  161.  
  162. /******************************************************************************
  163. **    Validates the item under the tools menu in NWAdmin.
  164. */
  165. N_GLOBAL_LIBRARY( void ) _export
  166. NDSViewMenuValid( pnuint16 pFlags )
  167. {
  168.     *pFlags=MF_ENABLED;
  169. }
  170.  
  171.  
  172.  
  173. /******************************************************************************
  174. **    This is the callback procedure that handles the messages for the main
  175. **        dialog of the snapin.
  176. */
  177. BOOL FAR PASCAL _export NDSViewDlgProc(HWND hDlg, UINT message, UINT wParam,
  178.                                     LONG lParam)
  179. {
  180.     switch(message)
  181.     {
  182.         case WM_INITDIALOG:
  183.             InitDialogStuff(hDlg);
  184.             InitAttrListBox(hDlg);
  185.             SetFocus(GetDlgItem(hDlg, IDC_ATTR_NAMES));
  186.             return FALSE;
  187.         case WM_SYSCOMMAND:
  188.             if (wParam == SC_CLOSE)
  189.             {
  190.                 NWDSFreeContext(gContext);
  191.                 EndDialog(hDlg, TRUE);
  192.                 return TRUE;
  193.             }
  194.         case WM_COMMAND:
  195.             switch(wParam)
  196.             {
  197.                 case BUT_QUIT:
  198.                     NWDSFreeContext(gContext);
  199.                     EndDialog(hDlg, TRUE);
  200.                     return TRUE;
  201.                 case IDC_ATTR_NAMES:
  202.                     if (HIWORD (lParam) == LBN_SELCHANGE)
  203.                         UpdateValueListBox(hDlg);
  204.                     break;
  205.                 default:
  206.                     break;
  207.             }
  208.             break;
  209.     }
  210.     return FALSE;
  211. }
  212.  
  213.  
  214.  
  215. /******************************************************************************
  216. **    Before the dialog windows is displayed, the values are initialized.  This
  217. **        function creates the context and gets the currently selected object in
  218. **        NWAdmin and sets those values in the dialog window.
  219. */
  220. WORD InitDialogStuff(HWND hDlg)
  221. {
  222.     NWASelObject  selObject;
  223.     NWDSCCODE      ccode;
  224.     DWORD              flags;
  225.  
  226.     gContext = NWDSCreateContext();
  227.     if((int)gContext == ERR_CONTEXT_CREATION)
  228.     {
  229.         MessageBox(hDlg, "Create Context Failed with 'ERR_CONTEXT_CREATION'", "WDSVIEW Error", MB_OK);
  230.         return((WORD)gContext);
  231.     }
  232.     ccode = NWDSSetContext(gContext, DCK_NAME_CONTEXT, "[Root]");
  233.     if(ccode < 0)
  234.     {
  235.         HandleCcode(hDlg, ccode, "NWDSSetContext");
  236.         return(ccode);
  237.     }
  238.     ccode = NWDSGetContext(gContext, DCK_FLAGS, &flags);
  239.     if(ccode < 0)
  240.     {
  241.         HandleCcode(hDlg, ccode, "NWDSGetContext");
  242.         return(ccode);
  243.     }
  244.     /* Turning off Types for all names. (ie: is.novell not ou=is.o=novell) */
  245.     flags |= DCV_TYPELESS_NAMES;
  246.     flags &= ~DCV_CANONICALIZE_NAMES;
  247.     ccode = NWDSSetContext(gContext, DCK_FLAGS, &flags);
  248.     if(ccode < 0)
  249.     {
  250.         HandleCcode(hDlg, ccode, "NWDSSetContext");
  251.         return(ccode);
  252.     }
  253.     NWAGetSelObject(0, &selObject);
  254.     strcpy(currObjName, selObject.objName);
  255.     SetDlgItemText(hDlg, IDC_OBJECT_NAME, currObjName);
  256.     return 0;
  257. }
  258.  
  259.  
  260.  
  261. /***************************************************************************
  262. **  This is a generic error handling routine.  It pops up a windows showing
  263. **    the message and error code passed in.
  264. */
  265. long HandleCcode(HWND hDlg, NWDSCCODE ccode, char *procName)
  266. {
  267.     char message[100];
  268.  
  269.     sprintf(message,"%s returned code: 0x%X", procName, ccode);
  270.     MessageBox(hDlg, message, "WDSVIEW Error", MB_OK);
  271.     return 0;
  272. };
  273.  
  274.  
  275.  
  276. /******************************************************************************
  277. **    This fills the attribute list for the currently selected object.
  278. */
  279. WORD InitAttrListBox(HWND hDlg)
  280. {
  281.     NWDS_BUFFER            *outBuf;
  282.     NWDS_ITERATION    iterationHandle = -1L;
  283.     NWDSCCODE                ccode;
  284.     char                        attrName[MAX_DN_CHARS + 1];
  285.     NWCOUNT                    attrCount;
  286.     int                            i;
  287.     NWSYNTAX_ID            syntax;
  288.     NWCOUNT                    valCount;
  289.  
  290.     ccode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &outBuf);
  291.     if(ccode < 0)
  292.     {
  293.         HandleCcode(hDlg, ccode, "NWDSAllocBuf");
  294.         return 1;
  295.     }
  296.     do
  297.     {
  298.         ccode = NWDSRead(
  299.                             gContext,                    /* Context Handle  (IN)        */
  300.                             currObjName,        /* name of object  (IN)        */
  301.                             DS_ATTRIBUTE_NAMES,    /* a #define         (IN)            */
  302.                             TRUE,                        /* #define as 1 (IN)            */
  303.                             NULL,                        /* Attribute names (IN)     */
  304.                             &iterationHandle,        /* iteration Handle (OUT) */
  305.                             outBuf);             /* Output Buffer (OUT)         */
  306.         if (ccode < 0)
  307.         {
  308.             HandleCcode(hDlg, ccode, "NWDSRead");
  309.             NWDSFreeBuf(outBuf);
  310.             return 1;
  311.         }
  312.         ccode = NWDSGetAttrCount(gContext, outBuf, &attrCount);
  313.         if (ccode < 0)
  314.         {
  315.             HandleCcode(hDlg, ccode, "NWDSGetAttrCount");
  316.             NWDSFreeBuf(outBuf);
  317.             return 1;
  318.         }
  319.         for(i = 0; i < attrCount; i++)
  320.         {
  321.             ccode = NWDSGetAttrName(gContext, outBuf, attrName, &valCount, &syntax);
  322.             if(ccode < 0)
  323.             {
  324.                 HandleCcode(hDlg, ccode, "NWDSGetAttrName");
  325.                 NWDSFreeBuf(outBuf);
  326.                 return 1;
  327.             }
  328.             SendDlgItemMessage(hDlg, IDC_ATTR_NAMES, LB_ADDSTRING, 0,
  329.                         (LONG) (LPSTR) attrName);
  330.         }
  331.     }
  332.     while(iterationHandle != -1L);
  333.     NWDSFreeBuf(outBuf);
  334.     return 0;
  335. }
  336.  
  337.  
  338.  
  339. /******************************************************************************
  340. **    Whenever a new attribute is selected, the value windows on the dialog
  341. **        must be updated with the new attributes value.  This function does that.
  342. */
  343. WORD UpdateValueListBox(HWND hDlg)
  344. {
  345.     NWDS_BUFFER                    *outBuf,*inBuf;
  346.     NWDS_ITERATION                iterationHandle;
  347.     NWDSCCODE                    ccode;
  348.     char                            attrName[MAX_DN_CHARS];
  349.     int                            j;
  350.     NWSIZE                        attrSize;
  351.     NWSYNTAX_ID                    syntax;
  352.     NWCOUNT                        valCount;
  353.     NWCOUNT                        totalAttrs;
  354.     char                            currAttr[MAX_DN_CHARS];
  355.     HANDLE                        htxtBuffer, htmpBuffer, hattrValue;
  356.     void                            *attrValue;
  357.     char                            *txtBuffer;
  358.     char                            *tmpBuffer;
  359.     char                            rightsstr[9];
  360.     struct date                    dt;
  361.     struct time                    tm;
  362.     WORD                            n;
  363.     int                              fHandle;
  364.  
  365.     SetDlgItemText(hDlg, IDC_ATTR_VALUES, "");
  366.     n = (WORD) SendDlgItemMessage(hDlg, IDC_ATTR_NAMES, LB_GETCURSEL, 0, 0L);
  367.     SendDlgItemMessage(hDlg, IDC_ATTR_NAMES, LB_GETTEXT, n,
  368.                         (LONG) (LPSTR) attrName);
  369.     strset(rightsstr, '\x0');
  370.     iterationHandle = -1L;
  371.  
  372.     if((htxtBuffer = GlobalAlloc(LHND, DEFAULT_MESSAGE_LEN))==NULL)
  373.     {
  374.         MessageBox(hDlg, "Could not Allocate Memory", "Error", MB_OK);
  375.         return 1;
  376.     }
  377.     if((htmpBuffer = GlobalAlloc(LHND, DEFAULT_MESSAGE_LEN))==NULL)
  378.     {
  379.         GlobalFree(htxtBuffer);
  380.         MessageBox(hDlg, "Could not Allocate Memory", "Error", MB_OK);
  381.         return 1;
  382.     }
  383.     (void *)txtBuffer = GlobalLock(htxtBuffer);
  384.     (void *)tmpBuffer = GlobalLock(htmpBuffer);
  385.  
  386.     ccode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &inBuf);
  387.     if(ccode < 0)
  388.     {
  389.         GlobalUnlock(htxtBuffer);
  390.         GlobalFree(htxtBuffer);
  391.         GlobalUnlock(htmpBuffer);
  392.         GlobalFree(htmpBuffer);
  393.         HandleCcode(hDlg, ccode, "NWDSAllocBuf");
  394.         return(ccode);
  395.     }
  396.     ccode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &outBuf);
  397.     if(ccode < 0)
  398.     {
  399.             GlobalUnlock(htxtBuffer);
  400.             GlobalFree(htxtBuffer);
  401.             GlobalUnlock(htmpBuffer);
  402.             GlobalFree(htmpBuffer);
  403.             HandleCcode(hDlg, ccode, "NWDSAllocBuf");
  404.             NWDSFreeBuf(inBuf);
  405.             return(ccode);
  406.      }
  407.     ccode = NWDSInitBuf(gContext,DSV_READ,inBuf);
  408.     if(ccode <0)
  409.     {
  410.             HandleCcode(hDlg, ccode, "NWDSInitBuf");
  411.             GlobalUnlock(htxtBuffer);
  412.             GlobalFree(htxtBuffer);
  413.             GlobalUnlock(htmpBuffer);
  414.             GlobalFree(htmpBuffer);
  415.             NWDSFreeBuf(inBuf);
  416.             NWDSFreeBuf(outBuf);
  417.             return(ccode);
  418.     }
  419.     ccode = NWDSPutAttrName(gContext,inBuf,attrName);
  420.     if(ccode <0)
  421.     {
  422.             HandleCcode(hDlg, ccode, "NWDSPutAttrName");
  423.             GlobalUnlock(htxtBuffer);
  424.             GlobalFree(htxtBuffer);
  425.             GlobalUnlock(htmpBuffer);
  426.             GlobalFree(htmpBuffer);
  427.             NWDSFreeBuf(inBuf);
  428.             NWDSFreeBuf(outBuf);
  429.             return(ccode);
  430.     }
  431.     do
  432.     {
  433.         ccode = NWDSRead(gContext,                    /* Context Handle  (IN)        */
  434.                                 currObjName,            /* name of object  (IN)        */
  435.                                 DS_ATTRIBUTE_VALUES,        /* a #define         (IN)            */
  436.                                 FALSE,                            /* #define as 1 (IN)            */
  437.                                 inBuf,                            /* Attribute names (IN)     */
  438.                                 &iterationHandle,            /* iteration Handle (OUT) */
  439.                                 outBuf);                  /* Output Buffer (OUT)         */
  440.         if(ccode < 0)
  441.         {
  442.                 HandleCcode(hDlg, ccode, "NWDSRead");
  443.                 GlobalUnlock(htxtBuffer);
  444.                 GlobalFree(htxtBuffer);
  445.                 GlobalUnlock(htmpBuffer);
  446.                 GlobalFree(htmpBuffer);
  447.                 NWDSFreeBuf(inBuf);
  448.                 NWDSFreeBuf(outBuf);
  449.                 return(ccode);
  450.         }
  451.         ccode = NWDSGetAttrCount(gContext, outBuf, &totalAttrs);
  452.         if(ccode < 0)
  453.         {
  454.                 HandleCcode(hDlg, ccode, "NWDSGetAttrCount");
  455.                 GlobalUnlock(htxtBuffer);
  456.                 GlobalFree(htxtBuffer);
  457.                 GlobalUnlock(htmpBuffer);
  458.                 GlobalFree(htmpBuffer);
  459.                 NWDSFreeBuf(inBuf);
  460.                 NWDSFreeBuf(outBuf);
  461.                 return(ccode);
  462.         }
  463.         if((NWCOUNT)0 == totalAttrs)
  464.         {
  465.                 GlobalUnlock(htxtBuffer);
  466.                 GlobalFree(htxtBuffer);
  467.                 GlobalUnlock(htmpBuffer);
  468.                 GlobalFree(htmpBuffer);
  469.                 NWDSFreeBuf(inBuf);
  470.                 NWDSFreeBuf(outBuf);
  471.                 return(TRUE);
  472.         }
  473.         else
  474.         {
  475.             ccode = NWDSGetAttrName(gContext, outBuf, currAttr, &valCount, &syntax);
  476.             if(ccode < 0)
  477.             {
  478.                     HandleCcode(hDlg, ccode, "NWDSGetAttrName");
  479.                     GlobalUnlock(htxtBuffer);
  480.                     GlobalFree(htxtBuffer);
  481.                     GlobalUnlock(htmpBuffer);
  482.                     GlobalFree(htmpBuffer);
  483.                     NWDSFreeBuf(inBuf);
  484.                     NWDSFreeBuf(outBuf);
  485.                     return(ccode);
  486.             }
  487.             for(j = 0; j < valCount; j++)
  488.             {
  489.  
  490.                 /*  Note that the attribute value size is computed each time a value
  491.                         is read.  Each attribute may have multiple values and each value
  492.                         may be a different size */
  493.  
  494.                 ccode = NWDSComputeAttrValSize(gContext, outBuf, syntax, &attrSize);
  495.                 if(ccode < 0)
  496.                 {
  497.                         HandleCcode(hDlg, ccode, "NWDSComputeAttrValSize");
  498.                         GlobalUnlock(htxtBuffer);
  499.                         GlobalFree(htxtBuffer);
  500.                         GlobalUnlock(htmpBuffer);
  501.                         GlobalFree(htmpBuffer);
  502.                         NWDSFreeBuf(inBuf);
  503.                         NWDSFreeBuf(outBuf);
  504.                         return(ccode);
  505.                 }
  506.                 if((hattrValue = LocalAlloc(LHND, (UINT) attrSize))==NULL)
  507.                 {
  508.                     GlobalUnlock(htxtBuffer);
  509.                     GlobalFree(htxtBuffer);
  510.                     GlobalUnlock(htmpBuffer);
  511.                     GlobalFree(htmpBuffer);
  512.                     NWDSFreeBuf(inBuf);
  513.                     NWDSFreeBuf(outBuf);
  514.                     return(ccode);
  515.                 }
  516.                 attrValue = LocalLock(hattrValue);
  517.                 ccode = NWDSGetAttrVal(gContext, outBuf, syntax, attrValue);
  518.                 if(ccode < 0)
  519.                     break;
  520.                 switch(syntax)                  /* for syntax reference see the        */
  521.                 {                               /* NDS Schema Specification                */
  522.                     case SYN_BACK_LINK    :
  523.                                         sprintf(tmpBuffer,"%lu\r\n%s\r\n",((Back_Link_T *)attrValue)->remoteID,((Back_Link_T *)attrValue)->objectName);
  524.                                         break;
  525.                     case SYN_BOOLEAN        :
  526.                                         sprintf(tmpBuffer,"%s\r\n", ((*((uint8 *)attrValue)) ? "TRUE" : "FALSE"));
  527.                                         break;
  528.                     case SYN_CI_LIST        :
  529.                                         sprintf(tmpBuffer,"%s\r\n", ((CI_List_T *)attrValue)->s);
  530.                                         break;
  531.                     case SYN_COUNTER        :
  532.                                         sprintf(tmpBuffer,"%lu\r\n", *((uint32 *)attrValue));
  533.                                         break;
  534.                     case SYN_CE_STRING     :                                /* All of these are strings */
  535.                     case SYN_CI_STRING    :                                /* and therefore are all    */
  536.                     case SYN_NU_STRING    :               /* printed the same way     */
  537.                     case SYN_PR_STRING    :
  538.                     case SYN_TEL_NUMBER    :
  539.                     case SYN_CLASS_NAME    :
  540.                     case SYN_DIST_NAME    :
  541.                                         sprintf(tmpBuffer,"%s\r\n",(char *)attrValue);
  542.                                         break;
  543.                     case SYN_EMAIL_ADDRESS :
  544.                                         sprintf(tmpBuffer,"%lu, %s\r\n", ((EMail_Address_T *)attrValue)->type, ((EMail_Address_T *)attrValue)->address);
  545.                                         break;
  546.                     case SYN_FAX_NUMBER    :
  547.                                         sprintf(tmpBuffer,"%s\r\n",((Fax_Number_T *)attrValue)->telephoneNumber);
  548.                                         break;
  549.                     case SYN_HOLD        :
  550.                                         sprintf(tmpBuffer,"%s, %lu\r\n",((Hold_T *)attrValue)->objectName,((Hold_T *)attrValue)->amount);
  551.                                         break;
  552.                     case SYN_INTEGER    :
  553.                     case SYN_INTERVAL    :
  554.                                         sprintf(tmpBuffer,"%lu\r\n",*((uint32 *)attrValue));
  555.                                         break;
  556.                     case SYN_NET_ADDRESS    :
  557.                                         sprintf(tmpBuffer,"Address Type:%lu\r\nAddress Length:%lu\r\nAddress:%02X%02X%02X%02X:%02X%02X%02X%02X%02X%02X\r\n", ((Net_Address_T *)attrValue)->addressType,((Net_Address_T *)attrValue)->addressLength,((Net_Address_T *)attrValue)->address[0],((Net_Address_T *)attrValue)->address[1],((Net_Address_T *)attrValue)->address[2],((Net_Address_T *)attrValue)->address[3],((Net_Address_T *)attrValue)->address[4],((Net_Address_T *)attrValue)->address[5],((Net_Address_T *)attrValue)->address[6],((Net_Address_T *)attrValue)->address[7],((Net_Address_T *)attrValue)->address[8],((Net_Address_T *)attrValue)->address[9]);
  558.                                         break;
  559.                     case SYN_OBJECT_ACL    :
  560.                                         DecodeRights(((Object_ACL_T *)attrValue)->protectedAttrName, rightsstr, ((Object_ACL_T *)attrValue)->privileges);
  561.                                         sprintf(tmpBuffer,"%s %s %s\r\n",((Object_ACL_T *)attrValue)->protectedAttrName,rightsstr,((Object_ACL_T *)attrValue)->subjectName);
  562.                                         break;
  563.                     case SYN_OCTET_LIST :
  564.                                         sprintf(tmpBuffer,"Because the syntax SYN_OCTET_LIST is a linked list\r\nit is not shown here\r\n");
  565.                                         break;
  566.                     case SYN_OCTET_STRING :
  567.                                         sprintf(tmpBuffer,"Length: 0x%x\r\nData: 0x%x\r\n",((Octet_String_T *)attrValue)->length, (uint8 *)((Octet_String_T *)attrValue)->data);
  568.                                         break;
  569.                     case SYN_PATH    :
  570.                                         sprintf(tmpBuffer,"Name Space Type: %lu\r\n%s:%s\r\n",((Path_T *)attrValue)->nameSpaceType,((Path_T *)attrValue)->volumeName,((Path_T *)attrValue)->path);
  571.                                         break;
  572.                     case SYN_PO_ADDRESS :
  573.                                         sprintf(tmpBuffer,"%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n",((char **)attrValue)[0],((char **)attrValue)[1],((char **)attrValue)[2],((char **)attrValue)[3],((char **)attrValue)[4],((char **)attrValue)[5]);
  574.                                         break;
  575.                     case SYN_REPLICA_POINTER    :
  576.                                         sprintf(tmpBuffer,"serverName: %s\r\nreplicaType: %lu\r\nreplicaNumber: %u\r\ncount: %lu\r\nReplica_Pointer_T.Net_Address_T not shown\r\n", ((Replica_Pointer_T *)attrValue)->serverName,((Replica_Pointer_T *)attrValue)->replicaType,((Replica_Pointer_T *)attrValue)->replicaNumber,((Replica_Pointer_T *)attrValue)->count);
  577.                                         break;
  578.                     case SYN_STREAM :
  579.                                         ccode = NWDSOpenStream(gContext, currObjName, currAttr, (NWDS_FLAGS)1, &fHandle);
  580.                                         if(!ccode)
  581.                                             _lread(fHandle, (void *)tmpBuffer, DEFAULT_MESSAGE_LEN);
  582.                                         else
  583.                                         {
  584.                                             sprintf(tmpBuffer,"NWDSOpenStream returned: %d",ccode);
  585.                                             MessageBox(hDlg, tmpBuffer, "View Attributes Error", MB_OK);
  586.                                         }
  587.                                         close(fHandle);
  588.                                         break;
  589.                     case SYN_TIME :
  590.                                         unixtodos(*((uint32 *)attrValue), &dt, &tm);
  591.                                         sprintf(tmpBuffer,"%d-%d-%d  %d:%d:%d\r\n", dt.da_mon, dt.da_day, dt.da_year, tm.ti_hour, tm.ti_min, tm.ti_sec);
  592.                                         break;
  593.                     case SYN_TIMESTAMP :
  594.                                         unixtodos(((NWDS_TimeStamp_T *)attrValue)->wholeSeconds, &dt, &tm);
  595.                                         sprintf(tmpBuffer,"%d-%d-%d  %d:%d:%d\r\n%lu\r\n", dt.da_mon, dt.da_day, dt.da_year, tm.ti_hour, tm.ti_min, tm.ti_sec, ((NWDS_TimeStamp_T *)attrValue)->eventID);
  596.                                         break;
  597.                     case SYN_TYPED_NAME :
  598.                                         sprintf(tmpBuffer,"0x%x, 0x%x, 0x%x\r\n", ((Typed_Name_T *)attrName)->objectName, ((Typed_Name_T *)attrName)->level, ((Typed_Name_T *)attrName)->interval);
  599.                                         break;
  600.                     default                :
  601.                                         sprintf(tmpBuffer,"Unrecognized Sytax\r\n");
  602.                                         break;
  603.                 }
  604.                 if(!((strlen(txtBuffer)) + (strlen(txtBuffer)) > DEFAULT_MESSAGE_LEN))
  605.                     strcat(txtBuffer,tmpBuffer);
  606.                 else
  607.                 {
  608.                     MessageBox(hDlg, "The Attribute you are reading holds more information\nthan is displayed but cannot be shown here.", "Memory Limit Reached", MB_OK);
  609.                     j= (int) valCount;
  610.                     iterationHandle = -1L;
  611.                 }
  612.                 SetDlgItemText(hDlg, IDC_ATTR_VALUES, txtBuffer);
  613.                 LocalUnlock(hattrValue);
  614.                 LocalFree(hattrValue);
  615.             }
  616.         }
  617.     }
  618.     while(iterationHandle != -1L);
  619.     GlobalUnlock(htxtBuffer);
  620.     GlobalFree(htxtBuffer);
  621.     GlobalUnlock(htmpBuffer);
  622.     GlobalFree(htmpBuffer);
  623.     NWDSFreeBuf(inBuf);
  624.     NWDSFreeBuf(outBuf);
  625.     return 0;
  626. }
  627.  
  628.  
  629.  
  630.  
  631. /***************************************************************************
  632. **    This procedure takes a list of rights (normally from an ACL) and
  633. **    translates then from the variable "privs" to a text format that is
  634. **    common to most network utilities.
  635. */
  636. void DecodeRights(char *attrName, char *rightsstring, NWDS_PRIVILEGES    privs)
  637. {
  638.     strset(rightsstring, '\x0');
  639.     strcat(rightsstring, "[");
  640.     if(!strcmp(attrName, "[Entry Rights]"))
  641.     {
  642.         if(privs & 0x01)                            /* DS_ENTRY_BROWSE */
  643.             strcat(rightsstring, "B");
  644.         else
  645.             strcat(rightsstring, " ");
  646.         if(privs & 0x02)                      /* DS_ENTRY_ADD */
  647.             strcat(rightsstring, "A");
  648.         else
  649.             strcat(rightsstring, " ");
  650.         if(privs & 0x04)                      /* DS_ENTRY_DELETE */
  651.             strcat(rightsstring, "D");
  652.         else
  653.             strcat(rightsstring, " ");
  654.         if(privs & 0x08)                      /* DS_ENTRY_RENAME */
  655.             strcat(rightsstring, "R");
  656.         else
  657.             strcat(rightsstring, " ");
  658.         if(privs & 0x10)                      /* DS_ENTRY_SUPERVISOR */
  659.             strcat(rightsstring, "S");
  660.         else
  661.             strcat(rightsstring, " ");
  662.     }
  663.     else
  664.     {
  665.         if(!strcmp(attrName, "[SMS Rights]"))
  666.         {
  667.             if(privs & 0x01)                        /* DS_SMS_SCAN */
  668.                 strcat(rightsstring, "S");
  669.             else
  670.                 strcat(rightsstring, " ");
  671.             if(privs & 0x02)                        /* DS_SMS_BACKUP */
  672.                 strcat(rightsstring, "B");
  673.             else
  674.                 strcat(rightsstring, " ");
  675.             if(privs & 0x04)                        /* DS_SMS_RESTORE */
  676.                 strcat(rightsstring, "R");
  677.             else
  678.                 strcat(rightsstring, " ");
  679.             if(privs & 0x08)                        /* DS_SMS_RENAME */
  680.                 strcat(rightsstring, "C");
  681.             else
  682.                 strcat(rightsstring, " ");
  683.             if(privs & 0x10)                        /* DS_SMS_DELETE */
  684.                 strcat(rightsstring, "D");
  685.             else
  686.                 strcat(rightsstring, " ");
  687.             if(privs & 0x20)                        /* DS_SMS_ADMIN */
  688.                 strcat(rightsstring, "A");
  689.             else
  690.                 strcat(rightsstring, " ");
  691.         }
  692.         else     /* Attribute Rights which applies to all others */
  693.         {
  694.             if(privs & 0x01)                        /* DS_ATTR_COMPARE */
  695.                 strcat(rightsstring, "C");
  696.             else
  697.                 strcat(rightsstring, " ");
  698.             if(privs & 0x02)                        /* DS_ATTR_READ */
  699.                 strcat(rightsstring, "R");
  700.             else
  701.                 strcat(rightsstring, " ");
  702.             if(privs & 0x04)                        /* DS_ATTR_WRITE */
  703.                 strcat(rightsstring, "W");
  704.             else
  705.                 strcat(rightsstring, " ");
  706.             if(privs & 0x08)                        /* DS_ATTR_SELF */
  707.                 strcat(rightsstring, "A");
  708.             else
  709.                 strcat(rightsstring, " ");
  710.             if(privs & 0x20)                        /* DS_ATTR_SUPERVISOR */
  711.                 strcat(rightsstring, "S");
  712.             else
  713.                 strcat(rightsstring, " ");
  714.         }
  715.     }
  716.     strcat(rightsstring,"]\x0");
  717. }
  718.  
  719.  
  720.