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 SendRequest(DsmlRequestDocument request)
 {
     if (request == null)
     {
         throw new ArgumentNullException("request");
     }
     DsmlResponseDocument document = this.SendRequestHelper(request.ToXml().InnerXml);
     if ((request.Count > 0) && (document.Count == 0))
     {
         throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("MissingResponse"));
     }
     return document;
 }
Exemplo n.º 3
0
        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 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;
 }
Exemplo n.º 5
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));
                }
            }
        }
Exemplo n.º 6
0
        public DsmlResponseDocument SendRequest(DsmlRequestDocument request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            DsmlResponseDocument responseDoc = SendRequestHelper(request.ToXml().InnerXml);
            if (request.Count > 0 && responseDoc.Count == 0)
                throw new DsmlInvalidDocumentException(Res.GetString(Res.MissingResponse));

            return responseDoc;
        }
Exemplo n.º 7
0
		public IAsyncResult BeginSendRequest (DsmlRequestDocument request, AsyncCallback callback, object state)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 8
0
		public DsmlResponseDocument SendRequest (DsmlRequestDocument request)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 9
0
		public DsmlResponseDocument SendRequest(DsmlRequestDocument request)
		{
			if (request != null)
			{
				DsmlResponseDocument dsmlResponseDocuments = this.SendRequestHelper(request.ToXml().InnerXml);
				if (request.Count <= 0 || dsmlResponseDocuments.Count != 0)
				{
					return dsmlResponseDocuments;
				}
				else
				{
					throw new DsmlInvalidDocumentException(Res.GetString("MissingResponse"));
				}
			}
			else
			{
				throw new ArgumentNullException("request");
			}
		}
Exemplo n.º 10
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");
			}
		}
Exemplo n.º 11
0
		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");
			}
		}