示例#1
0
        public override byte[] GetResponseBytes(ushort opNum, byte[] requestBytes)
        {
            switch ((ServerServiceOpName)opNum)
            {
            case ServerServiceOpName.NetrShareEnum:
            {
                NetrShareEnumRequest  request  = new NetrShareEnumRequest(requestBytes);
                NetrShareEnumResponse response = GetNetrShareEnumResponse(request);
                return(response.GetBytes());
            }

            case ServerServiceOpName.NetrShareGetInfo:
            {
                NetrShareGetInfoRequest  request  = new NetrShareGetInfoRequest(requestBytes);
                NetrShareGetInfoResponse response = GetNetrShareGetInfoResponse(request);
                return(response.GetBytes());
            }

            case ServerServiceOpName.NetrServerGetInfo:
            {
                NetrServerGetInfoRequest  request  = new NetrServerGetInfoRequest(requestBytes);
                NetrServerGetInfoResponse response = GetNetrWkstaGetInfoResponse(request);
                return(response.GetBytes());
            }

            default:
                throw new UnsupportedOpNumException();
            }
        }
示例#2
0
        public NetrShareGetInfoResponse GetNetrShareGetInfoResponse(NetrShareGetInfoRequest request)
        {
            int shareIndex = IndexOfShare(request.NetName);

            NetrShareGetInfoResponse response = new NetrShareGetInfoResponse();

            if (shareIndex == -1)
            {
                response.InfoStruct = new ShareInfo(request.Level);
                response.Result     = Win32Error.NERR_NetNameNotFound;
                return(response);
            }

            switch (request.Level)
            {
            case 0:
            {
                ShareInfo0Entry info = new ShareInfo0Entry(m_shares[shareIndex]);
                response.InfoStruct = new ShareInfo(info);
                response.Result     = Win32Error.ERROR_SUCCESS;
                return(response);
            }

            case 1:
            {
                ShareInfo1Entry info = new ShareInfo1Entry(m_shares[shareIndex], new ShareTypeExtended(ShareType.DiskDrive));
                response.InfoStruct = new ShareInfo(info);
                response.Result     = Win32Error.ERROR_SUCCESS;
                return(response);
            }

            case 2:
            {
                ShareInfo2Entry info = new ShareInfo2Entry(m_shares[shareIndex], new ShareTypeExtended(ShareType.DiskDrive));
                response.InfoStruct = new ShareInfo(info);
                response.Result     = Win32Error.ERROR_SUCCESS;
                return(response);
            }

            case 501:
            case 502:
            case 503:
            case 1005:
            {
                response.InfoStruct = new ShareInfo(request.Level);
                response.Result     = Win32Error.ERROR_NOT_SUPPORTED;
                return(response);
            }

            default:
            {
                response.InfoStruct = new ShareInfo(request.Level);
                response.Result     = Win32Error.ERROR_INVALID_LEVEL;
                return(response);
            }
            }
        }