public RpcMessageHeader(XdrDataReader reader) { TransactionId = reader.ReadUInt32(); RpcMessageType type = (RpcMessageType)reader.ReadInt32(); if (type != RpcMessageType.Reply) { throw new NotSupportedException("Parsing RPC call messages"); } ReplyHeader = new RpcReplyHeader(reader); }
private static string GenerateMessage(RpcReplyHeader reply) { if (reply.Status == RpcReplyStatus.Accepted) { switch (reply.AcceptReply.AcceptStatus) { case RpcAcceptStatus.Success: return("RPC success"); case RpcAcceptStatus.ProgramUnavailable: return("RPC program unavailable"); case RpcAcceptStatus.ProgramVersionMismatch: if (reply.AcceptReply.MismatchInfo.Low == reply.AcceptReply.MismatchInfo.High) { return("RPC program version mismatch, server supports version " + reply.AcceptReply.MismatchInfo.Low); } else { return("RPC program version mismatch, server supports versions " + reply.AcceptReply.MismatchInfo.Low + " through " + reply.AcceptReply.MismatchInfo.High); } case RpcAcceptStatus.ProcedureUnavailable: return("RPC procedure unavailable"); case RpcAcceptStatus.GarbageArguments: return("RPC corrupt procedure arguments"); default: return("RPC failure"); } } else { if (reply.RejectedReply.Status == RpcRejectedStatus.AuthError) { switch (reply.RejectedReply.AuthenticationStatus) { case RpcAuthenticationStatus.BadCredentials: return("RPC authentication credentials bad"); case RpcAuthenticationStatus.RejectedCredentials: return("RPC rejected authentication credentials"); case RpcAuthenticationStatus.BadVerifier: return("RPC bad authentication verifier"); case RpcAuthenticationStatus.RejectedVerifier: return("RPC rejected authentication verifier"); case RpcAuthenticationStatus.TooWeak: return("RPC authentication credentials too weak"); default: return("RPC authentication failure"); } } else { if (reply.RejectedReply.MismatchInfo != null) { return(string.Format(CultureInfo.InvariantCulture, "RPC protocol version mismatch, server supports versions {0} through {1}", reply.RejectedReply.MismatchInfo.Low, reply.RejectedReply.MismatchInfo.High)); } else { return("RPC protocol version mismatch, server didn't indicate supported versions"); } } } }
/// <summary> /// Initializes a new instance of the RpcException class. /// </summary> /// <param name="reply">The RPC reply from the server.</param> internal RpcException(RpcReplyHeader reply) : base(GenerateMessage(reply)) { }