home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dbsamp.exe
/
DBUNINST
/
DBUNINST.C
next >
Wrap
Text File
|
1995-01-04
|
8KB
|
273 lines
/****************************************************************************
** File: DBUNINST.C
**
** Desc: Removes the following classes from the tree:
** DBServer - a class that is used for a Database Server
** to authenticate to the tree.
** Database - a class that is used as an object to represent
** a database in a Database Server.
** Removes the following Attributes from the tree:
** DBAdmin - an attribute that is used to hold the name of
** a NDS group. This will be used to hold the
** administrators of the Database.
** DBOperator- an attribute that is used to hold the name of
** a NDS group. This will be used to hold the
** operators of the Database.
** NOTE - Because none of the classes or attributes above effect the
** the base classes, they can be removed from the schema
** provided there are no objects that exists of these types.
** If objects do exist, the removal of the classes and attributes
** will fail.
**
** 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.
**
** Programmers:
**
** Ini Who Firm
** --- ----------------- ------------------------------------------------
** CRG Calvin Gaisford Novell Developer Support.
**
** History:
**
** When Who What
** -------- --- ---------------------------------------------------------
** 10-21-94 CRG First code.
** 1-04-95 CRG Modified to be generic as an example.
*/
/***************************************************************************
** Libraries Linked in for .exe
**
** NWCALLS.LIB
** NWLOCALE.LIB
** NWNET.LIB
**
*/
/***************************************************************************
** #defines
*/
#define FAILURE 0xFF
#define SUCCESS 0x00
/****************************************************************************
** Include headers, macros, etc.
*/
/*-----------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
/*-----------------------------------------------------------------------
** NetWare
*/
#include <nwnet.h>
#include <nwcalls.h>
#include <nwlocale.h>
/*-----------------------------------------------------------------------
** Program Global storage
*/
struct
{
NWDSContextHandle context;
}gs;
extern unsigned _stklen=8000;
/***************************************************************************
** Function Prototypes
*/
void processCode(NWDSCCODE ccode);
void removeDB(void);
void removeDBS(void);
void removeAttr(void);
void FatalError(int errorCode);
void InitDS(void);
int UninitDS(void);
/***************************************************************************
** Main Program
*/
void main(void)
{
InitDS();
removeDB();
removeDBS();
removeAttr();
UninitDS();
}
/***************************************************************************
** Processes the return codes from DS calls.
*/
void processCode(NWDSCCODE ccode)
{
switch(ccode)
{
case 0 : printf("Successfully Removed\n");
break;
case -644 : printf("Failed -- Schema in Use\n");
break;
default : printf("Failed -- Returned Error: %d\n", ccode);
break;
}
}
/***************************************************************************
** Removes the following Attributes from the Schema: DBAdmin, DBOperator.
*/
void removeAttr(void)
{
Attr_Info_T attrInfo;
char attrName[MAX_SCHEMA_NAME_CHARS+2];
NWDSCCODE ccode;
/*---------------------------------------------------------------
** Removing the attributes DBAdmin and DBOperator.
*/
strcpy(attrName, "DBAdmin");
printf("Removing attribute \"%s\" from Schema...",attrName);
ccode = NWDSRemoveAttrDef(gs.context, attrName);
processCode(ccode);
strcpy(attrName, "DBOperator");
printf("Removing attribute \"%s\" from Schema...",attrName);
ccode = NWDSRemoveAttrDef(gs.context, attrName);
processCode(ccode);
}
/***************************************************************************
** Removes the new DBServer Class
** This class is based on the "Top" class. It is defined so that it
** can be contained by Organization or Organizational Unit. It is
** defined as an object for a Database
** Server to authenticate to the Tree. (therefore the public and private
** keys) Also, the Network Address Attribute was added so clients could
** find the server through DS and no have to look for SAPs.
*/
void removeDBS(void)
{
NWDSCCODE ccode;
char *className="DBServer";
printf("Removing Class \"%s\" from Schema...",className);
ccode = NWDSRemoveClassDef(gs.context, className);
processCode(ccode);
}
/***************************************************************************
** Removes the new Database Class. This class is defined to represent
** an an object that represents a database. It can only
** be contained by a Organization or Organizational Unit.
*/
void removeDB(void)
{
NWDSCCODE ccode;
char *className="Database";
printf("Removing Class \"%s\" from Schema...",className);
ccode = NWDSRemoveClassDef(gs.context, className);
processCode(ccode);
}
/***************************************************************************
** FatalError is the common exit point for errors.
*/
void FatalError(int errorCode)
{
exit(errorCode);
}
/***************************************************************************
** Establish context. These are the standard initializations for DS calls
*/
void InitDS(void)
{
NWDSCCODE dsCcode;
LCONV lconvInfo;
dsCcode=NWCallsInit(NULL,NULL);
if(dsCcode) /* initialize allowing to call nwcalls functions */
{
printf("FatalError during NWCallsInit %X\n",dsCcode);
FatalError(FAILURE);
}
NWLlocaleconv(&lconvInfo);
dsCcode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
if(dsCcode)
{
printf("NWInitUnicodeTables() returned: %04X\n", dsCcode);
FatalError(FAILURE);
}
gs.context=NWDSCreateContext();
if(gs.context)
{
printf("FatalError during NWDSCreateContext %X\n",gs.context);
FatalError(FAILURE);
}
}
/***************************************************************************
** Release context and clean up.
*/
int UninitDS()
{
NWDSCCODE dsCcode;
dsCcode=NWDSFreeContext(gs.context);
if(dsCcode)
{
printf("FatalError during NWDSFreeContext %X\n",dsCcode);
FatalError (FAILURE);
}
dsCcode=NWFreeUnicodeTables();
if(dsCcode)
{
printf("Error during NWFreeUnicodeTables()\n");
FatalError (FAILURE);
}
return(0);
}