home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / chgpss.exe / CHGPASS.C next >
Text File  |  1995-01-07  |  4KB  |  120 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:   CHGPASS.C
  22. **
  23. **   Description: Program allows the user (supervisor) to change a password.
  24. **
  25. **
  26. **   Parameter descriptions:    > input
  27. **                              < output
  28. **
  29. **        
  30. **   Programmers:
  31. **   Ini    Who             Firm
  32. **   -------------------------------------------------------------------
  33. **   ARM    A. Ray Maxwell  Novell Developer Support.
  34. **
  35. **   History:
  36. **       
  37. **   -------------------------------------------------------------------
  38. **   08-12-94   ARM   First code.
  39. */
  40.  
  41. /***********************************************************************
  42. ** Include Headers, Macros & function Prototypes.
  43. */
  44.    /*-------------------------------------------------------------------
  45.    **   ANSI
  46.    */
  47.    #include <stdio.h>
  48.    #include <stdlib.h>
  49.    #include <string.h>
  50.    #include <conio.h>
  51.  
  52.    #define RETURN '\r'
  53.  
  54.    /*-------------------------------------------------------------------
  55.    ** NetWare 
  56.    */
  57.    #include <nwcalls.h>
  58.    
  59.    /*-------------------------------------------------------------------
  60.    ** Defines
  61.    */
  62.    #define NWDOS
  63.  
  64.    /*-------------------------------------------------------------------
  65.    ** Prototypes
  66.    */
  67.  
  68.  
  69. /***********************************************************************
  70. ** Program start.
  71. */
  72. void main(int argc, char *argv[ ])
  73. {
  74.    NWCONN_HANDLE   connHandle;
  75.    NWCCODE         ccode;
  76.    char            server[50],
  77.                    objectName[50],
  78.                    password[128],
  79.                    oldPassword[128],
  80.                    newPassword[128];
  81.  
  82.    if(argc != 4) {
  83.    clrscr();
  84.       printf("Usage: CHGPASS <server name> <username> <new password>\n");
  85.       printf("Note: must be logged into server you change password on.\n");
  86.       exit(1);
  87.    }
  88.  
  89.    oldPassword[0] = NULL; /* you can also enter the old password    */
  90.    strcpy(server,strupr(argv[1]));      /* servers name             */
  91.    strcpy(objectName, strupr(argv[2])); /* user name is upper case  */
  92.    strcpy(newPassword,strupr(argv[3])); /* password is upper case   */
  93.  
  94.  
  95.    ccode = NWCallsInit(NULL, NULL);
  96.    if(ccode){
  97.       printf ("NWCallsInit failed with error=%X\n",ccode);
  98.       exit(1);
  99.    }
  100.  
  101.    ccode = NWGetConnectionHandle(server, 0, &connHandle, NULL);
  102.    if(ccode){
  103.       printf("NWGetConnectionHandle failed with error=%X\n",ccode);
  104.       exit(1);
  105.    }
  106.  
  107.    ccode = NWChangeObjectPassword(
  108.            /* > connection Handle    */ connHandle,
  109.            /* > user name            */ objectName,
  110.            /* > Bindery object       */ OT_USER,
  111.            /* > Old password or NULL */ oldPassword,
  112.            /* > New password         */ newPassword);
  113.    if(ccode){
  114.       printf ("NWChangObjectPassword failed with errror=%X\n",ccode);
  115.       exit(1);
  116.    }
  117.  
  118. }
  119.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
  120.