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); } } }
public void Read(NDRParser parser) { parser.BeginStructure(); // SHARE_ENUM_STRUCT Level = parser.ReadUInt32(); parser.BeginStructure(); // SHARE_ENUM_UNION // 14.3.8 - For a non-encapsulated union, the discriminant is marshalled into the transmitted data stream twice. // once as the field or parameter, which is referenced by the switch_is construct, in the procedure argument list; // and once as the first part of the union representation. uint level = parser.ReadUInt32(); switch (level) { case 0: ShareInfo0Container info0 = null; parser.ReadEmbeddedStructureFullPointer <ShareInfo0Container>(ref info0); Info = info0; break; case 1: ShareInfo1Container info1 = null; parser.ReadEmbeddedStructureFullPointer <ShareInfo1Container>(ref info1); Info = info1; break; case 2: case 501: case 502: case 503: throw new NotImplementedException(); default: break; } parser.EndStructure(); // SHARE_ENUM_UNION parser.EndStructure(); // SHARE_ENUM_STRUCT }