Using C# to get a list of ACLs for Servers and mapped drives

♀尐吖头ヾ 提交于 2019-11-30 03:39:41

Your getting the error because of the 'Auditing' tab, though I'm fairly sure all you really want to access on the screen is the data on the 'Permissions' tab. The SeSecurityPrivilege controls the access to the SACL.

Try changing

DirectorySecurity DirSec = di.GetAccessControl(AccessControlSections.All);

to

DirectorySecurity DirSec = di.GetAccessControl(AccessControlSections.Access);

then you should stop getting the error

Check that the remote folder grants the user running the code Read Attributes in the ACL.

Also remember that the permissions are resolved on the remote (server) machines, so local group (Users and Administrators) membership may not include the user account running on the client.

Having Process Monitor running on the server (filtered to the folders/files in question) may help resolve details of why it is failing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!