示例#1
0
        public SMBServer(ShareCollection shares, IPAddress serverAddress, SMBTransportType transport)
        {
            m_shares        = shares;
            m_serverAddress = serverAddress;
            m_serverGuid    = Guid.NewGuid();
            m_transport     = transport;

            m_services = new NamedPipeShare(shares.ListShares());
        }
示例#2
0
        internal static SMBCommand GetTreeConnectResponse(SMBHeader header, TreeConnectAndXRequest request, StateObject state, ShareCollection shares)
        {
            bool   isExtended   = (request.Flags & TreeConnectFlags.ExtendedResponse) > 0;
            string relativePath = ServerPathUtils.GetRelativeServerPath(request.Path);

            if (String.Equals(relativePath, "\\IPC$", StringComparison.InvariantCultureIgnoreCase))
            {
                header.TID = state.AddConnectedTree(relativePath);
                if (isExtended)
                {
                    return(CreateTreeConnectResponseExtended(ServiceName.NamedPipe));
                }
                else
                {
                    return(CreateTreeConnectResponse(ServiceName.NamedPipe));
                }
            }
            else
            {
                FileSystemShare share = shares.GetShareFromRelativePath(relativePath);
                if (share == null)
                {
                    header.Status = NTStatus.STATUS_OBJECT_PATH_NOT_FOUND;
                    return(new ErrorResponse(CommandName.SMB_COM_TREE_CONNECT_ANDX));
                }
                else
                {
                    string userName = state.GetConnectedUserName(header.UID);
                    if (!share.HasReadAccess(userName))
                    {
                        header.Status = NTStatus.STATUS_ACCESS_DENIED;
                        return(new ErrorResponse(CommandName.SMB_COM_TREE_CONNECT_ANDX));
                    }
                    else
                    {
                        header.TID = state.AddConnectedTree(relativePath);
                        if (isExtended)
                        {
                            return(CreateTreeConnectResponseExtended(ServiceName.DiskShare));
                        }
                        else
                        {
                            return(CreateTreeConnectResponse(ServiceName.DiskShare));
                        }
                    }
                }
            }
        }