home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
binscn.exe
/
BINDERY.C
next >
Wrap
Text File
|
1995-01-25
|
12KB
|
311 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: bindery.c
**
** Desc: Allows the user to scan the bindery for Objects Properties and
** values. These are then written to a file called Bindery.txt.
**
**
** Parameter descriptions: > input
** < output
**
**
** Programmers:
** Init Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 06-20-94 ARM First code.
** 09-29-94 ARM Added the code to allow Object names and Type to be
** entered from the command line.
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* strupr() strcpy() */
#include <conio.h> /* clrscr() */
/*------------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
/*------------------------------------------------------------------------
** Defines
*/
#define NWDOS
#define SIZEOFOBJNAME 48
#define SIZEOFPROPNAME 15
#define SEGSIZE 128 /* size of the data segment to be read */
/****************************************************************************
** Main program start
*/
void main(int argc,char *argv[])
{
int i, j;
FILE *fp;
NWCONN_HANDLE connHandle;
/*--------------------------------------------------------------------------
** NWScanObject perameter definitions
*/
NWOBJ_TYPE objectType,
searchObjectType,
temptype;
NWOBJ_ID objectID,id1;
NWCCODE ccode;
NWFLAGS hasprops;
NWFLAGS objectFlag;
NWFLAGS objectSecurity;
char objectName[SIZEOFOBJNAME],
buff[SIZEOFOBJNAME],
searchObjectName[SIZEOFOBJNAME];
char servername[SIZEOFOBJNAME];
/*--------------------------------------------------------------------------
** NWScanProperty perameter definitions
*/
long sequenceNumber;
char propertyName[SIZEOFPROPNAME];
char searchPropertyName[SIZEOFPROPNAME];
NWFLAGS propertyFlags;
NWFLAGS propertySecurity;
NWFLAGS hasValueFlag;
NWFLAGS moreFlag;
NWSEGMENT_NUM dataSetIndex = 1; /* init to one on the first pass */
NWSEGMENT_NUM dataBuffer[SEGSIZE];
/*--------------------------------------------------------------------------
** NWReadPropertyValue perameter definitions
*/
NWFLAGS valueMoreFlag;
ccode=NWCallsInit(NULL,NULL);
if (ccode)
exit(1);
if (argc > 1){
argv++;
strcpy(servername,strupr(*argv));
strcpy(searchObjectName,"*");
if (argc > 2){
argv++;
strcpy(searchObjectName,strupr(*argv));
}
else
strcpy(searchObjectName,"*");
if (argc > 3) {
++argv;
if (!strcmp (*argv,"*"))
searchObjectType=OT_WILD;
else
searchObjectType = (strtoul(*argv,(char**)NULL,0));
searchObjectType = (NWWordSwap)(strtoul(*argv,(char**)NULL,0));
}
else
searchObjectType = OT_WILD;
if (argc > 4) {
argv++;
strcpy(searchPropertyName,strupr(*argv));
}
else
strcpy(searchPropertyName,"*");
}
else {
clrscr();
printf ("USAGE: bindery <server name> [object name] [object type] [property name]\n");
printf (" servername=name of the NetWare server.\n");
printf (" object name= \"*\" if WILD otherwise SUPERVISOR, GUEST etc\n");
printf (" object type= \"*\" if WILD otherwise 1,2,etc.\n");
printf (" property Name= LOGIN_CONTROL etc.\n");
exit(1);
}
ccode=NWCallsInit(NULL,NULL);
ccode = NWGetConnectionHandle(
/* > servername */ servername,
/* Novell Reserved1 */ 0,
/* < connection Handle */ &connHandle,
/* Novell Reserved2 */ NULL);
//ccode= NWGetDefaultConnectionID(&connHandle);
if (ccode)
exit(1);
fp=fopen("bindery.txt","w+");
if (fp==NULL)
exit(1);
objectID=-1;
while(!(ccode = NWScanObject(
/* > conn Handle */ connHandle,
/* > pointer to object name */ searchObjectName,
/* > object type */ searchObjectType,
/* < pointer obj id -1 to start */ &objectID,
/* < pointer next name optional */ objectName,
/* < pointer next type optional */ &objectType,
/* < pointer Properties flag optional */ &hasprops,
/* < pointer Object flag byte optional */ &objectFlag,
/* < pointer Security mask of matching
object optional */ &objectSecurity)) ){
if (ccode)
exit(1);
else{
fprintf(fp,"\nObject: %s\n",objectName);
fprintf(fp,"\t\t-> ID: %08lX Type: %X Class: %-7s\n",
NWLongSwap(objectID),
NWWordSwap(objectType),
(objectFlag ? "dynamic":"static"));
fprintf(fp,"\t\tSecurity: %X Has Properties: %s\n",
objectSecurity,
hasprops ? "Yes":"No");
}
if(hasprops){
sequenceNumber=-1;
while (!(ccode = NWScanProperty (
/* > conn Handle */ connHandle,
/* > pointer set's object name */ objectName,
/* > Set's bindery object type */ objectType,
/* > pointer property name */ searchPropertyName,
/* < pointer for repeate calls
optional */ &sequenceNumber,
/* < pointer next name optional */ &propertyName,
/* < pointer status flag optional */ &propertyFlags,
/* < pointer security mask
optional */ &propertySecurity,
/* < does property have value */ &hasValueFlag,
/* < are there more properties */ &moreFlag))){
if(ccode){
printf("NWScanProperty failed: %X\n",ccode);
break;
}
fprintf(fp,"\nPROPERTY:\n");
fprintf(fp,"\t%-15s\n",propertyName);
fprintf(fp, "\t\tClass: %-7s Type: %-4s Sec: %X Val: %s\n\t\t",
(propertyFlags & BF_DYNAMIC) ? "dynamic":"static",
(propertyFlags & BF_SET) ? "set":"item",
propertySecurity,
(hasValueFlag) ? "Yes" : "No");
if(hasValueFlag){
dataSetIndex=1;
do{
ccode=NWReadPropertyValue(
/* > conn HANDLE */ connHandle,
/* > Pointer object name */ &objectName,
/* > object type */ objectType,
/* > pointer name of property */ &propertyName,
/* > segment number of data */ dataSetIndex,
/* < pointer 128 byte receive buf*/ dataBuffer,
/* < pointer to flag */ &valueMoreFlag,
/* < pointer property type (opt) */ &propertyFlags);
if (ccode){
printf("NWReadPropertyValue failed: %d\n",ccode);
break;
}
else if (propertyFlags & 2) {
for (j=0,i=0;i<32;i++){
/*-----------------------------------------------------
** propertyValue is 128 bytes and the objectID is 4
** bytes long therefore 32X4=128
*/
id1 = *(long *)&dataBuffer[i * 4];
if(id1){
if (ccode = NWGetObjectName(
/* > conn Handle */ connHandle,
/* > object ID */ id1,
/* < pointer Object name */ buff,
/* < pointer Object type */ &temptype)){
printf(buff,
"NWGetObjectName:failed %04x\n",ccode);
buff[0]= NULL;
}
fprintf(fp,"%-20.20s ",buff);
if (++j > 2) {
j = 0;
printf("\n\t\t");
}
}
} /* for */
}
else {
for (j=0, i=0; i<128; i++) {
fprintf(fp,"%02x ",dataBuffer[i]);
if (++j > 15) {
j=0;
fprintf(fp,"\n\t\t");
}
} /* for */
}
dataSetIndex++; /*index on each call to NWreadPropertyValue*/
}while(valueMoreFlag!=0);
dataSetIndex=1;
}
}/* end while */;
} /* end if */
}
fclose(fp);
}