コード例 #1
0
        public override DirectoryResponse SendRequest(DirectoryRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            DsmlRequestDocument document = new DsmlRequestDocument();

            document.Add(request);
            DsmlResponseDocument document2 = this.SendRequestHelper(document.ToXml().InnerXml);

            if (document2.Count == 0)
            {
                throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("MissingResponse"));
            }
            DirectoryResponse response = document2[0];

            if (response is DsmlErrorResponse)
            {
                ErrorResponseException exception = new ErrorResponseException((DsmlErrorResponse)response);
                throw exception;
            }
            ResultCode resultCode = response.ResultCode;

            if (((resultCode != ResultCode.Success) && (resultCode != ResultCode.CompareFalse)) && (((resultCode != ResultCode.CompareTrue) && (resultCode != ResultCode.Referral)) && (resultCode != ResultCode.ReferralV2)))
            {
                throw new DirectoryOperationException(response, OperationErrorMappings.MapResultCode((int)resultCode));
            }
            return(response);
        }
コード例 #2
0
 internal DsmlResponseDocument(StringBuilder responseString, string xpathToResponse) : this()
 {
     this.dsmlDocument = new XmlDocument();
     try
     {
         this.dsmlDocument.LoadXml(responseString.ToString());
     }
     catch (XmlException)
     {
         throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("NotWellFormedResponse"));
     }
     this.dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlBatchResponse = (XmlElement)this.dsmlDocument.SelectSingleNode(xpathToResponse, this.dsmlNS);
     if (this.dsmlBatchResponse == null)
     {
         throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("NotWellFormedResponse"));
     }
     foreach (XmlNode node in this.dsmlBatchResponse.ChildNodes)
     {
         if (node.NodeType == XmlNodeType.Element)
         {
             DirectoryResponse response = this.ConstructElement((XmlElement)node);
             this.dsmlResponse.Add(response);
         }
     }
 }
コード例 #3
0
 internal DsmlResponseDocument(StringBuilder responseString, string xpathToResponse) : this()
 {
     this.dsmlDocument = new XmlDocument();
     try
     {
         this.dsmlDocument.LoadXml(responseString.ToString());
     }
     catch (XmlException xmlException)
     {
         throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
     }
     this.dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlBatchResponse = (XmlElement)this.dsmlDocument.SelectSingleNode(xpathToResponse, this.dsmlNS);
     if (this.dsmlBatchResponse != null)
     {
         XmlNodeList childNodes = this.dsmlBatchResponse.ChildNodes;
         foreach (XmlNode childNode in childNodes)
         {
             if (childNode.NodeType != XmlNodeType.Element)
             {
                 continue;
             }
             DirectoryResponse directoryResponse = this.ConstructElement((XmlElement)childNode);
             this.dsmlResponse.Add(directoryResponse);
         }
         return;
     }
     else
     {
         throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
     }
 }
コード例 #4
0
        internal DsmlResponseDocument(HttpWebResponse resp, string xpathToResponse) : this()
        {
            // Our caller (the DsmlConnection-derived class) passes us the XPath telling us
            // how to locate the batchResponse element.  This permits us to work with
            // different transport protocols.

            // Get the response stream
            Stream       respStream       = resp.GetResponseStream();
            StreamReader respStreamReader = new StreamReader(respStream);

            try
            {
                // Load the response from the stream into the XmlDocument
                _dsmlDocument = new XmlDocument();

                try
                {
                    _dsmlDocument.Load(respStreamReader);
                }
                catch (XmlException)
                {
                    // The server didn't return well-formed XML to us
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
                }

                // Locate the batchResponse element within the response document
                _dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
                _dsmlBatchResponse = (XmlElement)_dsmlDocument.SelectSingleNode(xpathToResponse, _dsmlNS);

                if (_dsmlBatchResponse == null)
                {
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
                }

                // parse the response and put it in our internal store
                XmlNodeList nodeList = _dsmlBatchResponse.ChildNodes;

                // Unfortunately, we can't just index into the XmlNodeList,
                // because it's a list of all the nodes, not just the elements.
                // We're interested in the Nth element, not the Nth node.

                foreach (XmlNode node in nodeList)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        Debug.Assert(node is XmlElement);

                        DirectoryResponse el = ConstructElement((XmlElement)node);
                        _dsmlResponse.Add(el);
                    }
                }
            }
            finally
            {
                respStreamReader.Close();
            }
        }
コード例 #5
0
        private static string CreateMessage(DirectoryResponse response, string message)
        {
            string result = message ?? SR.DefaultOperationsError;

            if (!string.IsNullOrEmpty(response?.ErrorMessage))
            {
                result += " " + response.ErrorMessage;
            }
            return(result);
        }
コード例 #6
0
        private DirectoryResponse ConstructElement(XmlElement node)
        {
            DirectoryResponse dsmlErrorResponse = null;
            string            localName         = node.LocalName;
            string            str = localName;

            if (localName != null)
            {
                if (str == "errorResponse")
                {
                    dsmlErrorResponse = new DsmlErrorResponse(node);
                }
                else if (str == "searchResponse")
                {
                    dsmlErrorResponse = new SearchResponse(node);
                }
                else if (str == "modifyResponse")
                {
                    dsmlErrorResponse = new ModifyResponse(node);
                }
                else if (str == "addResponse")
                {
                    dsmlErrorResponse = new AddResponse(node);
                }
                else if (str == "delResponse")
                {
                    dsmlErrorResponse = new DeleteResponse(node);
                }
                else if (str == "modDNResponse")
                {
                    dsmlErrorResponse = new ModifyDNResponse(node);
                }
                else if (str == "compareResponse")
                {
                    dsmlErrorResponse = new CompareResponse(node);
                }
                else if (str == "extendedResponse")
                {
                    dsmlErrorResponse = new ExtendedResponse(node);
                }
                else if (str == "authResponse")
                {
                    dsmlErrorResponse = new DsmlAuthResponse(node);
                }
                else
                {
                    throw new DsmlInvalidDocumentException(Res.GetString("UnknownResponseElement"));
                }
                return(dsmlErrorResponse);
            }
            throw new DsmlInvalidDocumentException(Res.GetString("UnknownResponseElement"));
        }
コード例 #7
0
        private DirectoryResponse ConstructElement(XmlElement node)
        {
            DirectoryResponse el = null;

            Debug.Assert(node != null);

            switch (node.LocalName)
            {
            case DsmlConstants.DsmlErrorResponse:
                el = new DsmlErrorResponse(node);
                break;

            case DsmlConstants.DsmlSearchResponse:
                el = new SearchResponse(node);
                break;

            case DsmlConstants.DsmlModifyResponse:
                el = new ModifyResponse(node);
                break;

            case DsmlConstants.DsmlAddResponse:
                el = new AddResponse(node);
                break;

            case DsmlConstants.DsmlDelResponse:
                el = new DeleteResponse(node);
                break;

            case DsmlConstants.DsmlModDNResponse:
                el = new ModifyDNResponse(node);
                break;

            case DsmlConstants.DsmlCompareResponse:
                el = new CompareResponse(node);
                break;

            case DsmlConstants.DsmlExtendedResponse:
                el = new ExtendedResponse(node);
                break;

            case DsmlConstants.DsmlAuthResponse:
                el = new DsmlAuthResponse(node);
                break;

            default:
                throw new DsmlInvalidDocumentException(Res.GetString(Res.UnknownResponseElement));
            }

            Debug.Assert(el != null);

            return(el);
        }
コード例 #8
0
        internal DsmlResponseDocument(HttpWebResponse resp, string xpathToResponse) : this()
        {
            Stream       responseStream = resp.GetResponseStream();
            StreamReader streamReader   = new StreamReader(responseStream);

            try
            {
                this.dsmlDocument = new XmlDocument();
                try
                {
                    this.dsmlDocument.Load(streamReader);
                }
                catch (XmlException xmlException)
                {
                    throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
                }
                this.dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
                this.dsmlBatchResponse = (XmlElement)this.dsmlDocument.SelectSingleNode(xpathToResponse, this.dsmlNS);
                if (this.dsmlBatchResponse != null)
                {
                    XmlNodeList childNodes = this.dsmlBatchResponse.ChildNodes;
                    foreach (XmlNode childNode in childNodes)
                    {
                        if (childNode.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        DirectoryResponse directoryResponse = this.ConstructElement((XmlElement)childNode);
                        this.dsmlResponse.Add(directoryResponse);
                    }
                }
                else
                {
                    throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
                }
            }
            finally
            {
                streamReader.Close();
            }
        }
コード例 #9
0
        internal DsmlResponseDocument(StringBuilder responseString, string xpathToResponse) : this()
        {
            _dsmlDocument = new XmlDocument();

            try
            {
                _dsmlDocument.LoadXml(responseString.ToString());
            }
            catch (XmlException)
            {
                // The server didn't return well-formed XML to us
                throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
            }

            // Locate the batchResponse element within the response document
            _dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
            _dsmlBatchResponse = (XmlElement)_dsmlDocument.SelectSingleNode(xpathToResponse, _dsmlNS);

            if (_dsmlBatchResponse == null)
            {
                throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
            }

            // parse the response and put it in our internal store
            XmlNodeList nodeList = _dsmlBatchResponse.ChildNodes;

            // Unfortunately, we can't just index into the XmlNodeList,
            // because it's a list of all the nodes, not just the elements.
            // We're interested in the Nth element, not the Nth node.

            foreach (XmlNode node in nodeList)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    Debug.Assert(node is XmlElement);

                    DirectoryResponse el = ConstructElement((XmlElement)node);
                    _dsmlResponse.Add(el);
                }
            }
        }
コード例 #10
0
        public override DirectoryResponse SendRequest(DirectoryRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            DsmlRequestDocument doc = new DsmlRequestDocument();

            doc.Add(request);

            DsmlResponseDocument response = SendRequestHelper(doc.ToXml().InnerXml);

            if (response.Count == 0)
            {
                throw new DsmlInvalidDocumentException(Res.GetString(Res.MissingResponse));
            }

            DirectoryResponse result = response[0];

            if (result is DsmlErrorResponse)
            {
                // need to throw ErrorResponseException
                ErrorResponseException e = new ErrorResponseException((DsmlErrorResponse)result);
                throw e;
            }
            else
            {
                ResultCode error = result.ResultCode;
                if (error == ResultCode.Success || error == ResultCode.CompareFalse || error == ResultCode.CompareTrue || error == ResultCode.Referral || error == ResultCode.ReferralV2)
                {
                    return(result);
                }
                else
                {
                    throw new DirectoryOperationException(result, OperationErrorMappings.MapResultCode((int)error));
                }
            }
        }
コード例 #11
0
 public override DirectoryResponse SendRequest(DirectoryRequest request)
 {
     if (request != null)
     {
         DsmlRequestDocument dsmlRequestDocuments = new DsmlRequestDocument();
         dsmlRequestDocuments.Add(request);
         DsmlResponseDocument dsmlResponseDocuments = this.SendRequestHelper(dsmlRequestDocuments.ToXml().InnerXml);
         if (dsmlResponseDocuments.Count != 0)
         {
             DirectoryResponse item = dsmlResponseDocuments[0];
             if (item as DsmlErrorResponse == null)
             {
                 ResultCode resultCode = item.ResultCode;
                 if (resultCode == ResultCode.Success || resultCode == ResultCode.CompareFalse || resultCode == ResultCode.CompareTrue || resultCode == ResultCode.Referral || resultCode == ResultCode.ReferralV2)
                 {
                     return(item);
                 }
                 else
                 {
                     throw new DirectoryOperationException(item, OperationErrorMappings.MapResultCode((int)resultCode));
                 }
             }
             else
             {
                 ErrorResponseException errorResponseException = new ErrorResponseException((DsmlErrorResponse)item);
                 throw errorResponseException;
             }
         }
         else
         {
             throw new DsmlInvalidDocumentException(Res.GetString("MissingResponse"));
         }
     }
     else
     {
         throw new ArgumentNullException("request");
     }
 }
コード例 #12
0
		public TlsOperationException (DirectoryResponse response, string message, Exception inner)
			: base (response, message, inner)
		{
		}
コード例 #13
0
ファイル: DsmlResponseDocument.cs プロジェクト: nlhepler/mono
		public int IndexOf (DirectoryResponse value)
		{
			return list.IndexOf (value);
		}
コード例 #14
0
 public DirectoryOperationException(DirectoryResponse response) :
     base(CreateMessage(response, message: null))
 {
     Response = response;
 }
コード例 #15
0
 public int IndexOf(DirectoryResponse value)
 {
     return(list.IndexOf(value));
 }
コード例 #16
0
 public DirectoryOperationException(DirectoryResponse response, string message)
     : this(message)
 {
 }
コード例 #17
0
 public DirectoryOperationException(DirectoryResponse response, string message) : base(message)
 {
     Response = response;
 }
コード例 #18
0
		public DirectoryOperationException (DirectoryResponse response, string message)
			: this (message)
		{
		}
コード例 #19
0
		public DirectoryOperationException (DirectoryResponse response)
			: this ()
		{
		}
コード例 #20
0
 public TlsOperationException(DirectoryResponse response, string message)
     : this(response, message, null)
 {
 }
 public TlsOperationException(DirectoryResponse response) : base(response)
 {
 }
コード例 #22
0
 public TlsOperationException(DirectoryResponse response)
     : base(response, default_message)
 {
 }
コード例 #23
0
ファイル: DsmlResponseDocument.cs プロジェクト: nlhepler/mono
		public bool Contains (DirectoryResponse value)
		{
			return list.Contains (value);
		}
コード例 #24
0
 public DirectoryOperationException(DirectoryResponse response, string message, Exception inner)
     : base(CreateMessage(response, message), inner)
 {
     Response = response;
 }
コード例 #25
0
 public void Insert(int index, DirectoryResponse value)
 {
     list.Insert(index, value);
 }
コード例 #26
0
 public void Remove(DirectoryResponse value)
 {
     list.Remove(value);
 }
コード例 #27
0
ファイル: DsmlDocument.cs プロジェクト: chcosta/corefx
 public void CopyTo(DirectoryResponse[] value, int i)
 {
     _dsmlResponse.CopyTo(value, i);
 }
コード例 #28
0
ファイル: DsmlResponseDocument.cs プロジェクト: nlhepler/mono
		public void Remove (DirectoryResponse value)
		{
			list.Remove (value);
		}
コード例 #29
0
 public DirectoryOperationException(DirectoryResponse response) : base(SR.DefaultOperationsError)
 {
     Response = response;
 }
コード例 #30
0
ファイル: DsmlResponseDocument.cs プロジェクト: nlhepler/mono
		public void Insert (int index, DirectoryResponse value)
		{
			list.Insert (index, value);
		}
コード例 #31
0
ファイル: DirectoryException.cs プロジェクト: xuanmu/corefx
 public DirectoryOperationException(DirectoryResponse response) : base(String.Format(CultureInfo.CurrentCulture, SR.DefaultOperationsError))
 {
     this.response = response;
 }
コード例 #32
0
 public TlsOperationException(DirectoryResponse response) : base(response)
 {
 }
コード例 #33
0
 public DirectoryOperationException(DirectoryResponse response)
     : this()
 {
 }
コード例 #34
0
ファイル: DirectoryException.cs プロジェクト: chcosta/corefx
 public DirectoryOperationException(DirectoryResponse response) : base(Res.GetString(Res.DefaultOperationsError))
 {
     this.response = response;
 }
コード例 #35
0
 public DirectoryOperationException(DirectoryResponse response) : base(Res.GetString("DefaultOperationsError"))
 {
     this.response = response;
 }
コード例 #36
0
ファイル: DsmlResponseDocument.cs プロジェクト: nlhepler/mono
		public int Add (DirectoryResponse request)
		{
			return list.Add (request);
		}
コード例 #37
0
 public bool Contains(DirectoryResponse value)
 {
     return(list.Contains(value));
 }
コード例 #38
0
		public TlsOperationException (DirectoryResponse response)
			: base (response, default_message)
		{
		}
コード例 #39
0
 public TlsOperationException(DirectoryResponse response, string message, Exception inner) : base(response, message, inner)
 {
 }
コード例 #40
0
		public TlsOperationException (DirectoryResponse response, string message)
			: this (response, message, null)
		{
		}
コード例 #41
0
ファイル: DirectoryException.cs プロジェクト: chcosta/corefx
 public DirectoryOperationException(DirectoryResponse response, string message, Exception inner) : base(message, inner)
 {
     this.response = response;
 }
コード例 #42
0
ファイル: DsmlResponseDocument.cs プロジェクト: nlhepler/mono
		public void CopyTo (DirectoryResponse [] value, int i)
		{
			list.CopyTo (value, i);
		}
コード例 #43
0
 public DirectoryOperationException(DirectoryResponse response, string message, Exception inner) : base(message, inner)
 {
     this.response = response;
 }
コード例 #44
0
 public int Add(DirectoryResponse request)
 {
     return(list.Add(request));
 }