/// <summary> returns a string of information about the exception and the
        /// the nested exceptions, if any.
        /// </summary>
        public override System.String ToString()
        {
            System.String msg, tmsg;

            // Format the basic exception information
            msg = getExceptionString("LdapReferralException");

            // Add failed referral information
            if ((System.Object)failedReferral != null)
            {
                tmsg = ResourcesHandler.getMessage("FAILED_REFERRAL", new System.Object[] { "LdapReferralException", failedReferral });
                // If found no string from resource file, use a default string
                if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
                {
                    tmsg = "LdapReferralException: Failed Referral: " + failedReferral;
                }
                msg = msg + '\n' + tmsg;
            }

            // Add referral information, display all the referrals in the list
            if (referrals != null)
            {
                for (int i = 0; i < referrals.Length; i++)
                {
                    tmsg = ResourcesHandler.getMessage("REFERRAL_ITEM", new System.Object[] { "LdapReferralException", referrals[i] });
                    // If found no string from resource file, use a default string
                    if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
                    {
                        tmsg = "LdapReferralException: Referral: " + referrals[i];
                    }
                    msg = msg + '\n' + tmsg;
                }
            }
            return(msg);
        }
        /// <summary> builds a string of information about the exception and the
        /// the nested exceptions, if any.
        ///
        /// </summary>
        /// <param name="exception">The name of the exception class
        /// </param>
        /* package */
        internal virtual string getExceptionString(string exception)
        {
            string tmsg;

            // Format the basic exception information

            // Craft a string from the resouce file
            string msg = ResourcesHandler.getMessage("TOSTRING", new object[] { exception, base.Message, resultCode, resultCodeToString() });

            // If found no string from resource file, use a default string
            if (msg.ToUpper().Equals("TOSTRING".ToUpper()))
            {
                msg = exception + ": (" + resultCode + ") " + resultCodeToString();
            }

            // Add server message
            if (serverMessage != null && serverMessage.Length != 0)
            {
                tmsg = ResourcesHandler.getMessage("SERVER_MSG", new object[] { exception, serverMessage });
                // If found no string from resource file, use a default string
                if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
                {
                    tmsg = exception + ": Server Message: " + serverMessage;
                }

                msg = msg + '\n' + tmsg;
            }

            // Add Matched DN message
            if (matchedDN != null)
            {
                tmsg = ResourcesHandler.getMessage("MATCHED_DN", new object[] { exception, matchedDN });
                // If found no string from resource file, use a default string
                if (tmsg.ToUpper().Equals("MATCHED_DN".ToUpper()))
                {
                    tmsg = exception + ": Matched DN: " + matchedDN;
                }

                msg = msg + '\n' + tmsg;
            }

            if (rootException != null)
            {
                msg = msg + '\n' + rootException.ToString();
            }
            return(msg);
        }