home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dynobj.exe / DSOBJSCN.C next >
Text File  |  1994-09-09  |  3KB  |  137 lines

  1. /****************************************************************************
  2. ** Programmed by: Karl Bunnell
  3. **    Description  : This program will display all of the dynamic server objects 
  4. **                     a directory service server is aware of.
  5. **                
  6. **                
  7. ** Date             :08/09/94    
  8. */
  9.  
  10. #define NWDOS
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <nwcalls.h>
  14. #include <nwnet.h>
  15.  
  16.  
  17. void main(void)
  18. {
  19.       NWCONN_HANDLE         connHandle;
  20.     char            serverName[48];
  21.     char            objectName[47+1];
  22.     BYTE            propValue[128];
  23.     NWOBJ_ID        objectID = -1;
  24.     NWCCODE            cCode, cCode2;
  25.     BYTE            netAddress[12];
  26.     int            i;
  27.  
  28.       cCode = NWCallsInit(NULL,NULL);
  29.  
  30.       if(cCode)
  31.         {
  32.           printf("NWCallsInit returned: %04X\n",cCode);
  33.         exit(1);
  34.         }
  35.  
  36.     /*------------------------------------------------------------------------
  37.     ** Use NWGetNearestDirectoryService to retrieve a handle to a NDS server.
  38.     */
  39.  
  40.     cCode = NWGetNearestDirectoryService(
  41.                 /* > Connection Handle    */ &connHandle
  42.                 );
  43.  
  44.     switch (cCode)
  45.         {
  46.         case 0x8846:
  47.             printf("\nNo Directory Services Connection!\n");
  48.                         exit(1);
  49.  
  50.         default:
  51.             printf("\nNWGetNearestDirectoryService returned %04X\n", cCode);
  52.                         
  53.         }
  54.  
  55.     /*------------------------------------------------------------------------
  56.     ** Display Name of Nearest Directory Services File Server
  57.     */
  58.  
  59.     NWGetFileServerName(
  60.         /* Conn handle */ connHandle,
  61.         /* Server name */ serverName
  62.         );
  63.  
  64.     printf("\nNearest Response: %s\n", serverName);
  65.  
  66.     printf("\nServers...\n");
  67.  
  68.     printf("     Server Names                             Network:Node:Socket\n");
  69.     printf("     ------------                             -------------------\n");
  70.  
  71.     /*------------------------------------------------------------------------
  72.     ** Iteratively scan until all objects are found.
  73.     ** Note: The rights required to scan dynamic objects is BS_ANY_READ.
  74.     **         This means - access allowed to all clients, even if the client
  75.     **            is not logged in to the server.
  76.     **            This scan will work even if the Bindery Context is not set.
  77.     **         Bindery context is NOT set if it is set to the ROOT of the
  78.     **            DS tree.
  79.     */
  80.  
  81.     while(!cCode)
  82.         {
  83.         cCode =         NWScanObject(
  84.                     /* > Conn handle */ connHandle,
  85.                     /* > search name */ "*",
  86.                     /* > search type */ OT_FILE_SERVER,
  87.                     /* <>object ID   */ &objectID,
  88.                     /* < object name */ objectName,
  89.                     /* < object type */ NULL,
  90.                     /* < object prop */ NULL,
  91.                     /* < object flag */ NULL,
  92.                     /* < object sec  */ NULL
  93.                     );
  94.         
  95.         if (!cCode)
  96.             {
  97.             cCode2 = NWReadPropertyValue(
  98.                         /* > Conn Handle  */ connHandle,
  99.                         /* > object name  */ objectName,
  100.                         /* > object type  */ OT_FILE_SERVER,
  101.                         /* > property Name*/ "NET_ADDRESS",
  102.                         /* > data set indx*/ 1,
  103.                         /* < Data Buffer  */ propValue,
  104.                         /* < More flag    */ NULL,
  105.                         /* < Property Flgs*/ NULL
  106.                         );
  107.  
  108.             if (cCode2)
  109.                 {
  110.                 printf("\nNWReadPropertyValue returned: %04X", cCode);
  111.                 exit(1);
  112.                 }
  113.  
  114.             for (i=0; i<12; ++i)         // Not necessary, but nice.
  115.                 netAddress[i] = (BYTE)propValue[i];
  116.  
  117.             }
  118.             printf("%-47s%02X%02X%02X%02X:%02X%02X%02X%02X%02X%02X:%02X%02X\n",
  119.             objectName, 
  120.             netAddress[0],
  121.             netAddress[1],
  122.             netAddress[2],
  123.             netAddress[3],
  124.                 netAddress[4],
  125.             netAddress[5],
  126.             netAddress[6],
  127.             netAddress[7],
  128.             netAddress[8],
  129.             netAddress[9],
  130.             netAddress[10],
  131.             netAddress[11]
  132.             );
  133.  
  134.         }
  135.  
  136. }
  137.