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); }
public void Remove(DirectoryRequest value) { if (value == null) { throw new ArgumentNullException("value"); } this.dsmlRequests.Remove(value); }
public void Insert(int index, DirectoryRequest value) { if (value == null) { throw new ArgumentNullException("value"); } this.dsmlRequests.Insert(index, value); }
public int Add(DirectoryRequest request) { if (request == null) { throw new ArgumentNullException("request"); } return this.dsmlRequests.Add(request); }
public int Add(DirectoryRequest request) { if (request == null) { throw new ArgumentNullException("request"); } return(this.dsmlRequests.Add(request)); }
public int IndexOf(DirectoryRequest value) { if (value == null) { throw new ArgumentNullException("value"); } return(this.dsmlRequests.IndexOf(value)); }
public int IndexOf(DirectoryRequest value) { if (value == null) { throw new ArgumentNullException("value"); } return this.dsmlRequests.IndexOf(value); }
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)); } } }
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"); } }
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; }
public DirectoryResponse SendRequest(DirectoryRequest request, TimeSpan requestTimeout) { if (this.disposed) throw new ObjectDisposedException(GetType().Name); if (request == null) throw new ArgumentNullException("request"); if (request is DsmlAuthRequest) throw new NotSupportedException(Res.GetString(Res.DsmlAuthRequestNotSupported)); int messageID = 0; int error = SendRequestHelper(request, ref messageID); LdapOperation operation = LdapOperation.LdapSearch; if (request is DeleteRequest) operation = LdapOperation.LdapDelete; else if (request is AddRequest) operation = LdapOperation.LdapAdd; else if (request is ModifyRequest) operation = LdapOperation.LdapModify; else if (request is SearchRequest) operation = LdapOperation.LdapSearch; else if (request is ModifyDNRequest) operation = LdapOperation.LdapModifyDn; else if (request is CompareRequest) operation = LdapOperation.LdapCompare; else if (request is ExtendedRequest) operation = LdapOperation.LdapExtendedRequest; if (error == 0 && messageID != -1) { return ConstructResponse(messageID, operation, ResultAll.LDAP_MSG_ALL, requestTimeout, true); } else { if (error == 0) { // success code but message is -1, unexpected error = Wldap32.LdapGetLastError(); } throw ConstructException(error, operation); } }
public IAsyncResult BeginSendRequest(DirectoryRequest request, TimeSpan requestTimeout, PartialResultProcessing partialMode, AsyncCallback callback, object state) { int messageID = 0; int error = 0; if (this.disposed) throw new ObjectDisposedException(GetType().Name); // parameter validation if (request == null) throw new ArgumentNullException("request"); if (partialMode < PartialResultProcessing.NoPartialResultSupport || partialMode > PartialResultProcessing.ReturnPartialResultsAndNotifyCallback) throw new InvalidEnumArgumentException("partialMode", (int)partialMode, typeof(PartialResultProcessing)); if (partialMode != PartialResultProcessing.NoPartialResultSupport && !(request is SearchRequest)) throw new NotSupportedException(Res.GetString(Res.PartialResultsNotSupported)); if (partialMode == PartialResultProcessing.ReturnPartialResultsAndNotifyCallback && (callback == null)) throw new ArgumentException(Res.GetString(Res.CallBackIsNull), "callback"); error = SendRequestHelper(request, ref messageID); LdapOperation operation = LdapOperation.LdapSearch; if (request is DeleteRequest) operation = LdapOperation.LdapDelete; else if (request is AddRequest) operation = LdapOperation.LdapAdd; else if (request is ModifyRequest) operation = LdapOperation.LdapModify; else if (request is SearchRequest) operation = LdapOperation.LdapSearch; else if (request is ModifyDNRequest) operation = LdapOperation.LdapModifyDn; else if (request is CompareRequest) operation = LdapOperation.LdapCompare; else if (request is ExtendedRequest) operation = LdapOperation.LdapExtendedRequest; if (error == 0 && messageID != -1) { if (partialMode == PartialResultProcessing.NoPartialResultSupport) { LdapRequestState rs = new LdapRequestState(); LdapAsyncResult asyncResult = new LdapAsyncResult(callback, state, false); rs.ldapAsync = asyncResult; asyncResult.resultObject = rs; s_asyncResultTable.Add(asyncResult, messageID); _fd.BeginInvoke(messageID, operation, ResultAll.LDAP_MSG_ALL, requestTimeout, true, new AsyncCallback(ResponseCallback), rs); return (IAsyncResult)asyncResult; } else { // the user registers to retrieve partial results bool partialCallback = false; if (partialMode == PartialResultProcessing.ReturnPartialResultsAndNotifyCallback) partialCallback = true; LdapPartialAsyncResult asyncResult = new LdapPartialAsyncResult(messageID, callback, state, true, this, partialCallback, requestTimeout); s_partialResultsProcessor.Add(asyncResult); return (IAsyncResult)asyncResult; } } else { if (error == 0) { // success code but message is -1, unexpected error = Wldap32.LdapGetLastError(); } throw ConstructException(error, operation); } }
public void CopyTo(DirectoryRequest[] value, int i) { this.dsmlRequests.CopyTo(value, i); }
public override DirectoryResponse SendRequest (DirectoryRequest request) { throw new NotImplementedException (); }
public int IndexOf (DirectoryRequest value) { throw new NotImplementedException (); }
public void Remove (DirectoryRequest value) { throw new NotImplementedException (); }
public abstract DirectoryResponse SendRequest(DirectoryRequest request);
public int Add(DirectoryRequest request) { throw new NotImplementedException(); }
private int SendRequestHelper(DirectoryRequest request, ref int messageID) { IntPtr hGlobalUni; IntPtr intPtr; int num; int length; int count; int num1; IntPtr intPtr1 = (IntPtr)0; LdapControl[] ldapControlArray = null; IntPtr intPtr2 = (IntPtr)0; LdapControl[] ldapControlArray1 = null; string str = null; ArrayList arrayLists = new ArrayList(); LdapMod[] ldapModArray = null; IntPtr intPtr3 = (IntPtr)0; int num2 = 0; berval _berval = null; IntPtr intPtr4 = (IntPtr)0; int num3 = 0; int num4 = 0; if (!this.connected) { this.Connect(); this.connected = true; } if (this.AutoBind && (!this.bounded || this.needRebind) && !((LdapDirectoryIdentifier)this.Directory).Connectionless) { this.Bind(); } try { ldapControlArray = this.BuildControlArray(request.Controls, true); int num5 = Marshal.SizeOf(typeof(LdapControl)); if (ldapControlArray != null) { intPtr1 = Utility.AllocHGlobalIntPtrArray((int)ldapControlArray.Length + 1); for (int i = 0; i < (int)ldapControlArray.Length; i++) { hGlobalUni = Marshal.AllocHGlobal(num5); Marshal.StructureToPtr(ldapControlArray[i], hGlobalUni, false); intPtr = (IntPtr)((long)intPtr1 + (long)(Marshal.SizeOf(typeof(IntPtr)) * i)); Marshal.WriteIntPtr(intPtr, hGlobalUni); } intPtr = (IntPtr)((long)intPtr1 + (long)(Marshal.SizeOf(typeof(IntPtr)) * (int)ldapControlArray.Length)); Marshal.WriteIntPtr(intPtr, (IntPtr)0); } ldapControlArray1 = this.BuildControlArray(request.Controls, false); if (ldapControlArray1 != null) { intPtr2 = Utility.AllocHGlobalIntPtrArray((int)ldapControlArray1.Length + 1); for (int j = 0; j < (int)ldapControlArray1.Length; j++) { hGlobalUni = Marshal.AllocHGlobal(num5); Marshal.StructureToPtr(ldapControlArray1[j], hGlobalUni, false); intPtr = (IntPtr)((long)intPtr2 + (long)(Marshal.SizeOf(typeof(IntPtr)) * j)); Marshal.WriteIntPtr(intPtr, hGlobalUni); } intPtr = (IntPtr)((long)intPtr2 + (long)(Marshal.SizeOf(typeof(IntPtr)) * (int)ldapControlArray1.Length)); Marshal.WriteIntPtr(intPtr, (IntPtr)0); } if (request as DeleteRequest == null) { if (request as ModifyDNRequest == null) { if (request as CompareRequest == null) { if (request as AddRequest != null || request as ModifyRequest != null) { if (request as AddRequest == null) { ldapModArray = this.BuildAttributes(((ModifyRequest)request).Modifications, arrayLists); } else { ldapModArray = this.BuildAttributes(((AddRequest)request).Attributes, arrayLists); } if (ldapModArray == null) { length = 1; } else { length = (int)ldapModArray.Length + 1; } num2 = length; intPtr3 = Utility.AllocHGlobalIntPtrArray(num2); int num6 = Marshal.SizeOf(typeof(LdapMod)); int k = 0; for (k = 0; k < num2 - 1; k++) { hGlobalUni = Marshal.AllocHGlobal(num6); Marshal.StructureToPtr(ldapModArray[k], hGlobalUni, false); intPtr = (IntPtr)((long)intPtr3 + (long)(Marshal.SizeOf(typeof(IntPtr)) * k)); Marshal.WriteIntPtr(intPtr, hGlobalUni); } intPtr = (IntPtr)((long)intPtr3 + (long)(Marshal.SizeOf(typeof(IntPtr)) * k)); Marshal.WriteIntPtr(intPtr, (IntPtr)0); if (request as AddRequest == null) { num4 = Wldap32.ldap_modify(this.ldapHandle, ((ModifyRequest)request).DistinguishedName, intPtr3, intPtr1, intPtr2, ref messageID); } else { num4 = Wldap32.ldap_add(this.ldapHandle, ((AddRequest)request).DistinguishedName, intPtr3, intPtr1, intPtr2, ref messageID); } } else { if (request as ExtendedRequest == null) { if (request as SearchRequest == null) { throw new NotSupportedException(Res.GetString("InvliadRequestType")); } else { SearchRequest searchRequest = (SearchRequest)request; object filter = searchRequest.Filter; if (filter == null || filter as XmlDocument == null) { string str1 = (string)filter; if (searchRequest.Attributes == null) { count = 0; } else { count = searchRequest.Attributes.Count; } num3 = count; if (num3 != 0) { intPtr4 = Utility.AllocHGlobalIntPtrArray(num3 + 1); int l = 0; for (l = 0; l < num3; l++) { hGlobalUni = Marshal.StringToHGlobalUni(searchRequest.Attributes[l]); intPtr = (IntPtr)((long)intPtr4 + (long)(Marshal.SizeOf(typeof(IntPtr)) * l)); Marshal.WriteIntPtr(intPtr, hGlobalUni); } intPtr = (IntPtr)((long)intPtr4 + (long)(Marshal.SizeOf(typeof(IntPtr)) * l)); Marshal.WriteIntPtr(intPtr, (IntPtr)0); } int scope = (int)searchRequest.Scope; TimeSpan timeLimit = searchRequest.TimeLimit; int ticks = (int)(timeLimit.Ticks / (long)0x989680); DereferenceAlias derefAlias = this.options.DerefAlias; this.options.DerefAlias = searchRequest.Aliases; try { num4 = Wldap32.ldap_search(this.ldapHandle, searchRequest.DistinguishedName, scope, str1, intPtr4, searchRequest.TypesOnly, intPtr1, intPtr2, ticks, searchRequest.SizeLimit, ref messageID); } finally { this.options.DerefAlias = derefAlias; } } else { throw new ArgumentException(Res.GetString("InvalidLdapSearchRequestFilter")); } } } else { string requestName = ((ExtendedRequest)request).RequestName; byte[] requestValue = ((ExtendedRequest)request).RequestValue; if (requestValue != null && (int)requestValue.Length != 0) { _berval = new berval(); _berval.bv_len = (int)requestValue.Length; _berval.bv_val = Marshal.AllocHGlobal((int)requestValue.Length); Marshal.Copy(requestValue, 0, _berval.bv_val, (int)requestValue.Length); } num4 = Wldap32.ldap_extended_operation(this.ldapHandle, requestName, _berval, intPtr1, intPtr2, ref messageID); } } } else { DirectoryAttribute assertion = ((CompareRequest)request).Assertion; if (assertion != null) { if (assertion.Count == 1) { byte[] item = assertion[0] as byte[]; if (item == null) { str = assertion[0].ToString(); } else { if (item != null && (int)item.Length != 0) { _berval = new berval(); _berval.bv_len = (int)item.Length; _berval.bv_val = Marshal.AllocHGlobal((int)item.Length); Marshal.Copy(item, 0, _berval.bv_val, (int)item.Length); } } num4 = Wldap32.ldap_compare(this.ldapHandle, ((CompareRequest)request).DistinguishedName, assertion.Name, str, _berval, intPtr1, intPtr2, ref messageID); } else { throw new ArgumentException(Res.GetString("WrongNumValuesCompare")); } } else { throw new ArgumentException(Res.GetString("WrongAssertionCompare")); } } } else { ConnectionHandle connectionHandle = this.ldapHandle; string distinguishedName = ((ModifyDNRequest)request).DistinguishedName; string newName = ((ModifyDNRequest)request).NewName; string newParentDistinguishedName = ((ModifyDNRequest)request).NewParentDistinguishedName; if (((ModifyDNRequest)request).DeleteOldRdn) { num1 = 1; } else { num1 = 0; } num4 = Wldap32.ldap_rename(connectionHandle, distinguishedName, newName, newParentDistinguishedName, num1, intPtr1, intPtr2, ref messageID); } } else { num4 = Wldap32.ldap_delete_ext(this.ldapHandle, ((DeleteRequest)request).DistinguishedName, intPtr1, intPtr2, ref messageID); } if (num4 == 85) { num4 = 112; } num = num4; } finally { GC.KeepAlive(ldapModArray); if (intPtr1 != (IntPtr)0) { for (int m = 0; m < (int)ldapControlArray.Length; m++) { IntPtr intPtr5 = Marshal.ReadIntPtr(intPtr1, Marshal.SizeOf(typeof(IntPtr)) * m); if (intPtr5 != (IntPtr)0) { Marshal.FreeHGlobal(intPtr5); } } Marshal.FreeHGlobal(intPtr1); } if (ldapControlArray != null) { for (int n = 0; n < (int)ldapControlArray.Length; n++) { if (ldapControlArray[n].ldctl_oid != (IntPtr)0) { Marshal.FreeHGlobal(ldapControlArray[n].ldctl_oid); } if (ldapControlArray[n].ldctl_value != null && ldapControlArray[n].ldctl_value.bv_val != (IntPtr)0) { Marshal.FreeHGlobal(ldapControlArray[n].ldctl_value.bv_val); } } } if (intPtr2 != (IntPtr)0) { for (int o = 0; o < (int)ldapControlArray1.Length; o++) { IntPtr intPtr6 = Marshal.ReadIntPtr(intPtr2, Marshal.SizeOf(typeof(IntPtr)) * o); if (intPtr6 != (IntPtr)0) { Marshal.FreeHGlobal(intPtr6); } } Marshal.FreeHGlobal(intPtr2); } if (ldapControlArray1 != null) { for (int p = 0; p < (int)ldapControlArray1.Length; p++) { if (ldapControlArray1[p].ldctl_oid != (IntPtr)0) { Marshal.FreeHGlobal(ldapControlArray1[p].ldctl_oid); } if (ldapControlArray1[p].ldctl_value != null && ldapControlArray1[p].ldctl_value.bv_val != (IntPtr)0) { Marshal.FreeHGlobal(ldapControlArray1[p].ldctl_value.bv_val); } } } if (intPtr3 != (IntPtr)0) { for (int q = 0; q < num2 - 1; q++) { IntPtr intPtr7 = Marshal.ReadIntPtr(intPtr3, Marshal.SizeOf(typeof(IntPtr)) * q); if (intPtr7 != (IntPtr)0) { Marshal.FreeHGlobal(intPtr7); } } Marshal.FreeHGlobal(intPtr3); } int num7 = 0; while (num7 < arrayLists.Count) { IntPtr item1 = (IntPtr)arrayLists[num7]; Marshal.FreeHGlobal(item1); num7++; } if (_berval != null && _berval.bv_val != (IntPtr)0) { Marshal.FreeHGlobal(_berval.bv_val); } if (intPtr4 != (IntPtr)0) { for (int r = 0; r < num3; r++) { IntPtr intPtr8 = Marshal.ReadIntPtr(intPtr4, Marshal.SizeOf(typeof(IntPtr)) * r); if (intPtr8 != (IntPtr)0) { Marshal.FreeHGlobal(intPtr8); } } Marshal.FreeHGlobal(intPtr4); } } return num; }
public IAsyncResult BeginSendRequest(DirectoryRequest request, TimeSpan requestTimeout, PartialResultProcessing partialMode, AsyncCallback callback, object state) { int num = 0; if (!this.disposed) { if (request != null) { if (partialMode < PartialResultProcessing.NoPartialResultSupport || partialMode > PartialResultProcessing.ReturnPartialResultsAndNotifyCallback) { throw new InvalidEnumArgumentException("partialMode", (int)partialMode, typeof(PartialResultProcessing)); } else { if (partialMode == PartialResultProcessing.NoPartialResultSupport || request as SearchRequest != null) { if (partialMode != PartialResultProcessing.ReturnPartialResultsAndNotifyCallback || callback != null) { int num1 = this.SendRequestHelper(request, ref num); LdapOperation ldapOperation = LdapOperation.LdapSearch; if (request as DeleteRequest == null) { if (request as AddRequest == null) { if (request as ModifyRequest == null) { if (request as SearchRequest == null) { if (request as ModifyDNRequest == null) { if (request as CompareRequest == null) { if (request as ExtendedRequest != null) { ldapOperation = LdapOperation.LdapExtendedRequest; } } else { ldapOperation = LdapOperation.LdapCompare; } } else { ldapOperation = LdapOperation.LdapModifyDn; } } else { ldapOperation = LdapOperation.LdapSearch; } } else { ldapOperation = LdapOperation.LdapModify; } } else { ldapOperation = LdapOperation.LdapAdd; } } else { ldapOperation = LdapOperation.LdapDelete; } if (num1 != 0 || num == -1) { if (num1 == 0) { num1 = Wldap32.LdapGetLastError(); } throw this.ConstructException(num1, ldapOperation); } else { if (partialMode != PartialResultProcessing.NoPartialResultSupport) { bool flag = false; if (partialMode == PartialResultProcessing.ReturnPartialResultsAndNotifyCallback) { flag = true; } LdapPartialAsyncResult ldapPartialAsyncResult = new LdapPartialAsyncResult(num, callback, state, true, this, flag, requestTimeout); LdapConnection.partialResultsProcessor.Add(ldapPartialAsyncResult); return ldapPartialAsyncResult; } else { LdapRequestState ldapRequestState = new LdapRequestState(); LdapAsyncResult ldapAsyncResult = new LdapAsyncResult(callback, state, false); ldapRequestState.ldapAsync = ldapAsyncResult; ldapAsyncResult.resultObject = ldapRequestState; LdapConnection.asyncResultTable.Add(ldapAsyncResult, num); this.fd.BeginInvoke(num, ldapOperation, ResultAll.LDAP_MSG_ALL, requestTimeout, true, new AsyncCallback(this.ResponseCallback), ldapRequestState); return ldapAsyncResult; } } } else { throw new ArgumentException(Res.GetString("CallBackIsNull"), "callback"); } } else { throw new NotSupportedException(Res.GetString("PartialResultsNotSupported")); } } } else { throw new ArgumentNullException("request"); } } else { throw new ObjectDisposedException(base.GetType().Name); } }
public DirectoryResponse SendRequest(DirectoryRequest request, TimeSpan requestTimeout) { if (!this.disposed) { if (request != null) { if (request as DsmlAuthRequest == null) { int num = 0; int num1 = this.SendRequestHelper(request, ref num); LdapOperation ldapOperation = LdapOperation.LdapSearch; if (request as DeleteRequest == null) { if (request as AddRequest == null) { if (request as ModifyRequest == null) { if (request as SearchRequest == null) { if (request as ModifyDNRequest == null) { if (request as CompareRequest == null) { if (request as ExtendedRequest != null) { ldapOperation = LdapOperation.LdapExtendedRequest; } } else { ldapOperation = LdapOperation.LdapCompare; } } else { ldapOperation = LdapOperation.LdapModifyDn; } } else { ldapOperation = LdapOperation.LdapSearch; } } else { ldapOperation = LdapOperation.LdapModify; } } else { ldapOperation = LdapOperation.LdapAdd; } } else { ldapOperation = LdapOperation.LdapDelete; } if (num1 != 0 || num == -1) { if (num1 == 0) { num1 = Wldap32.LdapGetLastError(); } throw this.ConstructException(num1, ldapOperation); } else { return this.ConstructResponse(num, ldapOperation, ResultAll.LDAP_MSG_ALL, requestTimeout, true); } } else { throw new NotSupportedException(Res.GetString("DsmlAuthRequestNotSupported")); } } else { throw new ArgumentNullException("request"); } } else { throw new ObjectDisposedException(base.GetType().Name); } }
public override DirectoryResponse SendRequest(DirectoryRequest request) { return this.SendRequest(request, this.connectionTimeOut); }
private int SendRequestHelper(DirectoryRequest request, ref int messageID) { int num19; IntPtr zero = IntPtr.Zero; LdapControl[] controlArray = null; IntPtr clientcontrol = IntPtr.Zero; LdapControl[] controlArray2 = null; string strValue = null; ArrayList ptrToFree = new ArrayList(); LdapMod[] modArray = null; IntPtr attrs = IntPtr.Zero; int num = 0; berval binaryValue = null; IntPtr attributes = IntPtr.Zero; int num2 = 0; int num3 = 0; if (!this.connected) { this.Connect(); this.connected = true; } if ((this.AutoBind && (!this.bounded || this.needRebind)) && !((LdapDirectoryIdentifier) this.Directory).Connectionless) { this.Bind(); } try { IntPtr ptr = IntPtr.Zero; IntPtr ptr6 = IntPtr.Zero; controlArray = this.BuildControlArray(request.Controls, true); int cb = Marshal.SizeOf(typeof(LdapControl)); if (controlArray != null) { zero = Marshal.AllocHGlobal((int) (Marshal.SizeOf(typeof(IntPtr)) * (controlArray.Length + 1))); for (int i = 0; i < controlArray.Length; i++) { ptr = Marshal.AllocHGlobal(cb); Marshal.StructureToPtr(controlArray[i], ptr, false); ptr6 = (IntPtr) (((long) zero) + (Marshal.SizeOf(typeof(IntPtr)) * i)); Marshal.WriteIntPtr(ptr6, ptr); } ptr6 = (IntPtr) (((long) zero) + (Marshal.SizeOf(typeof(IntPtr)) * controlArray.Length)); Marshal.WriteIntPtr(ptr6, IntPtr.Zero); } controlArray2 = this.BuildControlArray(request.Controls, false); if (controlArray2 != null) { clientcontrol = Marshal.AllocHGlobal((int) (Marshal.SizeOf(typeof(IntPtr)) * (controlArray2.Length + 1))); for (int j = 0; j < controlArray2.Length; j++) { ptr = Marshal.AllocHGlobal(cb); Marshal.StructureToPtr(controlArray2[j], ptr, false); ptr6 = (IntPtr) (((long) clientcontrol) + (Marshal.SizeOf(typeof(IntPtr)) * j)); Marshal.WriteIntPtr(ptr6, ptr); } ptr6 = (IntPtr) (((long) clientcontrol) + (Marshal.SizeOf(typeof(IntPtr)) * controlArray2.Length)); Marshal.WriteIntPtr(ptr6, IntPtr.Zero); } if (request is DeleteRequest) { num3 = Wldap32.ldap_delete_ext(this.ldapHandle, ((DeleteRequest) request).DistinguishedName, zero, clientcontrol, ref messageID); } else if (request is ModifyDNRequest) { num3 = Wldap32.ldap_rename(this.ldapHandle, ((ModifyDNRequest) request).DistinguishedName, ((ModifyDNRequest) request).NewName, ((ModifyDNRequest) request).NewParentDistinguishedName, ((ModifyDNRequest) request).DeleteOldRdn ? 1 : 0, zero, clientcontrol, ref messageID); } else if (request is CompareRequest) { DirectoryAttribute assertion = ((CompareRequest) request).Assertion; if (assertion == null) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("WrongAssertionCompare")); } if (assertion.Count != 1) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("WrongNumValuesCompare")); } byte[] source = assertion[0] as byte[]; if (source != null) { if ((source != null) && (source.Length != 0)) { binaryValue = new berval { bv_len = source.Length, bv_val = Marshal.AllocHGlobal(source.Length) }; Marshal.Copy(source, 0, binaryValue.bv_val, source.Length); } } else { strValue = assertion[0].ToString(); } num3 = Wldap32.ldap_compare(this.ldapHandle, ((CompareRequest) request).DistinguishedName, assertion.Name, strValue, binaryValue, zero, clientcontrol, ref messageID); } else if ((request is AddRequest) || (request is ModifyRequest)) { if (request is AddRequest) { modArray = this.BuildAttributes(((AddRequest) request).Attributes, ptrToFree); } else { modArray = this.BuildAttributes(((ModifyRequest) request).Modifications, ptrToFree); } num = (modArray == null) ? 1 : (modArray.Length + 1); attrs = Marshal.AllocHGlobal((int) (Marshal.SizeOf(typeof(IntPtr)) * num)); int num7 = Marshal.SizeOf(typeof(LdapMod)); int index = 0; index = 0; while (index < (num - 1)) { ptr = Marshal.AllocHGlobal(num7); Marshal.StructureToPtr(modArray[index], ptr, false); ptr6 = (IntPtr) (((long) attrs) + (Marshal.SizeOf(typeof(IntPtr)) * index)); Marshal.WriteIntPtr(ptr6, ptr); index++; } ptr6 = (IntPtr) (((long) attrs) + (Marshal.SizeOf(typeof(IntPtr)) * index)); Marshal.WriteIntPtr(ptr6, IntPtr.Zero); if (request is AddRequest) { num3 = Wldap32.ldap_add(this.ldapHandle, ((AddRequest) request).DistinguishedName, attrs, zero, clientcontrol, ref messageID); } else { num3 = Wldap32.ldap_modify(this.ldapHandle, ((ModifyRequest) request).DistinguishedName, attrs, zero, clientcontrol, ref messageID); } } else if (request is ExtendedRequest) { string requestName = ((ExtendedRequest) request).RequestName; byte[] requestValue = ((ExtendedRequest) request).RequestValue; if ((requestValue != null) && (requestValue.Length != 0)) { binaryValue = new berval { bv_len = requestValue.Length, bv_val = Marshal.AllocHGlobal(requestValue.Length) }; Marshal.Copy(requestValue, 0, binaryValue.bv_val, requestValue.Length); } num3 = Wldap32.ldap_extended_operation(this.ldapHandle, requestName, binaryValue, zero, clientcontrol, ref messageID); } else { if (request is SearchRequest) { SearchRequest request2 = (SearchRequest) request; object filter = request2.Filter; if ((filter != null) && (filter is XmlDocument)) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("InvalidLdapSearchRequestFilter")); } string str3 = (string) filter; num2 = (request2.Attributes == null) ? 0 : request2.Attributes.Count; if (num2 != 0) { attributes = Marshal.AllocHGlobal((int) (Marshal.SizeOf(typeof(IntPtr)) * (num2 + 1))); int num9 = 0; num9 = 0; while (num9 < num2) { ptr = Marshal.StringToHGlobalUni(request2.Attributes[num9]); ptr6 = (IntPtr) (((long) attributes) + (Marshal.SizeOf(typeof(IntPtr)) * num9)); Marshal.WriteIntPtr(ptr6, ptr); num9++; } ptr6 = (IntPtr) (((long) attributes) + (Marshal.SizeOf(typeof(IntPtr)) * num9)); Marshal.WriteIntPtr(ptr6, IntPtr.Zero); } int scope = (int) request2.Scope; int timelimit = (int) (request2.TimeLimit.Ticks / 0x989680L); System.DirectoryServices.Protocols.DereferenceAlias derefAlias = this.options.DerefAlias; this.options.DerefAlias = request2.Aliases; try { num3 = Wldap32.ldap_search(this.ldapHandle, request2.DistinguishedName, scope, str3, attributes, request2.TypesOnly, zero, clientcontrol, timelimit, request2.SizeLimit, ref messageID); goto Label_06A6; } finally { this.options.DerefAlias = derefAlias; } } throw new NotSupportedException(System.DirectoryServices.Protocols.Res.GetString("InvliadRequestType")); } Label_06A6: if (num3 == 0x55) { num3 = 0x70; } num19 = num3; } finally { GC.KeepAlive(modArray); if (zero != IntPtr.Zero) { for (int m = 0; m < controlArray.Length; m++) { IntPtr hglobal = Marshal.ReadIntPtr(zero, Marshal.SizeOf(typeof(IntPtr)) * m); if (hglobal != IntPtr.Zero) { Marshal.FreeHGlobal(hglobal); } } Marshal.FreeHGlobal(zero); } if (controlArray != null) { for (int n = 0; n < controlArray.Length; n++) { if (controlArray[n].ldctl_oid != IntPtr.Zero) { Marshal.FreeHGlobal(controlArray[n].ldctl_oid); } if ((controlArray[n].ldctl_value != null) && (controlArray[n].ldctl_value.bv_val != IntPtr.Zero)) { Marshal.FreeHGlobal(controlArray[n].ldctl_value.bv_val); } } } if (clientcontrol != IntPtr.Zero) { for (int num14 = 0; num14 < controlArray2.Length; num14++) { IntPtr ptr8 = Marshal.ReadIntPtr(clientcontrol, Marshal.SizeOf(typeof(IntPtr)) * num14); if (ptr8 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr8); } } Marshal.FreeHGlobal(clientcontrol); } if (controlArray2 != null) { for (int num15 = 0; num15 < controlArray2.Length; num15++) { if (controlArray2[num15].ldctl_oid != IntPtr.Zero) { Marshal.FreeHGlobal(controlArray2[num15].ldctl_oid); } if ((controlArray2[num15].ldctl_value != null) && (controlArray2[num15].ldctl_value.bv_val != IntPtr.Zero)) { Marshal.FreeHGlobal(controlArray2[num15].ldctl_value.bv_val); } } } if (attrs != IntPtr.Zero) { for (int num16 = 0; num16 < (num - 1); num16++) { IntPtr ptr9 = Marshal.ReadIntPtr(attrs, Marshal.SizeOf(typeof(IntPtr)) * num16); if (ptr9 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr9); } } Marshal.FreeHGlobal(attrs); } for (int k = 0; k < ptrToFree.Count; k++) { IntPtr ptr10 = (IntPtr) ptrToFree[k]; Marshal.FreeHGlobal(ptr10); } if ((binaryValue != null) && (binaryValue.bv_val != IntPtr.Zero)) { Marshal.FreeHGlobal(binaryValue.bv_val); } if (attributes != IntPtr.Zero) { for (int num18 = 0; num18 < num2; num18++) { IntPtr ptr11 = Marshal.ReadIntPtr(attributes, Marshal.SizeOf(typeof(IntPtr)) * num18); if (ptr11 != IntPtr.Zero) { Marshal.FreeHGlobal(ptr11); } } Marshal.FreeHGlobal(attributes); } } return num19; }
public bool Contains(DirectoryRequest value) { throw new NotImplementedException(); }
public void CopyTo (DirectoryRequest [] value, int i) { throw new NotImplementedException (); }
public int IndexOf(DirectoryRequest value) { throw new NotImplementedException(); }
public void Insert (int index, DirectoryRequest value) { throw new NotImplementedException (); }
public void Insert(int index, DirectoryRequest value) { throw new NotImplementedException(); }
public bool Contains(DirectoryRequest value) { return this.dsmlRequests.Contains(value); }
public DirectoryResponse SendRequest(DirectoryRequest request, TimeSpan requestTimeout) { throw new NotImplementedException(); }
public override DirectoryResponse SendRequest(DirectoryRequest request) { throw new NotImplementedException(); }
public bool Contains(DirectoryRequest value) { return(this.dsmlRequests.Contains(value)); }
public override DirectoryResponse SendRequest(DirectoryRequest request) { // no request specific timeout is specified, use the connection timeout return SendRequest(request, connectionTimeOut); }
public IAsyncResult BeginSendRequest (DirectoryRequest request, TimeSpan requestTimeout, PartialResultProcessing partialMode, AsyncCallback callback, object state) { throw new NotImplementedException (); }
public IAsyncResult BeginSendRequest(DirectoryRequest request, PartialResultProcessing partialMode, AsyncCallback callback, object state) { return BeginSendRequest(request, connectionTimeOut, partialMode, callback, state); }
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"); } }
private int SendRequestHelper(DirectoryRequest request, ref int messageID) { IntPtr serverControlArray = (IntPtr)0; LdapControl[] managedServerControls = null; IntPtr clientControlArray = (IntPtr)0; LdapControl[] managedClientControls = null; string strValue = null; ArrayList ptrToFree = new ArrayList(); LdapMod[] modifications = null; IntPtr modArray = (IntPtr)0; int addModCount = 0; berval berValuePtr = null; IntPtr searchAttributes = (IntPtr)0; DereferenceAlias searchAliases; int attributeCount = 0; int error = 0; // connect to the server first if have not done so if (!_connected) { Connect(); _connected = true; } //do Bind if user has not turned off automatic bind, have not done so or there is a need to do rebind, also connectionless LDAP does not need to do bind if (AutoBind && (!_bounded || _needRebind) && ((LdapDirectoryIdentifier)Directory).Connectionless != true) { Debug.WriteLine("rebind occurs\n"); Bind(); } try { IntPtr controlPtr = (IntPtr)0; IntPtr tempPtr = (IntPtr)0; // build server control managedServerControls = BuildControlArray(request.Controls, true); int structSize = Marshal.SizeOf(typeof(LdapControl)); if (managedServerControls != null) { serverControlArray = Utility.AllocHGlobalIntPtrArray(managedServerControls.Length + 1); for (int i = 0; i < managedServerControls.Length; i++) { controlPtr = Marshal.AllocHGlobal(structSize); Marshal.StructureToPtr(managedServerControls[i], controlPtr, false); tempPtr = (IntPtr)((long)serverControlArray + Marshal.SizeOf(typeof(IntPtr)) * i); Marshal.WriteIntPtr(tempPtr, controlPtr); } tempPtr = (IntPtr)((long)serverControlArray + Marshal.SizeOf(typeof(IntPtr)) * managedServerControls.Length); Marshal.WriteIntPtr(tempPtr, (IntPtr)0); } // build client control managedClientControls = BuildControlArray(request.Controls, false); if (managedClientControls != null) { clientControlArray = Utility.AllocHGlobalIntPtrArray(managedClientControls.Length + 1); for (int i = 0; i < managedClientControls.Length; i++) { controlPtr = Marshal.AllocHGlobal(structSize); Marshal.StructureToPtr(managedClientControls[i], controlPtr, false); tempPtr = (IntPtr)((long)clientControlArray + Marshal.SizeOf(typeof(IntPtr)) * i); Marshal.WriteIntPtr(tempPtr, controlPtr); } tempPtr = (IntPtr)((long)clientControlArray + Marshal.SizeOf(typeof(IntPtr)) * managedClientControls.Length); Marshal.WriteIntPtr(tempPtr, (IntPtr)0); } if (request is DeleteRequest) { // it is an delete operation error = Wldap32.ldap_delete_ext(ldapHandle, ((DeleteRequest)request).DistinguishedName, serverControlArray, clientControlArray, ref messageID); } else if (request is ModifyDNRequest) { // it is a modify dn operation error = Wldap32.ldap_rename(ldapHandle, ((ModifyDNRequest)request).DistinguishedName, ((ModifyDNRequest)request).NewName, ((ModifyDNRequest)request).NewParentDistinguishedName, ((ModifyDNRequest)request).DeleteOldRdn ? 1 : 0, serverControlArray, clientControlArray, ref messageID); } else if (request is CompareRequest) { // it is a compare request DirectoryAttribute assertion = ((CompareRequest)request).Assertion; if (assertion == null) throw new ArgumentException(Res.GetString(Res.WrongAssertionCompare)); if (assertion.Count != 1) throw new ArgumentException(Res.GetString(Res.WrongNumValuesCompare)); // process the attribute byte[] byteArray = assertion[0] as byte[]; if (byteArray != null) { if (byteArray != null && byteArray.Length != 0) { berValuePtr = new berval(); berValuePtr.bv_len = byteArray.Length; berValuePtr.bv_val = Marshal.AllocHGlobal(byteArray.Length); Marshal.Copy(byteArray, 0, berValuePtr.bv_val, byteArray.Length); } } else { strValue = assertion[0].ToString(); } // it is a compare request error = Wldap32.ldap_compare(ldapHandle, ((CompareRequest)request).DistinguishedName, assertion.Name, strValue, berValuePtr, serverControlArray, clientControlArray, ref messageID); } else if (request is AddRequest || request is ModifyRequest) { // build the attributes if (request is AddRequest) modifications = BuildAttributes(((AddRequest)request).Attributes, ptrToFree); else modifications = BuildAttributes(((ModifyRequest)request).Modifications, ptrToFree); addModCount = (modifications == null ? 1 : modifications.Length + 1); modArray = Utility.AllocHGlobalIntPtrArray(addModCount); int modStructSize = Marshal.SizeOf(typeof(LdapMod)); int i = 0; for (i = 0; i < addModCount - 1; i++) { controlPtr = Marshal.AllocHGlobal(modStructSize); Marshal.StructureToPtr(modifications[i], controlPtr, false); tempPtr = (IntPtr)((long)modArray + Marshal.SizeOf(typeof(IntPtr)) * i); Marshal.WriteIntPtr(tempPtr, controlPtr); } tempPtr = (IntPtr)((long)modArray + Marshal.SizeOf(typeof(IntPtr)) * i); Marshal.WriteIntPtr(tempPtr, (IntPtr)0); if (request is AddRequest) { error = Wldap32.ldap_add(ldapHandle, ((AddRequest)request).DistinguishedName, modArray, serverControlArray, clientControlArray, ref messageID); } else { error = Wldap32.ldap_modify(ldapHandle, ((ModifyRequest)request).DistinguishedName, modArray, serverControlArray, clientControlArray, ref messageID); } } else if (request is ExtendedRequest) { string name = ((ExtendedRequest)request).RequestName; byte[] val = ((ExtendedRequest)request).RequestValue; // process the requestvalue if (val != null && val.Length != 0) { berValuePtr = new berval(); berValuePtr.bv_len = val.Length; berValuePtr.bv_val = Marshal.AllocHGlobal(val.Length); Marshal.Copy(val, 0, berValuePtr.bv_val, val.Length); } error = Wldap32.ldap_extended_operation(ldapHandle, name, berValuePtr, serverControlArray, clientControlArray, ref messageID); } else if (request is SearchRequest) { // processing the filter SearchRequest searchRequest = (SearchRequest)request; object filter = searchRequest.Filter; if (filter != null) { // LdapConnection only supports ldap filter if (filter is XmlDocument) throw new ArgumentException(Res.GetString(Res.InvalidLdapSearchRequestFilter)); } string searchRequestFilter = (string)filter; // processing the attributes attributeCount = (searchRequest.Attributes == null ? 0 : searchRequest.Attributes.Count); if (attributeCount != 0) { searchAttributes = Utility.AllocHGlobalIntPtrArray(attributeCount + 1); int i = 0; for (i = 0; i < attributeCount; i++) { controlPtr = Marshal.StringToHGlobalUni(searchRequest.Attributes[i]); tempPtr = (IntPtr)((long)searchAttributes + Marshal.SizeOf(typeof(IntPtr)) * i); Marshal.WriteIntPtr(tempPtr, controlPtr); } tempPtr = (IntPtr)((long)searchAttributes + Marshal.SizeOf(typeof(IntPtr)) * i); Marshal.WriteIntPtr(tempPtr, (IntPtr)0); } // processing the scope int searchScope = (int)searchRequest.Scope; // processing the timelimit int searchTimeLimit = (int)(searchRequest.TimeLimit.Ticks / TimeSpan.TicksPerSecond); // processing the alias searchAliases = _options.DerefAlias; _options.DerefAlias = searchRequest.Aliases; try { error = Wldap32.ldap_search(ldapHandle, searchRequest.DistinguishedName, searchScope, searchRequestFilter, searchAttributes, searchRequest.TypesOnly, serverControlArray, clientControlArray, searchTimeLimit, searchRequest.SizeLimit, ref messageID); } finally { // revert back _options.DerefAlias = searchAliases; } } else { throw new NotSupportedException(Res.GetString(Res.InvliadRequestType)); } // the asynchronous call itself timeout, this actually means that we time out the LDAP_OPT_SEND_TIMEOUT specified in the session option // wldap32 does not differentiate that, but the application caller actually needs this information to determin what to do with the error code if (error == (int)LdapError.TimeOut) error = (int)LdapError.SendTimeOut; return error; } finally { GC.KeepAlive(modifications); if (serverControlArray != (IntPtr)0) { //release the memory from the heap for (int i = 0; i < managedServerControls.Length; i++) { IntPtr tempPtr = Marshal.ReadIntPtr(serverControlArray, Marshal.SizeOf(typeof(IntPtr)) * i); if (tempPtr != (IntPtr)0) Marshal.FreeHGlobal(tempPtr); } Marshal.FreeHGlobal(serverControlArray); } if (managedServerControls != null) { for (int i = 0; i < managedServerControls.Length; i++) { if (managedServerControls[i].ldctl_oid != (IntPtr)0) Marshal.FreeHGlobal(managedServerControls[i].ldctl_oid); if (managedServerControls[i].ldctl_value != null) { if (managedServerControls[i].ldctl_value.bv_val != (IntPtr)0) Marshal.FreeHGlobal(managedServerControls[i].ldctl_value.bv_val); } } } if (clientControlArray != (IntPtr)0) { // release the memory from the heap for (int i = 0; i < managedClientControls.Length; i++) { IntPtr tempPtr = Marshal.ReadIntPtr(clientControlArray, Marshal.SizeOf(typeof(IntPtr)) * i); if (tempPtr != (IntPtr)0) Marshal.FreeHGlobal(tempPtr); } Marshal.FreeHGlobal(clientControlArray); } if (managedClientControls != null) { for (int i = 0; i < managedClientControls.Length; i++) { if (managedClientControls[i].ldctl_oid != (IntPtr)0) Marshal.FreeHGlobal(managedClientControls[i].ldctl_oid); if (managedClientControls[i].ldctl_value != null) { if (managedClientControls[i].ldctl_value.bv_val != (IntPtr)0) Marshal.FreeHGlobal(managedClientControls[i].ldctl_value.bv_val); } } } if (modArray != (IntPtr)0) { // release the memory from the heap for (int i = 0; i < addModCount - 1; i++) { IntPtr tempPtr = Marshal.ReadIntPtr(modArray, Marshal.SizeOf(typeof(IntPtr)) * i); if (tempPtr != (IntPtr)0) Marshal.FreeHGlobal(tempPtr); } Marshal.FreeHGlobal(modArray); } // free the pointers for (int x = 0; x < ptrToFree.Count; x++) { IntPtr tempPtr = (IntPtr)ptrToFree[x]; Marshal.FreeHGlobal(tempPtr); } if (berValuePtr != null) { if (berValuePtr.bv_val != (IntPtr)0) Marshal.FreeHGlobal(berValuePtr.bv_val); } if (searchAttributes != (IntPtr)0) { for (int i = 0; i < attributeCount; i++) { IntPtr tempPtr = Marshal.ReadIntPtr(searchAttributes, Marshal.SizeOf(typeof(IntPtr)) * i); if (tempPtr != (IntPtr)0) Marshal.FreeHGlobal(tempPtr); } Marshal.FreeHGlobal(searchAttributes); } } }
public bool Contains (DirectoryRequest value) { throw new NotImplementedException (); }
public DirectoryResponse SendRequest (DirectoryRequest request, TimeSpan requestTimeout) { throw new NotImplementedException (); }
public IAsyncResult BeginSendRequest(DirectoryRequest request, TimeSpan requestTimeout, PartialResultProcessing partialMode, AsyncCallback callback, object state) { throw new NotImplementedException(); }
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)); } } }
public int Add (DirectoryRequest request) { throw new NotImplementedException (); }
public void Remove(DirectoryRequest value) { throw new NotImplementedException(); }
public IAsyncResult BeginSendRequest(DirectoryRequest request, TimeSpan requestTimeout, PartialResultProcessing partialMode, AsyncCallback callback, object state) { int messageID = 0; int error = 0; if (this.disposed) { throw new ObjectDisposedException(base.GetType().Name); } if (request == null) { throw new ArgumentNullException("request"); } if ((partialMode < PartialResultProcessing.NoPartialResultSupport) || (partialMode > PartialResultProcessing.ReturnPartialResultsAndNotifyCallback)) { throw new InvalidEnumArgumentException("partialMode", (int) partialMode, typeof(PartialResultProcessing)); } if ((partialMode != PartialResultProcessing.NoPartialResultSupport) && !(request is SearchRequest)) { throw new NotSupportedException(System.DirectoryServices.Protocols.Res.GetString("PartialResultsNotSupported")); } if ((partialMode == PartialResultProcessing.ReturnPartialResultsAndNotifyCallback) && (callback == null)) { throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("CallBackIsNull"), "callback"); } error = this.SendRequestHelper(request, ref messageID); LdapOperation ldapSearch = LdapOperation.LdapSearch; if (request is DeleteRequest) { ldapSearch = LdapOperation.LdapDelete; } else if (request is AddRequest) { ldapSearch = LdapOperation.LdapAdd; } else if (request is ModifyRequest) { ldapSearch = LdapOperation.LdapModify; } else if (request is SearchRequest) { ldapSearch = LdapOperation.LdapSearch; } else if (request is ModifyDNRequest) { ldapSearch = LdapOperation.LdapModifyDn; } else if (request is CompareRequest) { ldapSearch = LdapOperation.LdapCompare; } else if (request is ExtendedRequest) { ldapSearch = LdapOperation.LdapExtendedRequest; } if ((error == 0) && (messageID != -1)) { if (partialMode == PartialResultProcessing.NoPartialResultSupport) { LdapRequestState state2 = new LdapRequestState(); LdapAsyncResult key = new LdapAsyncResult(callback, state, false); state2.ldapAsync = key; key.resultObject = state2; asyncResultTable.Add(key, messageID); this.fd.BeginInvoke(messageID, ldapSearch, ResultAll.LDAP_MSG_ALL, requestTimeout, true, new AsyncCallback(this.ResponseCallback), state2); return key; } bool partialCallback = false; if (partialMode == PartialResultProcessing.ReturnPartialResultsAndNotifyCallback) { partialCallback = true; } LdapPartialAsyncResult asyncResult = new LdapPartialAsyncResult(messageID, callback, state, true, this, partialCallback, requestTimeout); partialResultsProcessor.Add(asyncResult); return asyncResult; } if (error == 0) { error = Wldap32.LdapGetLastError(); } throw this.ConstructException(error, ldapSearch); }