home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
snapx1.exe
/
DSMODOBJ.C
next >
Wrap
Text File
|
1994-10-19
|
5KB
|
169 lines
/****************************************************************************
** File: DSMODOBJ.C
**
** Desc: This application adds an attribute called "Pets" to the
** user object. This sample code demonstrates to proper steps
** to create an attribute class and how to add this attribute
** to an existing class. This code was intended to be used with
** the SNAPPETS.C example. This must be run before any changes in
** the PETS.DLL Snapin example will be saved to the DS Database.
**
**
** 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
** -----------------------------------------------------------------------
** KLB Karl Bunnell Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 09-19-94 klb First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** MACROS
*/
#define NWDOS
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
/*------------------------------------------------------------------------
** NetWare
*/
#include <nwnet.h>
#include <nwcalls.h>
#include <nwlocale.h>
void main(void)
{
NWDSContextHandle dContext;
NWDSCCODE cCode=0;
Attr_Info_T attrInfo;
Buf_T *classBuf;
char attrName[MAX_SCHEMA_NAME_CHARS+2];
char className[MAX_SCHEMA_NAME_CHARS+2];
char optAttr[MAX_SCHEMA_NAME_CHARS+2];
char far *countryPtr;
LCONV lconvInfo;
cCode = NWCallsInit(NULL, NULL);
if (cCode)
{
printf("\nCall to NWCallsInit returned: %04X", cCode);
exit(1);
}
countryPtr = NWLsetlocale(LC_ALL, "");
NWLlocaleconv(&lconvInfo);
cCode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
if(cCode)
{
printf("NWInitUnicodeTables() returned: %04X\n", cCode);
NWFreeUnicodeTables();
exit(1);
}
dContext = NWDSCreateContext();
if (dContext == ERR_CONTEXT_CREATION)
{
printf("NWDSCreateContext returned: %04X\n", cCode);
NWFreeUnicodeTables();
exit(1);
}
/*---------------------------------------------------------------
** Create the attribute Pets.
*/
memset(&attrInfo, (int) '\0', sizeof(Attr_Info_T));
attrInfo.asn1ID.length = 0;
memset(attrInfo.asn1ID.data, 0, MAX_ASN1_NAME);
attrInfo.attrFlags = 0;
attrInfo.attrSyntaxID = SYN_PR_STRING;
strcpy(attrName, "Pets");
cCode = NWDSDefineAttr(dContext, attrName, &attrInfo);
if( cCode < 0 )
{
printf("\nNWDSDefineAttr returned %04X\n", cCode);
exit ((NWCCODE) cCode );
}
strcpy(className, "User");
cCode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &classBuf);
if( cCode < 0 )
{
printf("\nNWDSAllocBuf returned %04X\n", cCode);
exit( ( NWCCODE ) cCode );
}
cCode = NWDSInitBuf(dContext, DSV_MODIFY_CLASS_DEF, classBuf);
if( cCode < 0 )
{
printf("\nNWDSInitBuf returned %04X\n", cCode);
exit( ( NWCCODE ) cCode );
}
/*---------------------------------------------------------------
** Add Pets as optional attribute
*/
strcpy(optAttr, "Pets");
cCode = NWDSPutClassItem(dContext, classBuf, optAttr);
if( cCode < 0 )
{
printf("\nNWDSPutClassItem returned %04X\n", cCode);
exit ( ( NWCCODE ) cCode );
}
cCode = NWDSModifyClassDef(dContext, className, classBuf);
if( cCode < 0 )
{
printf("\nNWDSModifyClassDef returned %04X\n", cCode);
exit ( ( NWCCODE ) cCode );
}
NWDSFreeBuf(classBuf);
NWDSFreeContext(dContext);
}