Question

Gentlement,

following situation. There are files in a network share to which even Administrators have no permissions, permissions are set for two individual users only. In the process of an operation to detect and fix such issues (because this is not desired) I need to add access to the Administrators.

In Windows Explorer that's easy. Since I am an Administrator, I can take the ownership of a file or folder and then edit the security descriptor.

The problem is, that using FileSecurity.GetAccessControl() [or rather FileSecurity.GetAccessControl(AccessControlSections.Owner)] does not work, I am getting an UnauthorizedAccessException.

However I -need- to be able to do this, anyone got a tip? Might P/Invoke be a solution here and if so, how would I do that?

I am confused by this matter, because I thought it should work, since it does work in the Explorer ...

Thanks a bomb! - Chris

Was it helpful?

Solution

Just in case anyone is interested, I found a solution that uses PInvoke and does in fact work, everything else I have tried, including activating the privilege and using the .Net methods, failed.

http://blog.mikeobrien.net/2009/11/taking-ownership-and-setting-admin.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top