home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / lcud.exe / SCANLC.C < prev    next >
C/C++ Source or Header  |  1995-06-23  |  10KB  |  288 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: SCANLC.C
  22. **
  23. **   Desc: This program allows the user to scan the LOGIN_CONTROL of any user.
  24. **         Or the USER_DEFAULTS property of Supervisor.
  25. **
  26. **
  27. **   Programmers:
  28. **   Ini   Who                Firm
  29. **   ------------------------------------------------------------------
  30. **   ARM   A. Ray Maxwell     Novell Developer Support.
  31. **
  32. **   History:
  33. **
  34. **   ------------------------------------------------------------------
  35. **   01-08-94   ARM   First code.
  36. */
  37.  
  38. /***************************************************************************
  39. **   Include headers, macros, function prototypes, etc.
  40. */
  41.  
  42.    /*------------------------------------------------------------------
  43.    **   ANSI
  44.    */
  45.    #include <stdlib.h>          /* exit(), atol()        */
  46.    #include <stdio.h>           /* sprintf()             */
  47.    #include <string.h>
  48.    #include <conio.h>
  49.    /*------------------------------------------------------------------
  50.    **   NetWare
  51.    */
  52.    #include <nwcalls.h>      
  53.     #define NWDOS
  54.    /*------------------------------------------------------------------
  55.    ** Global 
  56.     ** The LOGIN_CONTROL structure is an 86 byte structure that contains
  57.    ** account and password information.  Following is the structure of
  58.    ** the LOGIN_CONTROL property.
  59.    */
  60.  
  61.    typedef struct{
  62.       BYTE accountExpiresYear;
  63.       BYTE accountExpiresMonth;
  64.       BYTE accountExpiresDay;
  65.       BYTE accountExpired;
  66.       BYTE passwordExpiresYear;
  67.       BYTE passwordExpiresMonth;
  68.       BYTE passwordExpiresDay;
  69.       BYTE passwordGraceLogins;
  70.       WORD expirationInterval;
  71.         BYTE graceReset;
  72.       BYTE minimumPasswordLength;
  73.       WORD maxConcurrentConnections;
  74.       BYTE timeBitMap[42];
  75.       BYTE lastLoginDate[6];
  76.         BYTE restrictionFlags;
  77.       BYTE filler;
  78.         LONG maxDiskBlocks;
  79.       WORD badLoginCount;
  80.       LONG nextResetTime;
  81.       BYTE badStationAddress[12];
  82.    } LOGIN_CONTROL;
  83.  
  84. typedef struct
  85. {
  86.    BYTE accountExpiresYear;
  87.    BYTE accountExpiresMonth;
  88.    BYTE accountExpiresDay;
  89.    BYTE restrictionFlags;
  90.    WORD expirationInterval;
  91.    BYTE graceReset;
  92.    BYTE minimumPasswordLength;
  93.    WORD maxConcurrentConnections;
  94.    BYTE timeBitMap[42];
  95.    LONG balance;
  96.    LONG creditLimit;
  97.    LONG maxDiskBlocks;
  98.    BYTE createHomeDir;
  99. } USER_DEFAULTS;
  100.    
  101.     /*-----------------------------------------------------------------------
  102.     ** Prototypes
  103.     */
  104.     void printLoginControl(LOGIN_CONTROL *, char *);
  105.     void printUserDefaults(USER_DEFAULTS *, char *);
  106.  
  107.  
  108. /****************************************************************************
  109. **   Program Start
  110. */
  111. void main(int argc, char *argv[])
  112. {
  113.  
  114.     LOGIN_CONTROL     log;
  115.     USER_DEFAULTS     user;
  116.     NWCONN_HANDLE     connHandle;
  117.     char              objectName[48];
  118.     char              propertyName[48];
  119.     BYTE              propValue[128];
  120.     NWCCODE           ccode;
  121.     BYTE              desiredValue[128];
  122.     long               transferSize;
  123.     char              input='0';
  124.  
  125.     if (argc <= 1){
  126.     printf("\nUsage: SCANLC <object name>\n");
  127.     exit(1);
  128.     }
  129.     while(input<'1' || input>'2'){
  130.         clrscr();
  131.         gotoxy(10,10);
  132.         printf("MENU ENTRY SCREEN");
  133.         gotoxy(10,12);
  134.         printf("1) LOGIN_CONTROL property?");
  135.         gotoxy(10,14);
  136.         printf("2) USER_DEFAULTS property?");
  137.         gotoxy(10,16);
  138.         printf("Choose 1 or 2 > ");
  139.         input=getche();
  140.     }
  141.     strupr(argv[1]);
  142.     strcpy(objectName, argv[1]);
  143.  
  144.     ccode = NWCallsInit(NULL,NULL);
  145.  
  146.     if(ccode){
  147.         printf("NWCallsInit returned: %04X\n",ccode);
  148.         exit(1);
  149.     }
  150.  
  151.     ccode = NWGetDefaultConnectionID(&connHandle);
  152.  
  153.     if(ccode){
  154.         printf("Call to NWGetDefaultConnectionID failed!! Code %04X\n", ccode);
  155.         exit(1);
  156.     }
  157.  
  158.     switch(input){
  159.         case '1' : strcpy(propertyName,"LOGIN_CONTROL");
  160.  
  161.                       break;
  162.         case '2' : strcpy(propertyName,"USER_DEFAULTS");
  163.                       transferSize=sizeof(USER_DEFAULTS);
  164.  
  165.                       break;
  166.         default  : printf("should never get here debug our code");
  167.                       exit(1);
  168.     }
  169.     memset(propValue,'\0',sizeof(propValue));
  170.  
  171.    clrscr();
  172.     ccode=NWReadPropertyValue(
  173.             /* > Conn Handle  */ connHandle,
  174.             /* > object name  */ objectName,
  175.             /* > object type  */ OT_USER,
  176.             /* > property Name*/ propertyName,
  177.             /* > data set indx*/ 1,
  178.             /* < Data Buffer  */ propValue,
  179.             /* < More flag    */ NULL,
  180.             /* < Property Flgs*/ NULL);
  181.  
  182.     if (ccode==0x89FC){
  183.         clrscr();
  184.         printf("There is no property found error code %X returned\n",ccode);
  185.         exit(1);
  186.     }
  187.     else if (ccode){
  188.         printf("\nNWReadPropertyValue returned: %04X", ccode);
  189.         exit(1);
  190.     }
  191.     switch(input){
  192.         case '1' : transferSize=sizeof(LOGIN_CONTROL);
  193.                       memmove (&log,propValue,transferSize);
  194.                       printLoginControl(&log, objectName);
  195.                       break;
  196.         case '2' : transferSize=sizeof(USER_DEFAULTS);
  197.                       memmove (&user,propValue,transferSize);
  198.                       printUserDefaults(&user, objectName);
  199.                       break;
  200.  
  201.         default  : printf("should never get here debug our code");
  202.                       exit(1);
  203.     }
  204. }
  205.  
  206. /***************************************************************************
  207. ** Prints out the USER_DEFAULTS property values.
  208. */
  209. void printUserDefaults(USER_DEFAULTS *user, char *objectName)
  210. {
  211.     int i;
  212.     int count=0;
  213.  
  214.     printf("         VALUES IN THE USER_DEFAULTS PROPERTY for: %s\n\n",objectName);
  215.     printf("accountExpiresYear       :  %02d\n",user->accountExpiresYear);
  216.     printf("accountExpiresMonth      :  %02d\n",user->accountExpiresMonth);
  217.     printf("accountExpiresDay        :  %02d\n",user->accountExpiresDay);
  218.     printf("restrictionFlags         :  %02X\n",user->restrictionFlags);
  219.     printf("expirationInterval       :  %02d\n",NWWordSwap(user->expirationInterval));
  220.     printf("graceReset               :  %02d\n",user->graceReset);
  221.     printf("minimumPasswordLength    :  %02d\n",user->minimumPasswordLength);
  222.     printf("maxConcurrentConnections :  %02d\n",NWWordSwap(user->maxConcurrentConnections));
  223.     printf("timeBitMap[42]           :  ");
  224.     for(i=0;i<42;i++){
  225.         printf("%02X",strtol(&(user->timeBitMap[i]),(char**)NULL,16));
  226.         count++;
  227.         if (count==21){
  228.             printf("\n                            ");
  229.             count=0;
  230.         }
  231.     }
  232.  
  233.     printf("\nbalance                  :  %04X\n",user->balance);
  234.     printf("creditLimit              :  %04X\n",user->creditLimit);
  235.     printf("maxDiskBlocks            :  %04X\n",user->maxDiskBlocks);
  236.     printf("createHomeDir            :  %02X\n",user->createHomeDir);
  237. }
  238.  
  239. /***************************************************************************
  240. ** Prints out the LOGIN_CONTROL property values.
  241. */
  242. void printLoginControl(LOGIN_CONTROL *log, char *objectName)
  243. {
  244.     int i;
  245.     int count=0;
  246.  
  247.     printf("         VALUES IN THE LOGIN_CONTROL PROPERTY for: %s\n",objectName);
  248.     printf("accountExpiresYear       :  %02d\n",log->accountExpiresYear);
  249.     printf("accountExpiresMonth      :  %02d\n",log->accountExpiresMonth);
  250.     printf("accountExpiresDay        :  %02d\n",log->accountExpiresDay);
  251.     printf("accountExpired           :  %02X\n",log->accountExpired);
  252.     printf("passwordExpiresYear      :  %02d\n",log->passwordExpiresYear);
  253.     printf("passwordExpiresMonth     :  %02d\n",log->passwordExpiresMonth);
  254.     printf("passwordExpiresDay       :  %02d\n",log->passwordExpiresDay);
  255.     printf("passwordGraceLogins      :  %02d\n",log->passwordGraceLogins);
  256.     printf("expirationInterval       :  %02d\n",NWWordSwap(log->expirationInterval));
  257.     printf("graceReset               :  %02d\n",log->graceReset);
  258.     printf("minimumPasswordLength    :  %02d\n",log->minimumPasswordLength);
  259.     printf("maxConcurrentConnections :  %02d\n",NWWordSwap(log->maxConcurrentConnections));
  260.     printf("timeBitMap[42]           :  ");
  261.     for(i=0;i<42;i++){
  262.         printf("%02X",strtol(&(log->timeBitMap[i]),(char**)NULL,16));
  263.         count++;
  264.         if (count==22){
  265.             printf("\n                            ");
  266.             count=0;
  267.         }
  268.     }
  269.     printf("\nlastLoginDate[6]         :");
  270.     printf(" %2d/%2d/%2d   %2d:%2d:%2d\n",
  271.         log->lastLoginDate[1],
  272.         log->lastLoginDate[2],
  273.         log->lastLoginDate[0],
  274.         log->lastLoginDate[3],
  275.         log->lastLoginDate[4],
  276.         log->lastLoginDate[5]);
  277.     printf("restrictionFlags         :  %02X\n",log->restrictionFlags);
  278.     printf("filler                   :  %02X\n",log->filler);
  279.     printf("maxDiskBlocks            :  %04X\n",log->maxDiskBlocks);
  280.     printf("badLoginCount            :  %02d\n",NWWordSwap(log->badLoginCount));
  281.     printf("nextResetTime            :  %04X Number of minute from jan 1 1985\n"
  282.                                                     ,log->nextResetTime);
  283.     printf("badStationAddress[12]    :  ");
  284.     for(i=0;i<12;i++){
  285.         printf("%02X",strtol(&(log->badStationAddress[i]),(char**)NULL,16));
  286.     }
  287. }
  288.