Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / April 2007

Tip: Looking for answers? Try searching our database.

create shared new directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt F - 08 Apr 2007 00:14 GMT
I need to create a folder in code, and also set sharing to being shared to
everyone with full control (or some such variation of security)

What I'm doing now is:

If Not System.IO.Directory.Exists(My.Application.Info.DirectoryPath &
"\NewTestFolder") Then

System.IO.Directory.CreateDirectory(My.Application.Info.DirectoryPath &
"\NewTestFolder")

End If

It appears there is a second parameter to the .CreateDirectory method, but
the type of "directorysecurity" which definitely sounds promising, but
trying to determine how to use this is proving a bit of a challenge.
Jeffrey Tan[MSFT] - 09 Apr 2007 04:15 GMT
Hi Matt ,

If you want to configure the DACL of the directory to allow everyone on
your machine to full control this folder, then you are looking at the
correct parameter. The "DirectorySecurity Class" below contains the sample
code regarding how to setup the DirectorySecurity object:
http://msdn2.microsoft.com/en-us/library/system.security.accesscontrol.direc
torysecurity.aspx

The link below also contains some ACL programming stuff:
"How To Program ACLs"
http://pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToProgramACLs.ht
ml

However, if you want to share this directory with others from remote
computer through LAN file share, there is another story.

In file share, there are 2 stages of access check: DACL access check and
file share permission check. Only account authentication can pass these 2
permission sets stages, can it successfully access the shared files.

Sharing Permission set can be configured through "Permissions" button in
"Sharing" tabpage in folder property dialog, while NTFS DACL Permission set
can be configured through button in "Security" tabpage in folder property
dialog.

.Net contains build-in support to configure the DACL permission of
directories/files and I have shown you the sample code snippet in the first
paragraph. To configure the share permission, there is no build-in support.
We have to p/invoke NetUseAdd Win32 API for this task. My original reply
below and the codeproject article demonstrates this idea with code snippet
in C#:
http://groups.google.com/group/microsoft.public.platformsdk.security/msg/063
d7b08b29e5642?hl=zh-CN&
"How to create a file share using .NET framework"
http://www.codeproject.com/dotnet/pinvokeaddshare.asp

Finally, the article below contains very detaild ACL programming in
.Net2.0, it should be informative if you are curious about security
programming in .Net:
http://www.codeproject.com/csharp/accessctrl3.asp

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.