home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
lcud.exe
/
SCANLC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-23
|
10KB
|
288 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: SCANLC.C
**
** Desc: This program allows the user to scan the LOGIN_CONTROL of any user.
** Or the USER_DEFAULTS property of Supervisor.
**
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 01-08-94 ARM First code.
*/
/***************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <stdio.h> /* sprintf() */
#include <string.h>
#include <conio.h>
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
#define NWDOS
/*------------------------------------------------------------------
** Global
** The LOGIN_CONTROL structure is an 86 byte structure that contains
** account and password information. Following is the structure of
** the LOGIN_CONTROL property.
*/
typedef struct{
BYTE accountExpiresYear;
BYTE accountExpiresMonth;
BYTE accountExpiresDay;
BYTE accountExpired;
BYTE passwordExpiresYear;
BYTE passwordExpiresMonth;
BYTE passwordExpiresDay;
BYTE passwordGraceLogins;
WORD expirationInterval;
BYTE graceReset;
BYTE minimumPasswordLength;
WORD maxConcurrentConnections;
BYTE timeBitMap[42];
BYTE lastLoginDate[6];
BYTE restrictionFlags;
BYTE filler;
LONG maxDiskBlocks;
WORD badLoginCount;
LONG nextResetTime;
BYTE badStationAddress[12];
} LOGIN_CONTROL;
typedef struct
{
BYTE accountExpiresYear;
BYTE accountExpiresMonth;
BYTE accountExpiresDay;
BYTE restrictionFlags;
WORD expirationInterval;
BYTE graceReset;
BYTE minimumPasswordLength;
WORD maxConcurrentConnections;
BYTE timeBitMap[42];
LONG balance;
LONG creditLimit;
LONG maxDiskBlocks;
BYTE createHomeDir;
} USER_DEFAULTS;
/*-----------------------------------------------------------------------
** Prototypes
*/
void printLoginControl(LOGIN_CONTROL *, char *);
void printUserDefaults(USER_DEFAULTS *, char *);
/****************************************************************************
** Program Start
*/
void main(int argc, char *argv[])
{
LOGIN_CONTROL log;
USER_DEFAULTS user;
NWCONN_HANDLE connHandle;
char objectName[48];
char propertyName[48];
BYTE propValue[128];
NWCCODE ccode;
BYTE desiredValue[128];
long transferSize;
char input='0';
if (argc <= 1){
printf("\nUsage: SCANLC <object name>\n");
exit(1);
}
while(input<'1' || input>'2'){
clrscr();
gotoxy(10,10);
printf("MENU ENTRY SCREEN");
gotoxy(10,12);
printf("1) LOGIN_CONTROL property?");
gotoxy(10,14);
printf("2) USER_DEFAULTS property?");
gotoxy(10,16);
printf("Choose 1 or 2 > ");
input=getche();
}
strupr(argv[1]);
strcpy(objectName, argv[1]);
ccode = NWCallsInit(NULL,NULL);
if(ccode){
printf("NWCallsInit returned: %04X\n",ccode);
exit(1);
}
ccode = NWGetDefaultConnectionID(&connHandle);
if(ccode){
printf("Call to NWGetDefaultConnectionID failed!! Code %04X\n", ccode);
exit(1);
}
switch(input){
case '1' : strcpy(propertyName,"LOGIN_CONTROL");
break;
case '2' : strcpy(propertyName,"USER_DEFAULTS");
transferSize=sizeof(USER_DEFAULTS);
break;
default : printf("should never get here debug our code");
exit(1);
}
memset(propValue,'\0',sizeof(propValue));
clrscr();
ccode=NWReadPropertyValue(
/* > Conn Handle */ connHandle,
/* > object name */ objectName,
/* > object type */ OT_USER,
/* > property Name*/ propertyName,
/* > data set indx*/ 1,
/* < Data Buffer */ propValue,
/* < More flag */ NULL,
/* < Property Flgs*/ NULL);
if (ccode==0x89FC){
clrscr();
printf("There is no property found error code %X returned\n",ccode);
exit(1);
}
else if (ccode){
printf("\nNWReadPropertyValue returned: %04X", ccode);
exit(1);
}
switch(input){
case '1' : transferSize=sizeof(LOGIN_CONTROL);
memmove (&log,propValue,transferSize);
printLoginControl(&log, objectName);
break;
case '2' : transferSize=sizeof(USER_DEFAULTS);
memmove (&user,propValue,transferSize);
printUserDefaults(&user, objectName);
break;
default : printf("should never get here debug our code");
exit(1);
}
}
/***************************************************************************
** Prints out the USER_DEFAULTS property values.
*/
void printUserDefaults(USER_DEFAULTS *user, char *objectName)
{
int i;
int count=0;
printf(" VALUES IN THE USER_DEFAULTS PROPERTY for: %s\n\n",objectName);
printf("accountExpiresYear : %02d\n",user->accountExpiresYear);
printf("accountExpiresMonth : %02d\n",user->accountExpiresMonth);
printf("accountExpiresDay : %02d\n",user->accountExpiresDay);
printf("restrictionFlags : %02X\n",user->restrictionFlags);
printf("expirationInterval : %02d\n",NWWordSwap(user->expirationInterval));
printf("graceReset : %02d\n",user->graceReset);
printf("minimumPasswordLength : %02d\n",user->minimumPasswordLength);
printf("maxConcurrentConnections : %02d\n",NWWordSwap(user->maxConcurrentConnections));
printf("timeBitMap[42] : ");
for(i=0;i<42;i++){
printf("%02X",strtol(&(user->timeBitMap[i]),(char**)NULL,16));
count++;
if (count==21){
printf("\n ");
count=0;
}
}
printf("\nbalance : %04X\n",user->balance);
printf("creditLimit : %04X\n",user->creditLimit);
printf("maxDiskBlocks : %04X\n",user->maxDiskBlocks);
printf("createHomeDir : %02X\n",user->createHomeDir);
}
/***************************************************************************
** Prints out the LOGIN_CONTROL property values.
*/
void printLoginControl(LOGIN_CONTROL *log, char *objectName)
{
int i;
int count=0;
printf(" VALUES IN THE LOGIN_CONTROL PROPERTY for: %s\n",objectName);
printf("accountExpiresYear : %02d\n",log->accountExpiresYear);
printf("accountExpiresMonth : %02d\n",log->accountExpiresMonth);
printf("accountExpiresDay : %02d\n",log->accountExpiresDay);
printf("accountExpired : %02X\n",log->accountExpired);
printf("passwordExpiresYear : %02d\n",log->passwordExpiresYear);
printf("passwordExpiresMonth : %02d\n",log->passwordExpiresMonth);
printf("passwordExpiresDay : %02d\n",log->passwordExpiresDay);
printf("passwordGraceLogins : %02d\n",log->passwordGraceLogins);
printf("expirationInterval : %02d\n",NWWordSwap(log->expirationInterval));
printf("graceReset : %02d\n",log->graceReset);
printf("minimumPasswordLength : %02d\n",log->minimumPasswordLength);
printf("maxConcurrentConnections : %02d\n",NWWordSwap(log->maxConcurrentConnections));
printf("timeBitMap[42] : ");
for(i=0;i<42;i++){
printf("%02X",strtol(&(log->timeBitMap[i]),(char**)NULL,16));
count++;
if (count==22){
printf("\n ");
count=0;
}
}
printf("\nlastLoginDate[6] :");
printf(" %2d/%2d/%2d %2d:%2d:%2d\n",
log->lastLoginDate[1],
log->lastLoginDate[2],
log->lastLoginDate[0],
log->lastLoginDate[3],
log->lastLoginDate[4],
log->lastLoginDate[5]);
printf("restrictionFlags : %02X\n",log->restrictionFlags);
printf("filler : %02X\n",log->filler);
printf("maxDiskBlocks : %04X\n",log->maxDiskBlocks);
printf("badLoginCount : %02d\n",NWWordSwap(log->badLoginCount));
printf("nextResetTime : %04X Number of minute from jan 1 1985\n"
,log->nextResetTime);
printf("badStationAddress[12] : ");
for(i=0;i<12;i++){
printf("%02X",strtol(&(log->badStationAddress[i]),(char**)NULL,16));
}
}