Solved

Programmatically setting folder/file permission for sharing folders

Posted on 2004-09-22
8
1,425 Views
Last Modified: 2008-02-01
Hello!
I am trying to find a way of sharing a folder on the computer as a network share.
This is very easy done manually, but I need some help in finding out how this can be done programmatically.

I need to do the following (ASAP........)
1. Set a specified folder as a network share including access permissions.
2. Set the different properties for files/folders in the share

How can this be achieved?
Could somebody help me with some code examples?  Preferably in VB.NET, but C# is also OK.
Or links to pages that give this information?

Thank you for your input!
Jorn
0
Comment
Question by:epihandy
  • 3
  • 2
8 Comments
 
LVL 3

Accepted Solution

by:
mAjKoL earned 300 total points
ID: 12130751
0
 

Author Comment

by:epihandy
ID: 12130812
Thanx, this looks very promising!
I will look at it at check whether this solves it!
Be back!
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12131453
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:epihandy
ID: 12132193
The last sample is working and is able to create the share, however I don't understand how to set the different security settings of the folder.
It needs to be different for different users. It only shares the folder with full permissions for all, and that is very risky......

I found this info, but that was all:
In SHARE_INFO_502 structure you can specify the permissions by specifying a Security Descriptor that has the required ACL. If you set the value of shi502_security_descriptor variable to 0, then a null DACL is set on the file share meaning that Everybody has full access to this share.

Thanx
0
 
LVL 18

Assisted Solution

by:armoghan
armoghan earned 200 total points
ID: 12132396
these links may help you learn more about the network API
http://custom.programming-in.net/articles/art9-2.asp?lib=netapi32.dll
http://www.codeproject.com/csharp/groupandmembers.asp


the article is also present here and you can communicate with the Author

http://www.codeproject.com/dotnet/pinvokeaddshare.asp

I have not worked on this thing in depth :(
0
 

Author Comment

by:epihandy
ID: 12338107
Just a minute!
I will split the points!
Sorry for the delay!
I simply forgot to do it!
THANX FOR YOUR ANSWERS!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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