Acquiring Active User Access Privileges

I have a search algorithm that tries to resolve the location of a directory on a local drive. A directory will obviously need access to other directories present on the system if it looks for a subdirectory of one of them. However, when doing so, I keep getting UnauthorizedAccessException.

I would like to give the search engine the access privileges of the active user when it starts, how can I achieve this.

0


a source to share


1 answer


In most cases, the correct answer is that you shouldn't.

Your algorithm should catch the UnauthorizedAccessException, accept that it is not allowed to navigate further through this folder, and act as if the folder is empty.

This means that sometimes you will get a response that the directory you are looking for does not exist when it technically does exist. This is normal. This is how it should be. If you don't have permission to do this, it doesn't exist for you.

Folders protected by the rights of some other users are "private". The program that "Joe" is running should not look at folders belonging to "Mary". These are all permission points.



There are very few controlled exceptions in the rule. As you know, Disk Backup and Antivirus applications should be able to navigate the entire disk regardless of the folder permission. They do this by setting up the service under a high-priority account (maybe "SYSTEM", maybe something else). This will likely be the account containing the SeBackupPrivilege.

You can do this for your program if you really need to scan the entire drive, but for most application scenarios, you really shouldn't. You only need to provide maintenance such as antivirus or backup software.

It is not that he "overflows"; that's what it is "wrong". He doesn't play by the rules.

0


a source







All Articles