Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Accessing (read) Folder/File Security Information - Get Around Error Msg??



Permlink Replies: 1 - Last Post: Aug 16, 2016 11:34 AM Last Post By: Remy Lebeau (Te...
Bradley MacDonald

Posts: 40
Registered: 10/10/99
Accessing (read) Folder/File Security Information - Get Around Error Msg??
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 16, 2016 9:04 AM
Hello Everyone,

I have an application that scans a directory structure on Windows - and tries to get the Windows Permissions. It works fine - except for a few directories that I do not have access to (even though I am an administrator on that machine).

The program comes back with a OS error 5. If you try to access the folder in Explorer - you get a message dialog that has the message "You don't currently have permission to access this folder. Click continue to permanently get access to this folder"
Now - I know I can get around this in one of two ways - either grant access to my current account - or somehow use the internal Administrator account (which owns this folder).

What I am I am wondering is if there is anyway to allow the program to get around this? The issue I have is that it is a shareware application that will be used by folks on all sorts of different machines. Is it possible to use something like a Windows manifest file to accomplish this?

Any thoughts or pointers would be much appreciated!!

G. Bradley MacDonald
brad_AT_timeacct_DOT_com

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Accessing (read) Folder/File Security Information - Get Around ErrorMsg??
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 16, 2016 11:34 AM   in response to: Bradley MacDonald in response to: Bradley MacDonald
Bradley wrote:

What I am I am wondering is if there is anyway to allow the program
to get around this?

Obviously, you have to run your scan code under a user account that has access
to the folder.

The issue I have is that it is a shareware application that will be used
by folks on all sorts of different machines. Is it possible to use something
like a Windows manifest file to accomplish this?

That would force the entire app to run as an elevated admin user.

What you could try is when you detect the error, prompt the user for credentials
of the account that owns the folder, and then use LogonUser() and ImpersonateLoggedOnUser()
to temporarily impersonate that user to continue the scanning of that folder.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02