Solved

Access denied, file/folder audit... c# vs2012

Posted on 2014-12-25
7
280 Views
Last Modified: 2015-01-10
I have produced small application using http://msdn.microsoft.com/en-us/library/ms171645%28v=vs.80%29.aspx which functions well for certain folders but not all.

It works well for path like: C:\Users\Public\Documents\UntypeDatasetSample which there is no security requirements. But it doesn't work for most other folders because the security issues discussed at:  http://windows.microsoft.com/en-us/windows7/how-do-i-open-a-file-if-i-get-an-access-denied-message

Question: Is it possible to dynamically pacify the security and reinstate it after the files and folders have been audited?

If you wish to have a copy of this 60KB applcation, download it from: https://onedrive.live.com/?cid=420CDD6A13807C9B&id=420CDD6A13807C9B%21116
0
Comment
Question by:Mike Eghtebas
  • 3
  • 3
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40518081
What happens if you right-click on the program name and select "Run as Administrator"?
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40518083
I am running as admin. It errors as shown below:
AccessDenied
Above and beyond admin sign-in, the following link below seems to suggest the need to change security for folders being accessed.

http://windows.microsoft.com/en-us/windows7/how-do-i-open-a-file-if-i-get-an-access-denied-message

Public folder doesn't have security but My Music folder (by default) has in windows 7.

Mike
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 40518087
On Windows 7, your user, even when an Admin, does not run with Admin privileges most of the time.  Many times when I have to install programs on Windows 7, I have to right-click and select "Run as Administrator" even though the user is the Only user and is an Administrator.  But then... I knew you wouldn't try it.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40518095
As you are describing, I have too, to use run as admin when it is needed. This application is for learning at this point. As we know users will not have admin rights and that is good (they will not be able to view the content of certain folders they are not allowed to). But as admin, I do not want to manually change each and every folder just to audit them and then go back to restore their security. I am hoping for a dynamic solution.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40518129
Yes... but did you try "Run as Admin" to see if the program you are working on works in your 'admin' account?  I doubt that you will find "a dynamic solution", especially for regular non-admin users.
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40518146
re:> but did you try "Run as Admin" to see if the program you are working on works in your 'admin' account?
A folder is nothing to run as. I am able open My Music folder manually but the code I am running, is not able to open it to read its content despite the fact I have logged as admin prior to running  this code.

re: especially for regular non-admin users
This is good, because non-admin users are better to be limited to only the folders they are allowed to view.

re:> I doubt that you will find "a dynamic solution"
All I can do is to keep asking around. I think, I better include some other TAs such as operating system or those heavily involved with security issues.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 400 total points
ID: 40526215
First, as suggested, try to run the app as admin to ensure that the problem you are having is due to admin access requirement. If it is the case then you will need to impersonate an admin user as shown in examples

http://nujakcities.wordpress.com/2011/08/01/use-vb-net-to-impersonate-a-domain-user/

http://www.codeproject.com/Articles/14358/User-Impersonation-in-NET

http://williamfaulkner.co.uk/2009/04/vbnet-run-as-administrator-impersonate-a-user-2008/


For asking current user to elevate UAC level, see examples

http://support.microsoft.com/kb/981778

http://justsomevbcode.blogspot.co.uk/2013/01/elevate-your-application-at-start-up.html


You can only access folders that the current user has access while you are running as that user. If you need to access the folders that current user does not have access to, you need to either give permissions or run as a different user that has permissions. There is no other way (and should not be any other way).
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Set value of dynamically created checkboxlist 2 31
VB: Convert 2 dates to specific format 24 48
Modal Popup Extender control 1 18
cannot connect to sqlserver 8 25
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question