home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / prtown.exe / PRTOWNER.C < prev    next >
C/C++ Source or Header  |  1995-01-23  |  7KB  |  237 lines

  1. /****************************************************************************
  2. **      DISCLAIMER  
  3. **  
  4. **   Novell, Inc. makes no representations or warranties with respect to
  5. **   any NetWare software, and specifically disclaims any express or
  6. **   implied warranties of merchantability, title, or fitness for a
  7. **   particular purpose.  
  8. **
  9. **   Distribution of any NetWare software is forbidden without the
  10. **   express written consent of Novell, Inc.  Further, Novell reserves
  11. **   the right to discontinue distribution of any NetWare software.
  12. **   
  13. **   Novell is not responsible for lost profits or revenue, loss of use
  14. **   of the software, loss of data, costs of re-creating lost data, the
  15. **   cost of any substitute equipment or program, or claims by any party
  16. **   other than you.  Novell strongly recommends a backup be made before
  17. **   any software is installed.   Technical support for this software
  18. **   may be provided at the discretion of Novell.
  19. ****************************************************************************
  20. **
  21. **   File: PRTOWNER.C
  22. **
  23. **   Desc: Allows the user to find out who owns printjobs in the 4.X
  24. **         print queue and what the printjob number is (same number that
  25. **         shows up in pconsole).
  26. **
  27. **   Programmers:
  28. **   Ini   Who                Firm
  29. **   ------------------------------------------------------------------
  30. **   ARM   A. Ray Maxwell     Novell Developer Support.
  31. **
  32. **   History:
  33. **
  34. **   ------------------------------------------------------------------
  35. **   01-20-95   ARM   First code.
  36. */
  37.  
  38. /****************************************************************************
  39. **   Include headers, macros, function prototypes, etc.
  40. */
  41.  
  42.    /*------------------------------------------------------------------------
  43.    **   Macros
  44.    */
  45.    #define NWDOS
  46.  
  47.    /*------------------------------------------------------------------------
  48.    **   ANSI
  49.    */
  50.    #include <stdio.h>
  51.    #include <string.h>
  52.    #include <stdlib.h>
  53.    #include <conio.h>   /* getche()   */
  54.    #include <mem.h>     /* setmem()   */
  55.  
  56.    /*------------------------------------------------------------------------
  57.    **   NetWare
  58.    */
  59.    #include <nwnet.h>
  60.    #include <nwcalls.h>
  61.    #include <nwlocale.h>
  62.  
  63.    extern unsigned _stklen = (1024 * 8);
  64.  
  65. /****************************************************************************
  66. **   Function main() contains the entire program.
  67. **
  68. */
  69.  
  70.  
  71. void main(void)
  72. {
  73.   NWDSContextHandle  dContext;
  74.   NWDSCCODE          ccode;
  75.   NWCONN_HANDLE      connHandle;
  76.   NWOBJ_ID           objectID;
  77.   NWQueueJobStruct   job;
  78.   NWNUM              startPosition=0;
  79.   QueueJobListReply  jobList;
  80.   char               *ptr;
  81.   char               objectName[MAX_DN_CHARS],
  82.                      queueName[128],
  83.                      userName[128];
  84.   char               ch;
  85.   WORD               listNumber=0;
  86.   LCONV              lconvInfo;
  87.  
  88.  
  89.     ccode = NWCallsInit(NULL,NULL);
  90.     printf("NWCallsInit() = %04X\n",ccode);
  91.     if(ccode)
  92.         exit(1);
  93.  
  94.     NWLsetlocale(LC_ALL, "");
  95.     printf("\nNWLsetl.. OK");
  96.  
  97.    NWLlocaleconv(&lconvInfo);
  98.    printf("\nCountry ID = %03d, Code Page = %04d\n",
  99.             lconvInfo.country_id, lconvInfo.code_page);
  100.  
  101.    ccode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
  102.  
  103.    printf("NWInitUnicodeTables() = %04X\n",ccode);
  104.    if(ccode){
  105.       NWFreeUnicodeTables();
  106.       exit(1);
  107.    }
  108.  
  109.  
  110.         dContext = NWDSCreateContext();
  111.       printf("NWDSCreateContext() = %04X\n",dContext);
  112.  
  113.    if(dContext == ERR_CONTEXT_CREATION){
  114.       NWFreeUnicodeTables();
  115.       NWDSFreeContext(dContext);
  116.       exit(1);
  117.    }
  118.  
  119.  
  120.    queueName[0] = '\0';
  121.    printf("\nQueue Name: ");
  122.    setmem(&job,sizeof(NWQueueJobStruct),'\0');
  123.    setmem(&jobList,sizeof(QueueJobListReply),'\0');
  124.  
  125.    ptr = queueName;
  126.  
  127.    do{
  128.       ch = getche();
  129.       *ptr = ch;
  130.       ptr++;
  131.    } while (ch != '\r');
  132.  
  133.    ptr = ptr - 1;
  134.    *ptr = '\0';
  135.  
  136.    printf("\nAttempting Change User password... \n");
  137.  
  138.    ccode = NWGetNearestDirectoryService(
  139.             /* > Connection Handle    */ &connHandle
  140.             );
  141.  
  142.    printf("\nNWGetNearestDirectoryService returned: %04X\n", ccode);
  143.  
  144.    ccode=NWDSMapNameToID(
  145.             /* > NWDSContextHandle   */ dContext,
  146.          /* > connection handle   */ connHandle,
  147.          /* > object name         */ queueName,
  148.          /* < pointer to objectID */ &objectID);
  149.    if(ccode){
  150.       printf("NWDSMapNameToID returned: %04X\n",ccode);
  151.       NWFreeUnicodeTables();
  152.       exit(1);
  153.    }
  154.  
  155.    ccode=NWGetQueueJobList2(
  156.          /* > connection Handle            */ connHandle,
  157.          /* > bindery object ID            */ objectID,
  158.          /* > position of netx job         */ startPosition,
  159.          /* < pointer to array of job nums */ &jobList);
  160.  
  161.    if(ccode){
  162.       printf("NWDGetQueueJobList2 returned: %04X\n",ccode);
  163.       NWFreeUnicodeTables();
  164.       exit(1);
  165.    }
  166.  
  167.     if(jobList.totalQueueJobs == 0)
  168.         printf("No jobs in queue: program terminated\n");
  169.     else
  170.         /*-------------------------------------------------------------------
  171.         ** Read throught the queue jobs in the queue and report back the sub-
  172.         ** mitters name and the job number.
  173.         */
  174.         do{
  175.             ccode=NWReadQueueJobEntry2(
  176.                     /* > connection handle   */ connHandle,
  177.                     /* > objectID            */ objectID,
  178.                     /* > jobNumber           */ jobList.jobNumberList[listNumber],
  179.                     /* < NWQueueJobStruct    */ &job);
  180.  
  181.             if(ccode){
  182.                 printf("NWReadQueueJobEntry2 returned: %04X\n",ccode);
  183.                 NWFreeUnicodeTables();
  184.                 exit(1);
  185.             }
  186.  
  187.             ccode=NWDSMapIDToName(
  188.                     /* > context                           */ dContext,
  189.                     /* > connection handle                 */ connHandle,
  190.                     /* > object ID                         */ job.clientID,
  191.                     /* < pointer object distinguished name */ userName);
  192.  
  193.             if(ccode){
  194.                 printf("NWDSMapIDToName returned: %04X\n",ccode);
  195.                 NWFreeUnicodeTables();
  196.                 exit(1);
  197.             }
  198.  
  199.             printf(" Jobnumber: %08lX \n",jobList.jobNumberList[listNumber]);
  200.             printf(" User submitting job: %s\n",userName);
  201.             listNumber++;
  202.         }while(listNumber<jobList.totalQueueJobs);
  203.  
  204.     NWFreeUnicodeTables();
  205.     NWDSFreeContext(dContext);
  206. }
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.                                                                                                                                                                
  235.  
  236.                                                                                                                                                                                                  
  237.