home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
effrht.exe
/
RIGHTS.C
< prev
next >
Wrap
Text File
|
1995-06-02
|
7KB
|
175 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: Rights.c
**
** Desc: Finds a users effective rights for a directory or a file.
** NOTE: This code works with a 4.X server but fails with a 3.x server
** this is being fixed and once fixed will allow this call to work
** in the 3.x environment also.
**
** Programmers:
** Ini Who Firm
** ------------------------------------------------------------------
** ARM A. Ray Maxwell Novell Developer Support.
**
** History:
**
** ------------------------------------------------------------------
** 04-01-95 ARM First code.
*/
/***************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------
** ANSI
*/
#include <stdlib.h> /* exit(), atol() */
#include <stdio.h> /* printf() */
#include <string.h> /* strcpy() */
/*------------------------------------------------------------------
** NetWare
*/
#include <nwcalls.h>
/****************************************************************************
** Program Start
*/
void main(int argc, char *argv[])
{
NWCONN_HANDLE connHandle;
NWOBJ_ID objectID;
NWCCODE ccode;
NWACCESS_RIGHTS mask;
NWRIGHTS_MASK rightsMask;
NWDIR_HANDLE dirHandle=-1;
char server[50];
char objectName[48];
char path[256];
char directory[128];
char dirPath[128];
if(argc <= 3) {
printf("Usage: rights <server> <object Name> <path> <directory>\n\n");
printf(" NOTE:If directory is not given then dirHandle=0.\n");
printf(" so path is the full path. Otherwise the path is\n");
printf(" relative to the directory given.\n");
printf("EXAMPLE rights servername johndoe sys:johndoe testdir\n");
exit(1);
}
if (argc==4)
dirHandle=0;
strcpy(server, strupr(argv[1]));
strcpy(objectName,strupr(argv[2]));
strcpy(path,strupr(argv[3]));
strcpy(directory, strupr(argv[4]));
ccode = NWCallsInit(NULL, NULL);
if(ccode)
exit(1);
ccode = NWGetConnectionHandle(
/* > servername */ server,
/* Novell Reserved1 */ 0,
/* < connection Handle */ &connHandle,
/* Novell Reserved2 */ NULL);
if(ccode){
printf("NWGetConnectionHandle failed %X\n",ccode);
exit(1);
}
ccode=NWGetObjectID(
/* > connection Handle */ connHandle,
/* > object Name */ objectName,
/* > objectType */ OT_USER,
/* < object ID */ &objectID);
if(ccode){
printf("NWGetObjectID failed %X\n",ccode);
exit(1);
}
/*----------------------------------------------------------------
** The following code will allocate a temporary directory handle
** for use in the NWGetObjectEffectiveRights() function
*/
if(dirHandle!=0){
ccode = NWAllocTemporaryDirectoryHandle(
/* > Connection Handle */ connHandle,
/* > Directory Handle */ NULL,
/* > Pointer to Absolute dir path */ directory,
/* < Pointer to New dir Handle */ &dirHandle,
/* < Pointer to trustee rights */ &mask);
if (ccode){
printf("NWAllocTemproaryDirectoryHandle failed error code= %X\n",
ccode);
exit(1);
}
}
ccode=NWGetObjectEffectiveRights(
/* > connection Handle */ connHandle,
/* > object ID */ objectID,
/* > directory Handle */ dirHandle,
/* > path */ path,
/* < rights mask */ &rightsMask);
if(ccode){
printf("NWGetObjectEffectiveRights failed %X\n",ccode);
}
else{
printf("NWGetObjectEffectiveRights for\n");
printf("\n\t%-08s\t [%c%c%c%c%c%c%c%c]\n\n",objectName,
(rightsMask & TR_SUPERVISOR) ? 'S' : ' ',
(rightsMask & TR_READ) ? 'R' : ' ',
(rightsMask & TR_WRITE) ? 'W' : ' ',
(rightsMask & TR_CREATE) ? 'C' : ' ',
(rightsMask & TR_DELETE) ? 'E' : ' ',
(rightsMask & TR_ACCESS_CTRL) ? 'A' : ' ',
(rightsMask & TR_FILE_SCAN) ? 'F' : ' ',
(rightsMask & TR_MODIFY) ? 'M' : ' ');
}
ccode=NWGetEffectiveRights(connHandle,
dirHandle,
path,
&rightsMask);
if(ccode){
printf("NWGetEffectiveRights failed %X\n",ccode);
}
else
printf("NWGetEffectiveRights for:\n");
printf("%-08s\t\t [%c%c%c%c%c%c%c%c]",objectName,
(rightsMask & TR_SUPERVISOR) ? 'S' : ' ',
(rightsMask & TR_READ) ? 'R' : ' ',
(rightsMask & TR_WRITE) ? 'W' : ' ',
(rightsMask & TR_CREATE) ? 'C' : ' ',
(rightsMask & TR_DELETE) ? 'E' : ' ',
(rightsMask & TR_ACCESS_CTRL) ? 'A' : ' ',
(rightsMask & TR_FILE_SCAN) ? 'F' : ' ',
(rightsMask & TR_MODIFY) ? 'M' : ' ');
}