SharpCifs.Smb.SmbFile.GetShareSecurity C# (CSharp) Method

GetShareSecurity() public method

Return an array of Access Control Entry (ACE) objects representing the share permissions on the share exporting this file or directory.
Return an array of Access Control Entry (ACE) objects representing the share permissions on the share exporting this file or directory. If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned.

Note that this is different from calling getSecurity on a share. There are actually two different ACLs for shares - the ACL on the share and the ACL on the folder being shared. Go to Computer Management > System Tools > Shared Folders > Shares and look at the Properties for a share. You will see two tabs - one for "Share Permissions" and another for "Security". These correspond to the ACLs returned by getShareSecurity and getSecurity respectively.

public GetShareSecurity ( bool resolveSids ) : Ace[]
resolveSids bool /// Attempt to resolve the SIDs within each ACE form /// their numeric representation to their corresponding account names. ///
return Ace[]
        public virtual Ace[] GetShareSecurity(bool resolveSids)
        {
            string p = Url.AbsolutePath;
            MsrpcShareGetInfo rpc;
            DcerpcHandle handle;
            Ace[] aces;
            ResolveDfs(null);
            string server = GetServerWithDfs();
            rpc = new MsrpcShareGetInfo(server, Tree.Share);
            handle = DcerpcHandle.GetHandle("ncacn_np:" + server + "[\\PIPE\\srvsvc]", Auth);
            try
            {
                handle.Sendrecv(rpc);
                if (rpc.Retval != 0)
                {
                    throw new SmbException(rpc.Retval, true);
                }
                aces = rpc.GetSecurity();
                if (aces != null)
                {
                    ProcessAces(aces, resolveSids);
                }
            }
            finally
            {
                try
                {
                    handle.Close();
                }
                catch (IOException ioe)
                {
                    if (Log.Level >= 1)
                    {
                        Runtime.PrintStackTrace(ioe, Log);
                    }
                }
            }
            return aces;
        }