public void Abort(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!(asyncResult is DsmlAsyncResult)) { throw new ArgumentException(Res.GetString(Res.NotReturnedAsyncResult, "asyncResult")); } if (!_httpConnectionTable.Contains(asyncResult)) { throw new ArgumentException(Res.GetString(Res.InvalidAsyncResult)); } HttpWebRequest request = (HttpWebRequest)(_httpConnectionTable[asyncResult]); // remove the asyncResult from our connection table _httpConnectionTable.Remove(asyncResult); // cancel the request request.Abort(); DsmlAsyncResult result = (DsmlAsyncResult)asyncResult; result.resultObject.abortCalled = true; }
public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state) { if (request != null) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)this.directoryIdentifier).ServerUri); this.PrepareHttpWebRequest(httpWebRequest); StringBuilder stringBuilder = new StringBuilder(0x400); this.BeginSOAPRequest(ref stringBuilder); stringBuilder.Append(request.ToXml().InnerXml); this.EndSOAPRequest(ref stringBuilder); RequestState requestState = new RequestState(); requestState.request = httpWebRequest; requestState.requestString = stringBuilder.ToString(); DsmlAsyncResult dsmlAsyncResult = new DsmlAsyncResult(callback, state); dsmlAsyncResult.resultObject = requestState; if (request.Count > 0) { dsmlAsyncResult.hasValidRequest = true; } requestState.dsmlAsync = dsmlAsyncResult; this.httpConnectionTable.Add(dsmlAsyncResult, httpWebRequest); httpWebRequest.BeginGetRequestStream(new AsyncCallback(DsmlSoapHttpConnection.RequestStreamCallback), requestState); return(dsmlAsyncResult); } else { throw new ArgumentNullException("request"); } }
public void Abort(IAsyncResult asyncResult) { if (asyncResult != null) { if (asyncResult as DsmlAsyncResult != null) { if (this.httpConnectionTable.Contains(asyncResult)) { HttpWebRequest item = (HttpWebRequest)this.httpConnectionTable[asyncResult]; this.httpConnectionTable.Remove(asyncResult); item.Abort(); DsmlAsyncResult dsmlAsyncResult = (DsmlAsyncResult)asyncResult; dsmlAsyncResult.resultObject.abortCalled = true; return; } else { throw new ArgumentException(Res.GetString("InvalidAsyncResult")); } } else { object[] objArray = new object[1]; objArray[0] = "asyncResult"; throw new ArgumentException(Res.GetString("NotReturnedAsyncResult", objArray)); } } else { throw new ArgumentNullException("asyncResult"); } }
public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state) { if (request == null) { throw new ArgumentNullException("request"); } HttpWebRequest dsmlConnection = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)base.directoryIdentifier).ServerUri); this.PrepareHttpWebRequest(dsmlConnection); StringBuilder buffer = new StringBuilder(0x400); this.BeginSOAPRequest(ref buffer); buffer.Append(request.ToXml().InnerXml); this.EndSOAPRequest(ref buffer); RequestState state2 = new RequestState { request = dsmlConnection, requestString = buffer.ToString() }; DsmlAsyncResult key = new DsmlAsyncResult(callback, state) { resultObject = state2 }; if (request.Count > 0) { key.hasValidRequest = true; } state2.dsmlAsync = key; this.httpConnectionTable.Add(key, dsmlConnection); dsmlConnection.BeginGetRequestStream(new AsyncCallback(DsmlSoapHttpConnection.RequestStreamCallback), state2); return(key); }
public DsmlResponseDocument EndSendRequest(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!(asyncResult is DsmlAsyncResult)) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("NotReturnedAsyncResult", new object[] { "asyncResult" })); } if (!this.httpConnectionTable.Contains(asyncResult)) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("InvalidAsyncResult")); } this.httpConnectionTable.Remove(asyncResult); DsmlAsyncResult result = (DsmlAsyncResult)asyncResult; asyncResult.AsyncWaitHandle.WaitOne(); if (result.resultObject.exception != null) { throw result.resultObject.exception; } DsmlResponseDocument document = new DsmlResponseDocument(result.resultObject.responseString, "se:Envelope/se:Body/dsml:batchResponse"); this.debugResponse = document.ResponseString; if (result.hasValidRequest && (document.Count == 0)) { throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("MissingResponse")); } return(document); }
public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state) { if (request == null) { throw new ArgumentNullException("request"); } // construct the new httpwebrequest object HttpWebRequest asyncConnection = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)directoryIdentifier).ServerUri); // Do the generic preparation of the request PrepareHttpWebRequest(asyncConnection); // construct the request string StringBuilder requestStringBuffer = new StringBuilder(1024); // Begin the SOAP Envelope, attaching the sessionID if applicable BeginSOAPRequest(ref requestStringBuffer); // append the document requestStringBuffer.Append(request.ToXml().InnerXml); // Finish writing the SOAP Envelope EndSOAPRequest(ref requestStringBuffer); // construct the state object RequestState rs = new RequestState(); rs.request = asyncConnection; rs.requestString = requestStringBuffer.ToString(); // construct the async object DsmlAsyncResult asyncResult = new DsmlAsyncResult(callback, state); asyncResult.resultObject = rs; // give hint about whether this is an empty request or not so later we could validate the response if (request.Count > 0) { asyncResult.hasValidRequest = true; } // result object needs to have a handle on the waitobject, so later it could wake up the EndSendRequest call rs.dsmlAsync = asyncResult; // add connection-async pair to our table _httpConnectionTable.Add(asyncResult, asyncConnection); // begin the requeststream call asyncConnection.BeginGetRequestStream(new AsyncCallback(RequestStreamCallback), rs); // return the asyncResult return((IAsyncResult)asyncResult); }
public DsmlResponseDocument EndSendRequest(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!(asyncResult is DsmlAsyncResult)) { throw new ArgumentException(Res.GetString(Res.NotReturnedAsyncResult, "asyncResult")); } if (!_httpConnectionTable.Contains(asyncResult)) { throw new ArgumentException(Res.GetString(Res.InvalidAsyncResult)); } // remove the asyncResult from our connection table _httpConnectionTable.Remove(asyncResult); DsmlAsyncResult result = (DsmlAsyncResult)asyncResult; asyncResult.AsyncWaitHandle.WaitOne(); // Process the response // see if any exception occurs, if yes, then throw the exception if (result.resultObject.exception != null) { throw result.resultObject.exception; } DsmlResponseDocument dsmlResponseDoc = new DsmlResponseDocument( result.resultObject.responseString, "se:Envelope/se:Body/dsml:batchResponse" ); _debugResponse = dsmlResponseDoc.ResponseString; // validate the response if (result.hasValidRequest && dsmlResponseDoc.Count == 0) { throw new DsmlInvalidDocumentException(Res.GetString(Res.MissingResponse)); } return(dsmlResponseDoc); }
public DsmlResponseDocument EndSendRequest(IAsyncResult asyncResult) { if (asyncResult != null) { if (asyncResult as DsmlAsyncResult != null) { if (this.httpConnectionTable.Contains(asyncResult)) { this.httpConnectionTable.Remove(asyncResult); DsmlAsyncResult dsmlAsyncResult = (DsmlAsyncResult)asyncResult; asyncResult.AsyncWaitHandle.WaitOne(); if (dsmlAsyncResult.resultObject.exception == null) { DsmlResponseDocument dsmlResponseDocuments = new DsmlResponseDocument(dsmlAsyncResult.resultObject.responseString, "se:Envelope/se:Body/dsml:batchResponse"); this.debugResponse = dsmlResponseDocuments.ResponseString; if (!dsmlAsyncResult.hasValidRequest || dsmlResponseDocuments.Count != 0) { return(dsmlResponseDocuments); } else { throw new DsmlInvalidDocumentException(Res.GetString("MissingResponse")); } } else { throw dsmlAsyncResult.resultObject.exception; } } else { throw new ArgumentException(Res.GetString("InvalidAsyncResult")); } } else { object[] objArray = new object[1]; objArray[0] = "asyncResult"; throw new ArgumentException(Res.GetString("NotReturnedAsyncResult", objArray)); } } else { throw new ArgumentNullException("asyncResult"); } }
public void Abort(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!(asyncResult is DsmlAsyncResult)) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("NotReturnedAsyncResult", new object[] { "asyncResult" })); } if (!this.httpConnectionTable.Contains(asyncResult)) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("InvalidAsyncResult")); } HttpWebRequest request = (HttpWebRequest)this.httpConnectionTable[asyncResult]; this.httpConnectionTable.Remove(asyncResult); request.Abort(); DsmlAsyncResult result = (DsmlAsyncResult)asyncResult; result.resultObject.abortCalled = true; }
public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state) { if (request == null) { throw new ArgumentNullException("request"); } HttpWebRequest dsmlConnection = (HttpWebRequest) WebRequest.Create(((DsmlDirectoryIdentifier) base.directoryIdentifier).ServerUri); this.PrepareHttpWebRequest(dsmlConnection); StringBuilder buffer = new StringBuilder(0x400); this.BeginSOAPRequest(ref buffer); buffer.Append(request.ToXml().InnerXml); this.EndSOAPRequest(ref buffer); RequestState state2 = new RequestState { request = dsmlConnection, requestString = buffer.ToString() }; DsmlAsyncResult key = new DsmlAsyncResult(callback, state) { resultObject = state2 }; if (request.Count > 0) { key.hasValidRequest = true; } state2.dsmlAsync = key; this.httpConnectionTable.Add(key, dsmlConnection); dsmlConnection.BeginGetRequestStream(new AsyncCallback(DsmlSoapHttpConnection.RequestStreamCallback), state2); return key; }
public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state) { if (request == null) throw new ArgumentNullException("request"); // construct the new httpwebrequest object HttpWebRequest asyncConnection = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)directoryIdentifier).ServerUri); // Do the generic preparation of the request PrepareHttpWebRequest(asyncConnection); // construct the request string StringBuilder requestStringBuffer = new StringBuilder(1024); // Begin the SOAP Envelope, attaching the sessionID if applicable BeginSOAPRequest(ref requestStringBuffer); // append the document requestStringBuffer.Append(request.ToXml().InnerXml); // Finish writing the SOAP Envelope EndSOAPRequest(ref requestStringBuffer); // construct the state object RequestState rs = new RequestState(); rs.request = asyncConnection; rs.requestString = requestStringBuffer.ToString(); // construct the async object DsmlAsyncResult asyncResult = new DsmlAsyncResult(callback, state); asyncResult.resultObject = rs; // give hint about whether this is an empty request or not so later we could validate the response if (request.Count > 0) asyncResult.hasValidRequest = true; // result object needs to have a handle on the waitobject, so later it could wake up the EndSendRequest call rs.dsmlAsync = asyncResult; // add connection-async pair to our table _httpConnectionTable.Add(asyncResult, asyncConnection); // begin the requeststream call asyncConnection.BeginGetRequestStream(new AsyncCallback(RequestStreamCallback), rs); // return the asyncResult return (IAsyncResult)asyncResult; }
public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state) { if (request != null) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)this.directoryIdentifier).ServerUri); this.PrepareHttpWebRequest(httpWebRequest); StringBuilder stringBuilder = new StringBuilder(0x400); this.BeginSOAPRequest(ref stringBuilder); stringBuilder.Append(request.ToXml().InnerXml); this.EndSOAPRequest(ref stringBuilder); RequestState requestState = new RequestState(); requestState.request = httpWebRequest; requestState.requestString = stringBuilder.ToString(); DsmlAsyncResult dsmlAsyncResult = new DsmlAsyncResult(callback, state); dsmlAsyncResult.resultObject = requestState; if (request.Count > 0) { dsmlAsyncResult.hasValidRequest = true; } requestState.dsmlAsync = dsmlAsyncResult; this.httpConnectionTable.Add(dsmlAsyncResult, httpWebRequest); httpWebRequest.BeginGetRequestStream(new AsyncCallback(DsmlSoapHttpConnection.RequestStreamCallback), requestState); return dsmlAsyncResult; } else { throw new ArgumentNullException("request"); } }