home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / getid.exe / GETID.C next >
Text File  |  1995-08-07  |  4KB  |  116 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: GETID.C
  22. **
  23. **   Desc: Gets a users objectID. It is then printed it to the screen,
  24. **           in a long and also converts it to a character string.
  25. **         This code is written to help programers understand how to
  26. **         read the objectID from the bindery and put it into the format
  27. **         they would need to say: create a mail directory.
  28. **
  29. **   Programmers:
  30. **   Ini   Who                Firm
  31. **   ------------------------------------------------------------------
  32. **   ARM   A. Ray Maxwell     Novell Developer Support.
  33. **
  34. **   History:
  35. **
  36. **   ------------------------------------------------------------------
  37. **   08-07-95   ARM   First code.
  38. */
  39.  
  40. /***************************************************************************
  41. **   Include headers, macros, function prototypes, etc.
  42. */
  43.  
  44.    /*------------------------------------------------------------------
  45.    **   ANSI
  46.    */
  47.    #include <stdlib.h>          /* exit(), atol()        */
  48.    #include <stdio.h>           /* printf()              */
  49.    #include <string.h>          /* strcpy()              */
  50.    #include <conio.h>           /* clrscr()              */
  51.    /*------------------------------------------------------------------
  52.    **   NetWare
  53.    */
  54.    #include <nwcalls.h>
  55.  
  56.  
  57.  
  58. /****************************************************************************
  59. **   Program Start
  60. */
  61. void main(int argc, char *argv[])
  62. {
  63.    NWCONN_HANDLE   connHandle;
  64.    DWORD           swapID;
  65.    NWOBJ_ID        objectID;
  66.    NWCCODE         ccode;
  67.    char            server[50];
  68.    char            objectName[48];
  69.    char             object[48];
  70.  
  71.    if(argc <= 2) 
  72.    {
  73.       printf("Usage: GETID <server> <object Name>\n\n");
  74.       exit(1);
  75.    }
  76.  
  77.    strcpy(server,    strupr(argv[1]));
  78.    strcpy(objectName,strupr(argv[2]));
  79.  
  80.    ccode = NWCallsInit(NULL, NULL);
  81.  
  82.    if(ccode)
  83.       exit(1);
  84.  
  85.    ccode = NWGetConnectionHandle(
  86.            /* > servername        */ server,
  87.            /*   Novell Reserved1  */ 0,
  88.            /* < connection Handle */ &connHandle,
  89.            /*   Novell Reserved2  */ NULL);
  90.    if(ccode)
  91.    {
  92.       printf("NWGetConnectionHandle failed %X\n",ccode);
  93.       exit(1);
  94.    }
  95.  
  96.    ccode=NWGetObjectID(
  97.          /* > connection Handle        */ connHandle,
  98.          /* > object Name              */ objectName,
  99.          /* > objectType               */ OT_USER,
  100.          /* < object ID                */ &objectID);
  101.    if(ccode)
  102.    {
  103.       printf("NWGetObjectID failed %X\n",ccode);
  104.       exit(1);
  105.    }
  106.    
  107.    swapID=NWLongSwap(objectID);
  108.    ltoa(swapID,object,16);
  109.    clrscr();
  110.    printf("This is the objectID in String form %s\n\n",strupr(object));
  111.  
  112.    printf("Object Name= %s   Object ID = %08lX\n",
  113.          objectName,
  114.          NWLongSwap(objectID));
  115. }
  116.