S
Sten Westerback
Hi
I just made a little tool that recursively finds out how many bytes the
files in
a folder tree contains. The tool will run with administrative rights on
Windows NT/2k/XP systems with NTFS where user is allowed to have folders
with security set so that only (s)he can access it.
My question is:
Is it possible for administrator to enumarate the files and subfolders in
such folders
without aquiring user credentials and preferably without getting and then
resetting
permission to the folder? The purpose is to find out the backup needs for
the users.
The only idea i have to go on at the moment is to use backup sematics in
CreateFile() to open the folder and then BackupRead() and BackupSeek()
to scan over end of stream and get actual size returned..
I tried this with this function:
BOOL bGetFailedFolderSizes(char *p_szFolder, BOOL bInNoBackup)
{
HANDLE hDir;
WIN32_STREAM_ID *p_strid;
DWORD dw, dwOut;
VOID *p_Cont=NULL;
hDir = CreateFile (p_szFolder, GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hDir==NULL) return FALSE;
dw=sizeof(WIN32_STREAM_ID) + 500000;
if ((p_strid=malloc(dw))==NULL) { CloseHandle(hDir); return FALSE; }
memset(p_strid, 0, dw);
while (BackupRead(hDir, p_strid, dw, &dwOut, FALSE, FALSE, &p_Cont))
{
// just debugging for now; not sure what the directory stream
contains...
}
CloseHandle(hDir);
return FALSE;
}
BackupRead() returns "true" but still the buffer isn't touch and context
pointer is
set to 0xFFFFFFFF. Do one need to enable some Local Policy for it to work?
- Sten
I just made a little tool that recursively finds out how many bytes the
files in
a folder tree contains. The tool will run with administrative rights on
Windows NT/2k/XP systems with NTFS where user is allowed to have folders
with security set so that only (s)he can access it.
My question is:
Is it possible for administrator to enumarate the files and subfolders in
such folders
without aquiring user credentials and preferably without getting and then
resetting
permission to the folder? The purpose is to find out the backup needs for
the users.
The only idea i have to go on at the moment is to use backup sematics in
CreateFile() to open the folder and then BackupRead() and BackupSeek()
to scan over end of stream and get actual size returned..
I tried this with this function:
BOOL bGetFailedFolderSizes(char *p_szFolder, BOOL bInNoBackup)
{
HANDLE hDir;
WIN32_STREAM_ID *p_strid;
DWORD dw, dwOut;
VOID *p_Cont=NULL;
hDir = CreateFile (p_szFolder, GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hDir==NULL) return FALSE;
dw=sizeof(WIN32_STREAM_ID) + 500000;
if ((p_strid=malloc(dw))==NULL) { CloseHandle(hDir); return FALSE; }
memset(p_strid, 0, dw);
while (BackupRead(hDir, p_strid, dw, &dwOut, FALSE, FALSE, &p_Cont))
{
// just debugging for now; not sure what the directory stream
contains...
}
CloseHandle(hDir);
return FALSE;
}
BackupRead() returns "true" but still the buffer isn't touch and context
pointer is
set to 0xFFFFFFFF. Do one need to enable some Local Policy for it to work?
- Sten