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

  1. /*  This will only login to a bindery server  */
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <alloc.h>
  7. #include <conio.h>
  8. #include <nwcalls.h>
  9.  
  10. void main (int argc, char *argv[])
  11. {
  12.     NWCONN_HANDLE     connHandle;
  13.     NWCCODE        ccode;
  14.  
  15.     char    server[100], user[100], password[100];
  16.     int i;
  17.  
  18.     if (argc != 3)
  19.     {
  20.         printf ("Usage:  NWLOGIN <server name> <user name>");
  21.         return;
  22.     }
  23.  
  24.     ccode = NWCallsInit (NULL,NULL);
  25.     if (ccode) return;
  26.  
  27.     strcpy (server, strupr (argv[1]));
  28.     strcpy (user, strupr (argv[2]));
  29.  
  30.     ccode = NWAttachToFileServer (argv[1], 0, &connHandle);
  31.  
  32.     if ((ccode != 0) && (ccode != 0x8800))
  33.     {
  34.         printf ("NWAttachToFileServer returned error %04X\n", ccode);
  35.         return;
  36.     }
  37.  
  38.     printf ("Password:  ");
  39.  
  40.     i = 0;
  41.  
  42.     do
  43.     {
  44.         password[i] = getch ();
  45.         putch ('*');
  46.         i++;
  47.     } while (password[i-1] != '\r');
  48.     password[i-1] = '\x0';
  49.  
  50.     printf ("\n\n");
  51.  
  52.     ccode = NWLoginToFileServer (connHandle, user, OT_USER, password);
  53.     if (ccode)
  54.     {
  55.         printf ("NWLoginToFileServer returned %X\n", ccode);
  56.         return;
  57.     }
  58.  
  59.     printf ("You are logged into server %s\n", argv[1]);
  60. }