Exemplo n.º 1
0
 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";
             }
         }
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public bool Equals(RpcReplyHeader other)
        {
            if (other == null)
            {
                return(false);
            }

            return(other.Status == Status &&
                   object.Equals(other.AcceptReply, AcceptReply) &&
                   object.Equals(other.RejectedReply, RejectedReply));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 /// <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))
 {
 }
Exemplo n.º 6
0
        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");
                    }
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a new instance for a server-indicated error
 /// </summary>
 /// <param name="reply">The RPC reply from the server.</param>
 internal RpcException(RpcReplyHeader reply)
     : base(GenerateMessage(reply))
 {
 }