I want to write a program with C/C++ for disabling net share folders and to prevent users from create a new share folder. Does anyone know the methods?
Asked
Active
Viewed 775 times
0

Cody Gray - on strike
- 239,200
- 50
- 490
- 574

AlxDong
- 13
- 4
-
1What's wrong with using the standard Windows tools for doing this? This is a job for Group Policies, not a C++ application. – Cody Gray - on strike Mar 15 '11 at 06:25
-
What does it mean to "disable net share folders"? – Gabe Mar 15 '11 at 06:34
-
@Gabe: My assumption is (s)he is referring to the `net.exe` command with the `share` argument that allows you to create/manage local network shares. But I agree it's a strange way of explaining the problem. – Cody Gray - on strike Mar 15 '11 at 06:36
1 Answers
0
There is a method of doing it with C++ here.
Here is another stackoverflow question that addresses a similar issue.
In short, you need to call GetNamedSecurityInfoW() method with appropriate parameters to get the security descriptor of the folder and then you have to modify the ACL of the folder through methods explained here.
-
First of all, that article is about C#, not C or C++. Second, that doesn't have anything to do with disabling network shares. It's about controlling the access privileges of individual folders. – Cody Gray - on strike Mar 15 '11 at 06:43
-
Sorry for down vote,it sets it automatic and says vote up requires 15 reputations.it's my first time to using this web,if i get sufficient reputations,i will vote it up. – AlxDong Mar 15 '11 at 08:16
-
@Andrew: I don't think you're the one who downvoted this question. It does indeed require 15 reputation points to vote up *or* down answers, so you couldn't have been the one to vote it down. And it definitely doesn't vote answers down automatically. You've done the right thing by accepting the answer, if you think it's helpful. When you get 15+ points, you can also come back and upvote, if you'd like. – Cody Gray - on strike Mar 15 '11 at 12:33
-
@Aamir: Despite my criticisms, I was not the downvoter. I get accused of that relatively often, despite my notable tendency not to cast very many downvotes, captured for all to see in my profile stats. I'm sure someone else came along and downvoted before you updated your answer. – Cody Gray - on strike Mar 15 '11 at 12:33
-
@Cody Gray: I sort of knew that it wasn't you :) That's why I specifically asked. – Aamir Mar 15 '11 at 12:38
-
Thanks all of you answer my question, but i want to know more about net share.Disable net share folder means user can't share any folders in local computer,even if user want to enable this by modifying group policy or registry. – AlxDong Mar 16 '11 at 03:12
-
@Andrew: There is no way to write a program that disables shared folders that can't be worked around by a user with sufficient permissions. Editing the Registry or the local computer's security settings can always be used to restore the functionality. As I mentioned in a comment, the proper way to solve this problem is setting Group Policies and restricting the rights of specific user accounts. This is not a problem that can be solved by writing a C++ app. – Cody Gray - on strike Mar 16 '11 at 04:14
-
@Cody Gray:Thanks for your help,I've got what i want,it's really useful. – AlxDong Mar 16 '11 at 05:29