home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dscrea.exe
/
DSCREATE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-23
|
5KB
|
169 lines
/****************************************************************************
** File:DSCREATE.C
**
** Description:
** The file DSCREATE.C sets up a buffer and creates a DS user
** named Joe Smith in the default context then logs the user
** Joe Smith into the tree.
**
**
** 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
** -----------------------------------------------------------------------
** MDP Marina D Pimentel Novell Developer Support
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 06-21-95 MDP First code.
**
*/
/*---------------------------------------------------------------------------
** Include headers, macros, structures, typedefs, etc.
*/
#define NWDOS
#include <stdio.h>
#include <string.h>
#include <nwcalls.h>
#include <nwnet.h>
#include <nwpsrv.h>
#include <stdlib.h>
extern _stklen = (8 * 1024U);
/*---------------------------------------------------------------------------
** Program start.
*/
void main(int argc, char *argv[ ])
{
NWDSContextHandle dContext;
NWDSCCODE ccode;
NWDS_FLAGS optionsFlag=0;
NWCONN_HANDLE connID;
NWDS_BUFFER *inBuf;
/*---------------------------------------------------------------------------
** Include headers, macros, structures, typedefs, etc.
*/
ccode=NWCallsInit(NULL,NULL);
ccode = NWInitUnicodeTables(001, 437);
if(ccode)
{
printf("NWInitUnicodeTables returned [%x]\n",ccode);
goto cleanup;
}
ccode=NWGetPrimaryConnectionID(&connID);
if(ccode)
{
printf("NWGetPrimaryConnectionID returned [%x]\n",ccode);
goto cleanup;
}
dContext = NWDSCreateContext( );
if(dContext == ERR_CONTEXT_CREATION)
{
printf("Could not create context\n");
goto cleanup;
}
/*---------------------------------------------------------------------------
** Setting up buffer to add user.
*/
ccode=NWDSAllocBuf(DEFAULT_MESSAGE_LEN,&inBuf);
if (ccode)
{
printf("NWDSAllocBuf failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSInitBuf(dContext,DSV_ADD_ENTRY,inBuf);
if (ccode)
{
printf("NWDSInitBuf failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSPutAttrName(dContext,inBuf,"Object Class");
if (ccode)
{
printf("NWDSPutAttrName failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSPutAttrVal(dContext,inBuf,SYN_DIST_NAME,"User");
if (ccode)
{
printf("NWDSPutAttrValue failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSPutAttrName(dContext,inBuf,"Surname");
if (ccode)
{
printf("NWDSPutAttrName failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSPutAttrVal(dContext,inBuf,SYN_CI_STRING,"Smith");
if (ccode)
{
printf("NWDSPutAttrVal failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSAddObject(dContext,"Joe",NULL,0,inBuf);
if (ccode)
{
printf("NWDSAddObject failed with [%x]\n",ccode);
goto cleanup;
}
/*---------------------------------------------------------------------------
** Generating object key pair then logging in as the new user.
*/
ccode=NWDSGenerateObjectKeyPair(dContext,"Joe","MYPASS",optionsFlag);
if (ccode)
{
printf("NWDSGenerateObjectKeyPair failed with [%x]\n",ccode);
goto cleanup;
}
ccode=NWDSLogin(dContext,optionsFlag,"Joe","MYPASS",0);
if (ccode)
printf("NWDSLogin failed with [%x]\n",ccode);
ccode=NWDSAuthenticate(connID,optionsFlag,NULL);
if (ccode)
printf("NWDSAuthenticate returned a [%x]\n",ccode);
/*---------------------------------------------------------------------------
** Freeing memory.
*/
cleanup:
NWDSFreeBuf(inBuf);
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
}