locked
how can I create a new WHS Share with full access given to all users? RRS feed

  • Question

  • I'm trying to create a new WHS Share in an add-in.  The Share is created okay but permissions for users are not enabled.  That is, all users have "user Access = none" ... does anyone know how to set full access to all users by default?  thanks.

    Here's the C# code I'm using...

                IWHSInfo2 Info2 = Info as IWHSInfo2;
                IShareInfo2 share = Info2.CreateShare(ShareName, "my new share", 0);
                DirectoryInfo DirInfo = new DirectoryInfo(share.Path);
                DirectorySecurity dSecurity = DirInfo.GetAccessControl();
                // note, SID of S-1-1-0 = "Everyone"
                dSecurity.AddAccessRule(new FileSystemAccessRule("S-1-1-0", FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow));
                DirInfo.SetAccessControl(dSecurity);
    Sunday, December 6, 2009 5:08 AM

Answers

  • Everything you do with Windows Home Server shares has to be done through Windows Home Server. You're trying to work directly with the file system, which may cause problems. So you're using the wrong method of the wrong object. Try IShareInfo2.SetPermissions() instead.
    I'm not on the WHS team, I just post a lot. :)
    Sunday, December 6, 2009 1:09 PM
    Moderator

All replies

  • Everything you do with Windows Home Server shares has to be done through Windows Home Server. You're trying to work directly with the file system, which may cause problems. So you're using the wrong method of the wrong object. Try IShareInfo2.SetPermissions() instead.
    I'm not on the WHS team, I just post a lot. :)
    Sunday, December 6, 2009 1:09 PM
    Moderator
  • Great! That did the trick.  Thanks for the pointer.
    Monday, December 7, 2009 3:33 AM