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 >
Wrap
Text File
|
1995-07-27
|
7KB
|
203 lines
/****************************************************************************
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
****************************************************************************
**
** File: ADDTOSET.C
**
** Desc: To add or delete a USER from another users SECURITY_EQUALS
** property in the bindery.
**
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 07-26-95 ARM First code.
*/
/***************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strcpy() */
#include <conio.h>
#include <ctype.h> /*toupper() */
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
/*------------------------------------------------------------------
** Defines
*/
#define NWDOS
#define MAXNAME 47
#define MAXPATH 255
#define TRUE 1
#define FALSE 0
/****************************************************************************
** Program Start
*/
void main(int argc, char *argv[])
{
NWCCODE ccode;
/*------------------------------------------------------------------
** NWCreateQueue variables.
*/
NWCONN_HANDLE connHandle;
char destinationName[MAXNAME+1];
NWOBJ_TYPE queueType;
NWDIR_ID dirPath;
char pathName[MAXPATH+1];
NWOBJ_ID queueID;
char userName[MAXPATH+1];
char serverName[MAXPATH+1];
char input;
int addflag;
if(argc != 4) {
printf("Usage: ADDPTOSET <servername> <username to add> <username to add to>\n");
printf("EXAMPLE: SERVER1 SUPERVISOR JOHN\n");
printf(" This will add security equivalence of supervisor to user john\n");
exit(1);
}
strcpy(serverName, strupr(argv[1]));
strcpy(userName, strupr(argv[2]));
strcpy(destinationName, strupr(argv[3]));
clrscr();
printf("(A)dd supervisor to property SECURITY_EQUALS.\n\n");
printf("(D)elete SUPERVISOR from the property SECURITY_EQUALS.\n");
input=getch();
if(toupper(input)=='A')
addflag=TRUE;
else
addflag=FALSE;
ccode=NWCallsInit(NULL,NULL);
if (ccode){
printf("NWCallsInit failed %X\n",ccode);
exit(1);
}
ccode=NWGetConnectionHandle(serverName,NULL,&connHandle,NULL);
if (ccode){
printf("NWGetConnectionHandle failed with error code %x\n",ccode);
exit (ccode);
}
if(addflag){
/*------------------------------------------------------------------
** Add the USER to the set of SECURITY_EQUALS in the bindery.
*/
ccode=NWAddObjectToSet(
/* > connection Handle */ connHandle,
/* > name of user to modify */ destinationName,
/* > Object Type */ OT_USER,
/* > Property Name */ "SECURITY_EQUALS",
/* > Member Name being added */ userName,
/* > object Type of member */ OT_USER);
switch(ccode){
case 0x0000 : printf("Successfully added %s to %s's SECURITY_EQUALS list\n",
userName,destinationName);
break;
case 0x8996 : printf("Server_OUT_OF_MEMORY\n");
break;
case 0x89E8 : printf("WRITE_PROPERTY_TO_GROUP\n");
break;
case 0x89E9 : printf("MEMBER_ALREADY_EXISTS\n");
break;
case 0x89EA : printf("NO_SUCH_MEMBER\n");
break;
case 0x89EB : printf("NOT_GROUP_PROPERTY\n");
break;
case 0x89EC : printf("NO_SUCH_SEGMENT\n");
break;
case 0x89F0 : printf("WILD_CARD_NOT_ALLOWED\n");
break;
case 0x89F8 : printf("NO_PROPERTY_WRITE_PRIVILEGE\n");
break;
case 0x89FB : printf("NO_SUCH_PROPERTY\n");
break;
case 0x89FC : printf("NO_SUCH_OBJECT\n");
break;
case 0x89FE : printf("DIRECTOYR_LOCKED\n");
break;
case 0x89FF : printf("HARDWARE_FAILURE\n");
break;
default : break;
}
}
else{
/*------------------------------------------------------------------
** Delete USER from the set of SECURITY_EQUALS in the bindery.
*/
ccode=NWDeleteObjectFromSet(
/* > connection Handle */ connHandle,
/* > object to delete */ destinationName,
/* > Object Type */ OT_USER,
/* > Property Name */ "SECURITY_EQUALS",
/* > Member to delete */ userName,
/* > object type */ OT_USER);
switch(ccode){
case 0x0000 : printf("Successfully deleted %s from %s's SECURITY_EQUALS list\n",
userName,destinationName);
break;
case 0x8801 : printf("INVALID_CONNECTION\n");
break;
case 0x8996 : printf("Server_OUT_OF_MEMORY\n");
break;
case 0x89EA : printf("NO_SUCH_MEMBER\n");
break;
case 0x89EB : printf("NOT_GROUP_PROPERTY\n");
break;
case 0x89F0 : printf("WILD_CARD_NOT_ALLOWED\n");
break;
case 0x89F4 : printf("NO_OBJECT_DELETE_PRIVILEGE\n");
break;
case 0x89F8 : printf("NO_PROPERTY_WRITE_PRIVILEGE\n");
break;
case 0x89FB : printf("NO_SUCH_PROPERTY\n");
break;
case 0x89FC : printf("NO_SUCH_OBJECT\n");
break;
case 0x89FE : printf("DIRECTOYR_LOCKED\n");
break;
case 0x89FF : printf("HARDWARE_FAILURE\n");
break;
default : break;
}
}
}