home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dsdelu.exe / DELUSER.C next >
C/C++ Source or Header  |  1995-04-12  |  5KB  |  195 lines

  1. /****************************************************************************
  2. **    File:    DELUSER.C
  3. **
  4. **    Desc:    Deletes objects in the Tree
  5. **
  6. **            This was designed only to delete "User" Objects from the tree.
  7. **
  8. **
  9. **        DISCLAIMER
  10. **
  11. **    Novell, Inc. makes no representations or warranties with respect to
  12. **    any NetWare software, and specifically disclaims any express or
  13. **    implied warranties of merchantability, title, or fitness for a
  14. **    particular purpose.
  15. **
  16. **    Distribution of any NetWare software is forbidden without the
  17. **    express written consent of Novell, Inc.  Further, Novell reserves
  18. **    the right to discontinue distribution of any NetWare software.
  19. **
  20. **    Novell is not responsible for lost profits or revenue, loss of use
  21. **    of the software, loss of data, costs of re-creating lost data, the
  22. **    cost of any substitute equipment or program, or claims by any party
  23. **    other than you.  Novell strongly recommends a backup be made before
  24. **    any software is installed.   Technical support for this software
  25. **    may be provided at the discretion of Novell.
  26. **
  27. **    Programmers:
  28. **
  29. **        Ini    Who                                Firm
  30. **        --- ----------------- ------------------------------------------------
  31. **        CRG    Calvin Gaisford        Novell Developer Support.
  32. **
  33. **    History:
  34. **
  35. **        When         Who What
  36. **        -------- --- ---------------------------------------------------------
  37. **        10-21-94 CRG First code.
  38. */
  39.  
  40.  
  41.  
  42. /***************************************************************************
  43. **  Libraries Linked in for .exe
  44. **
  45. **  NWCALLS.LIB
  46. **  NWLOCALE.LIB
  47. **  NWNET.LIB
  48. **
  49. */
  50.  
  51.  
  52. /***************************************************************************
  53. **  #defines
  54. */
  55. #define FAILURE  0xFF
  56. #define SUCCESS  0x00
  57.  
  58.  
  59. /****************************************************************************
  60. **    Include headers, macros, etc.
  61. */
  62.  
  63.     /*-----------------------------------------------------------------------
  64.     **    ANSI
  65.     */
  66.     #include <stdio.h>
  67.     #include <stdlib.h>
  68.     #include <string.h>
  69.  
  70.  
  71.     /*-----------------------------------------------------------------------
  72.     **    NetWare
  73.     */
  74.     #include <nwnet.h>
  75.     #include <nwcalls.h>
  76.     #include <nwlocale.h>
  77.  
  78.     /*-----------------------------------------------------------------------
  79.     **    Program Global storage
  80.     */
  81.     struct
  82.     {
  83.         NWDSContextHandle context;
  84.     }gs;
  85.  
  86.     extern unsigned _stklen=8000;
  87.  
  88.  
  89. /***************************************************************************
  90. **    Function Prototypes
  91. */
  92. void Proc(void);
  93. void FatalError(int errorCode);
  94. void InitDS(void);
  95. int  UninitDS(void);
  96.  
  97.  
  98. /***************************************************************************
  99. **    Main Program
  100. */
  101. void main(void)
  102. {
  103.     InitDS();
  104.     Proc();
  105.     UninitDS();
  106. }
  107.  
  108.  
  109. /***************************************************************************
  110. **    This will prompt users for login names to remove a user from the tree.
  111. */
  112. void Proc(void)
  113. {
  114.     NWDSCCODE            ccode;
  115.     char                    objectName[MAX_DN_CHARS];
  116.  
  117.     printf("Login Name: ");
  118.     gets(objectName);
  119.     strcat(objectName,"\x0");
  120.  
  121.     ccode = NWDSRemoveObject(gs.context, objectName);
  122.     if(ccode)
  123.         printf("NWDSRemoveObject returned %X\n", ccode);
  124.     else
  125.         {
  126.             printf("Object \"%s\"successfully removed\n", objectName);
  127.         }
  128. }
  129.  
  130.  
  131.  
  132. /***************************************************************************
  133. **    FatalError is the common exit point for errors.
  134. */
  135. void FatalError(int errorCode)
  136. {
  137.         exit(errorCode);
  138. }
  139.  
  140.  
  141.  
  142. /***************************************************************************
  143. **    Establish context.  These are the standard initializations for DS calls
  144. */
  145. void InitDS(void)
  146. {
  147.     NWDSCCODE dsCcode;
  148.     LCONV            lconvInfo;
  149.  
  150.     dsCcode=NWCallsInit(NULL,NULL);
  151.     if(dsCcode)          /* initialize allowing to call nwcalls functions */
  152.     {
  153.         printf("FatalError during NWCallsInit %X\n",dsCcode);
  154.         FatalError(FAILURE);
  155.     }
  156.     NWLlocaleconv(&lconvInfo);
  157.     dsCcode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
  158.     if(dsCcode)
  159.     {
  160.         printf("NWInitUnicodeTables() returned: %X\n", dsCcode);
  161.         FatalError(FAILURE);
  162.     }
  163.     gs.context=NWDSCreateContext();
  164.     if(gs.context)
  165.     {
  166.         printf("FatalError during NWDSCreateContext %X\n",gs.context);
  167.         FatalError(FAILURE);
  168.     }
  169. }
  170.  
  171.  
  172.  
  173. /***************************************************************************
  174. **    Release context and clean up.
  175. */
  176. int UninitDS()
  177. {
  178.     NWDSCCODE dsCcode;
  179.  
  180.     dsCcode=NWDSFreeContext(gs.context);
  181.     if(dsCcode)
  182.     {
  183.         printf("FatalError during NWDSFreeContext %X\n",dsCcode);
  184.         FatalError (FAILURE);
  185.     }
  186.     dsCcode=NWFreeUnicodeTables();
  187.     if(dsCcode)
  188.     {
  189.         printf("Error during NWFreeUnicodeTables()\n");
  190.         FatalError (FAILURE);
  191.     }
  192.     return(0);
  193. }
  194.  
  195.