Prevent WNetAddConnection2 class which allows prohibited user to access shared folder

此生再无相见时 提交于 2019-12-02 07:12:47

By design, connecting to a share requires access to the share - it does not require access to the root directory of the share.

Opening the share via the Run box opens the root directory of the share, so it requires at least read access to the directory as well as to the share. The WNetAddConnection2() API, by comparison only requires access to the share.

It has to work this way, because it is sometimes desirable to give someone access to only certain subdirectories, but not the root directory. If connecting to the share required access to the root directory this would not be possible.

After connecting to the share, you can test access to the root directory by attempting to enumerate the files. If you get an access denied exception, the user does not have access.

redthonz

I had the same problem when I used to deploy my C# project in IIS 7.5, but it's amazing when I do to removed the logout procedure of my code. . .

What I mean is removed function LogoutFromShare(ip,folder) server directory.

I use ony this one LoginToOtherPC(ip, usr, pwd, folder).

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