Пример #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 NetrShareEnumResponse GetNetrShareEnumResponse(NetrShareEnumRequest request)
        {
            NetrShareEnumResponse response = new NetrShareEnumResponse();

            switch (request.InfoStruct.Level)
            {
            case 0:
            {
                // We ignore request.PreferedMaximumLength
                ShareInfo0Container info = new ShareInfo0Container();
                foreach (string shareName in m_shares)
                {
                    info.Add(new ShareInfo0Entry(shareName));
                }
                response.InfoStruct   = new ShareEnum(info);
                response.TotalEntries = (uint)m_shares.Count;
                response.Result       = Win32Error.ERROR_SUCCESS;
                return(response);
            }

            case 1:
            {
                // We ignore request.PreferedMaximumLength
                ShareInfo1Container info = new ShareInfo1Container();
                foreach (string shareName in m_shares)
                {
                    info.Add(new ShareInfo1Entry(shareName, new ShareTypeExtended(ShareType.DiskDrive)));
                }
                response.InfoStruct   = new ShareEnum(info);
                response.TotalEntries = (uint)m_shares.Count;
                response.Result       = Win32Error.ERROR_SUCCESS;
                return(response);
            }

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

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