home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / addobj.exe / ADDTOSET.C < prev    next >
Text File  |  1995-07-27  |  7KB  |  203 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: ADDTOSET.C
  22. **
  23. **      Desc:   To add or delete a USER from another users SECURITY_EQUALS  
  24. **              property in the bindery.
  25. **
  26. **           
  27. **      Programmers:
  28. **      Ini   Who                     Firm
  29. **      ------------------------------------------------------------------
  30. **      ARM   A. Ray Maxwell          Novell Developer Support.
  31. **
  32. **      History:
  33. **       
  34. **      ------------------------------------------------------------------
  35. **      07-26-95      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>             /* strcpy()                       */
  48.    #include <conio.h>
  49.    #include <ctype.h>              /*toupper()                       */
  50.  
  51.    /*------------------------------------------------------------------
  52.    **      NetWare
  53.    */
  54.    #include <nwcalls.h>
  55.  
  56.    /*------------------------------------------------------------------
  57.    **      Defines
  58.    */
  59.    #define NWDOS
  60.    #define MAXNAME 47
  61.    #define MAXPATH 255
  62.    #define TRUE    1
  63.    #define FALSE   0
  64.  
  65. /****************************************************************************
  66. **      Program Start
  67. */
  68. void main(int argc, char *argv[])
  69. {
  70.    NWCCODE       ccode;
  71.  
  72.    /*------------------------------------------------------------------
  73.    **      NWCreateQueue variables.
  74.    */
  75.    NWCONN_HANDLE  connHandle;
  76.    char           destinationName[MAXNAME+1];
  77.    NWOBJ_TYPE     queueType;
  78.    NWDIR_ID       dirPath;
  79.    char           pathName[MAXPATH+1];
  80.    NWOBJ_ID       queueID;
  81.    char           userName[MAXPATH+1];
  82.    char           serverName[MAXPATH+1];
  83.    char           input;
  84.    int            addflag;
  85.  
  86.  
  87.    if(argc != 4) {
  88.         printf("Usage: ADDPTOSET <servername> <username to add> <username to add to>\n");
  89.         printf("EXAMPLE: SERVER1 SUPERVISOR JOHN\n");
  90.         printf(" This will add security equivalence of supervisor to user john\n");
  91.       exit(1);
  92.     }
  93.     strcpy(serverName,  strupr(argv[1]));
  94.     strcpy(userName, strupr(argv[2]));
  95.     strcpy(destinationName, strupr(argv[3]));
  96.     clrscr();
  97.     printf("(A)dd supervisor to property SECURITY_EQUALS.\n\n");
  98.     printf("(D)elete SUPERVISOR from the property SECURITY_EQUALS.\n");
  99.     input=getch();
  100.  
  101.     if(toupper(input)=='A')
  102.         addflag=TRUE;
  103.     else
  104.         addflag=FALSE;
  105.  
  106.  
  107.     ccode=NWCallsInit(NULL,NULL);
  108.     if (ccode){
  109.         printf("NWCallsInit failed %X\n",ccode);
  110.         exit(1);
  111.     }
  112.     ccode=NWGetConnectionHandle(serverName,NULL,&connHandle,NULL);
  113.     if (ccode){
  114.         printf("NWGetConnectionHandle failed with error code %x\n",ccode);
  115.         exit (ccode);
  116.     }
  117.      if(addflag){
  118.         /*------------------------------------------------------------------
  119.         **      Add the USER to the set of SECURITY_EQUALS in the bindery.
  120.         */
  121.         ccode=NWAddObjectToSet(
  122.                 /* > connection Handle       */  connHandle,
  123.                 /* > name of user to modify  */  destinationName,
  124.                 /* > Object Type             */  OT_USER,
  125.                 /* > Property Name           */  "SECURITY_EQUALS",
  126.                 /* > Member Name being added */  userName,
  127.                 /* > object Type of member   */  OT_USER);
  128.         switch(ccode){
  129.             case 0x0000 : printf("Successfully added %s to %s's SECURITY_EQUALS list\n",
  130.                                         userName,destinationName);
  131.                               break;
  132.             case 0x8996 : printf("Server_OUT_OF_MEMORY\n");
  133.                               break;
  134.             case 0x89E8 : printf("WRITE_PROPERTY_TO_GROUP\n");
  135.                               break;
  136.             case 0x89E9 : printf("MEMBER_ALREADY_EXISTS\n");
  137.                               break;
  138.             case 0x89EA : printf("NO_SUCH_MEMBER\n");
  139.                               break;
  140.             case 0x89EB : printf("NOT_GROUP_PROPERTY\n");
  141.                               break;
  142.             case 0x89EC : printf("NO_SUCH_SEGMENT\n");
  143.                               break;
  144.             case 0x89F0 : printf("WILD_CARD_NOT_ALLOWED\n");
  145.                               break;
  146.             case 0x89F8 : printf("NO_PROPERTY_WRITE_PRIVILEGE\n");
  147.                               break;
  148.             case 0x89FB : printf("NO_SUCH_PROPERTY\n");
  149.                               break;
  150.             case 0x89FC : printf("NO_SUCH_OBJECT\n");
  151.                               break;
  152.             case 0x89FE : printf("DIRECTOYR_LOCKED\n");
  153.                               break;
  154.             case 0x89FF : printf("HARDWARE_FAILURE\n");
  155.                               break;
  156.  
  157.             default     : break;
  158.         }
  159.  
  160.     }
  161.     else{
  162.         /*------------------------------------------------------------------
  163.         **      Delete USER from the set of SECURITY_EQUALS in the bindery.
  164.         */
  165.         ccode=NWDeleteObjectFromSet(
  166.                 /* > connection Handle     */ connHandle,
  167.                 /* > object to delete      */ destinationName,
  168.                 /* > Object Type           */ OT_USER,
  169.                 /* > Property Name         */ "SECURITY_EQUALS",
  170.                 /* > Member to delete      */ userName,
  171.                 /* > object type           */ OT_USER);
  172.         switch(ccode){
  173.             case 0x0000 : printf("Successfully deleted %s from %s's SECURITY_EQUALS list\n",
  174.                                         userName,destinationName);
  175.                               break;
  176.             case 0x8801 : printf("INVALID_CONNECTION\n");
  177.                               break;
  178.             case 0x8996 : printf("Server_OUT_OF_MEMORY\n");
  179.                               break;
  180.             case 0x89EA : printf("NO_SUCH_MEMBER\n");
  181.                               break;
  182.             case 0x89EB : printf("NOT_GROUP_PROPERTY\n");
  183.                               break;
  184.             case 0x89F0 : printf("WILD_CARD_NOT_ALLOWED\n");
  185.                               break;
  186.             case 0x89F4 : printf("NO_OBJECT_DELETE_PRIVILEGE\n");
  187.                               break;
  188.             case 0x89F8 : printf("NO_PROPERTY_WRITE_PRIVILEGE\n");
  189.                               break;
  190.             case 0x89FB : printf("NO_SUCH_PROPERTY\n");
  191.                               break;
  192.             case 0x89FC : printf("NO_SUCH_OBJECT\n");
  193.                               break;
  194.             case 0x89FE : printf("DIRECTOYR_LOCKED\n");
  195.                               break;
  196.             case 0x89FF : printf("HARDWARE_FAILURE\n");
  197.                               break;
  198.  
  199.             default     : break;
  200.         }
  201.     }
  202. }
  203.