home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dschgp.exe
/
DSCHGPAS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-19
|
6KB
|
217 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: DSCHGPSS.C
**
** Desc: Allows the user to change the password on a user in the DS tree.
**
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 01-18-95 ARM First code.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** Macros
*/
#define NWDOS
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h> /* getch() */
/*------------------------------------------------------------------------
** NetWare
*/
#include <nwnet.h>
#include <nwcalls.h>
#include <nwlocale.h>
extern unsigned _stklen = (1024 * 8);
/****************************************************************************
** Function main() contains the entire program.
**
*/
void main(int argc, char *argv[])
{
NWDSContextHandle dContext;
NWDSCCODE ccode;
NWCONN_HANDLE connHandle;
char *ptr,*ptr1;
char objectName[MAX_DN_CHARS],
originalPassword[128],
newPassword[128];
char ch;
LCONV lconvInfo;
ccode = NWCallsInit(NULL,NULL);
printf("NWCallsInit() = %04X\n",ccode);
if(ccode)
exit(1);
NWLsetlocale(LC_ALL, "");
printf("\nNWLsetl.. OK");
NWLlocaleconv(&lconvInfo);
printf("\nCountry ID = %03d, Code Page = %04d\n",
lconvInfo.country_id, lconvInfo.code_page);
ccode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
printf("NWInitUnicodeTables() = %04X\n",ccode);
if(ccode){
NWFreeUnicodeTables();
exit(1);
}
dContext = NWDSCreateContext();
printf("NWDSCreateContext() = %04X\n",dContext);
if(dContext == ERR_CONTEXT_CREATION){
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
exit(1);
}
originalPassword[0] = '\0';
printf("\nOriginal Password: ");
ptr = originalPassword;
do
{
ch = getch(); // get password without echo!
*ptr = ch;
ptr++;
} while (ch != '\r');
ptr = ptr - 1;
*ptr = '\0';
printf("\nAttempting Change User password... \n");
ccode = NWDSWhoAmI(
/* > Context */ dContext,
/* < Obj name* */ objectName);
if (ccode){
printf("\nNWDSWhoAmI returned: %04X", ccode);
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
exit(1);
}
ccode=NWDSVerifyObjectPassword(
/* > contextHandle */ dContext,
/* > reserved */ 0,
/* > object name */ objectName,
/* > password clear text */ originalPassword);
if (ccode){
printf("\nNWDSVerifyObjectPassword returned: %04X", ccode);
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
exit(1);
}
newPassword[0] = '\0';
printf("\nNew Password: ");
ptr1 = newPassword;
do
{
ch = getch(); // get password without echo!
*ptr1 = ch;
ptr1 = ptr1 + 1;
} while (ch != '\r');
ptr1 = ptr1 - 1;
*ptr1 = '\0';
ccode=NWDSChangeObjectPassword(
/* > contextHandle */ dContext,
/* > reserved */ NULL,
/* > object name */ objectName,
/* > currentpassword */ originalPassword,
/* > new password */ newPassword);
if(ccode){
printf("\nNWDSChangeObjectPassword returned: %04X", ccode);
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
exit(1);
}
NWFreeUnicodeTables();
NWDSFreeContext(dContext);
}