internal DirectoryControl[] ControlsHelper(string primaryXPath)
        {
            // Get the set of control nodes
            XmlNodeList nodeList = dsmlNode.SelectNodes(primaryXPath, dsmlNS);

            if (nodeList.Count == 0)
            {
                // the server returned no controls
                return(new DirectoryControl[0]);
            }

            // Build the DirectoryControl array
            DirectoryControl[] controls = new DirectoryControl[nodeList.Count];
            int index = 0;

            foreach (XmlNode node in nodeList)
            {
                Debug.Assert(node is XmlElement);

                controls[index] = new DirectoryControl((XmlElement)node);
                index++;
            }

            return(controls);
        }
Beispiel #2
0
        public void Insert(int index, DirectoryControl value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

            List.Insert(index, value);
        }
Beispiel #3
0
 public void AddRange(DirectoryControl[] controls)
 {
     if (controls != null)
     {
         DirectoryControl[] directoryControlArray = controls;
         int num = 0;
         while (num < (int)directoryControlArray.Length)
         {
             DirectoryControl directoryControl = directoryControlArray[num];
             if (directoryControl != null)
             {
                 num++;
             }
             else
             {
                 throw new ArgumentException(Res.GetString("ContainNullControl"), "controls");
             }
         }
         base.InnerList.AddRange(controls);
         return;
     }
     else
     {
         throw new ArgumentNullException("controls");
     }
 }
Beispiel #4
0
        public int Add(DirectoryControl control)
        {
            if (control == null)
                throw new ArgumentNullException("control");

            return List.Add(control);
        }
		public void AddRange(DirectoryControl[] controls)
		{
			if (controls != null)
			{
				DirectoryControl[] directoryControlArray = controls;
				int num = 0;
				while (num < (int)directoryControlArray.Length)
				{
					DirectoryControl directoryControl = directoryControlArray[num];
					if (directoryControl != null)
					{
						num++;
					}
					else
					{
						throw new ArgumentException(Res.GetString("ContainNullControl"), "controls");
					}
				}
				base.InnerList.AddRange(controls);
				return;
			}
			else
			{
				throw new ArgumentNullException("controls");
			}
		}
 public void Insert(int index, DirectoryControl value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     base.List.Insert(index, value);
 }
 public int Add(DirectoryControl control)
 {
     if (control == null)
     {
         throw new ArgumentNullException("control");
     }
     return base.List.Add(control);
 }
Beispiel #8
0
 internal DirectoryResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral)
 {
     this.dn = dn;
     this.directoryControls = controls;
     this.result = result;
     this.directoryMessage = message;
     this.directoryReferral = referral;
 }
 internal DirectoryResponse(string dn, DirectoryControl[] controls, System.DirectoryServices.Protocols.ResultCode result, string message, Uri[] referral)
 {
     this.result = ~System.DirectoryServices.Protocols.ResultCode.Success;
     this.dn = dn;
     this.directoryControls = controls;
     this.result = result;
     this.directoryMessage = message;
     this.directoryReferral = referral;
 }
Beispiel #10
0
		public ADResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral)
		{
			this._result = ResultCode.OperationsError | ResultCode.ProtocolError | ResultCode.TimeLimitExceeded | ResultCode.SizeLimitExceeded | ResultCode.CompareFalse | ResultCode.CompareTrue | ResultCode.AuthMethodNotSupported | ResultCode.StrongAuthRequired | ResultCode.ReferralV2 | ResultCode.Referral | ResultCode.AdminLimitExceeded | ResultCode.UnavailableCriticalExtension | ResultCode.ConfidentialityRequired | ResultCode.SaslBindInProgress | ResultCode.NoSuchAttribute | ResultCode.UndefinedAttributeType | ResultCode.InappropriateMatching | ResultCode.ConstraintViolation | ResultCode.AttributeOrValueExists | ResultCode.InvalidAttributeSyntax | ResultCode.NoSuchObject | ResultCode.AliasProblem | ResultCode.InvalidDNSyntax | ResultCode.AliasDereferencingProblem | ResultCode.InappropriateAuthentication | ResultCode.InsufficientAccessRights | ResultCode.Busy | ResultCode.Unavailable | ResultCode.UnwillingToPerform | ResultCode.LoopDetect | ResultCode.SortControlMissing | ResultCode.OffsetRangeError | ResultCode.NamingViolation | ResultCode.ObjectClassViolation | ResultCode.NotAllowedOnNonLeaf | ResultCode.NotAllowedOnRdn | ResultCode.EntryAlreadyExists | ResultCode.ObjectClassModificationsProhibited | ResultCode.ResultsTooLarge | ResultCode.AffectsMultipleDsas | ResultCode.VirtualListViewError | ResultCode.Other;
			this._dn = dn;
			this._controls = controls;
			ADResponse.TransformControls(this._controls);
			this._result = result;
			this._message = message;
			this._referral = referral;
		}
Beispiel #11
0
 public int Add(DirectoryControl control)
 {
     if (control != null)
     {
         return(base.List.Add(control));
     }
     else
     {
         throw new ArgumentNullException("control");
     }
 }
Beispiel #12
0
 public void Insert(int index, DirectoryControl value)
 {
     if (value != null)
     {
         base.List.Insert(index, value);
         return;
     }
     else
     {
         throw new ArgumentNullException("value");
     }
 }
		public static void Deserialize(XmlDictionaryReader reader, out IList<DirectoryControl> controls, bool mustBePresent, bool fullChecks)
		{
			string str = null;
			string str1 = null;
			bool flag;
			byte[] numArray = null;
			controls = new List<DirectoryControl>();
			if (mustBePresent || reader.IsStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
			{
				reader.ReadFullStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
				while (reader.IsStartElement("control", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
				{
					string attribute = reader.GetAttribute("type");
					string attribute1 = reader.GetAttribute("criticality");
					reader.Read();
					if (!reader.IsStartElement("controlValue", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
					{
						numArray = null;
					}
					else
					{
						string attribute2 = reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
						if (attribute2 != null)
						{
							XmlUtility.SplitPrefix(attribute2, out str, out str1);
							numArray = reader.ReadElementContentAsBase64();
						}
						else
						{
							throw new ArgumentException();
						}
					}
					if (!string.Equals("true", attribute1))
					{
						flag = false;
					}
					else
					{
						flag = true;
					}
					DirectoryControl directoryControl = new DirectoryControl(attribute, numArray, flag, true);
					controls.Add(directoryControl);
					reader.Read();
				}
				return;
			}
			else
			{
				return;
			}
		}
 public void AddRange(DirectoryControl[] controls)
 {
     if (controls == null)
     {
         throw new ArgumentNullException("controls");
     }
     DirectoryControl[] controlArray = controls;
     for (int i = 0; i < controlArray.Length; i++)
     {
         if (controlArray[i] == null)
         {
             throw new ArgumentException(Res.GetString("ContainNullControl"), "controls");
         }
     }
     base.InnerList.AddRange(controls);
 }
 internal DirectoryControl[] ControlsHelper(string primaryXPath)
 {
     XmlNodeList list = this.dsmlNode.SelectNodes(primaryXPath, this.dsmlNS);
     if (list.Count == 0)
     {
         return new DirectoryControl[0];
     }
     DirectoryControl[] controlArray = new DirectoryControl[list.Count];
     int index = 0;
     foreach (XmlNode node in list)
     {
         controlArray[index] = new DirectoryControl((XmlElement) node);
         index++;
     }
     return controlArray;
 }
 private DirectoryControl[] ControlsHelper()
 {
     XmlNodeList list = this.dsmlNode.SelectNodes("dsml:control", this.dsmlNS);
     if (list.Count == 0)
     {
         return new DirectoryControl[0];
     }
     DirectoryControl[] controlArray = new DirectoryControl[list.Count];
     int index = 0;
     foreach (XmlNode node in list)
     {
         controlArray[index] = new DirectoryControl((XmlElement) node);
         index++;
     }
     return controlArray;
 }
        private DirectoryControl[] ControlsHelper()
        {
            XmlNodeList list = this.dsmlNode.SelectNodes("dsml:control", this.dsmlNS);

            if (list.Count == 0)
            {
                return(new DirectoryControl[0]);
            }
            DirectoryControl[] controlArray = new DirectoryControl[list.Count];
            int index = 0;

            foreach (XmlNode node in list)
            {
                controlArray[index] = new DirectoryControl((XmlElement)node);
                index++;
            }
            return(controlArray);
        }
Beispiel #18
0
        internal DirectoryControl[] ControlsHelper(string primaryXPath)
        {
            XmlNodeList list = this.dsmlNode.SelectNodes(primaryXPath, this.dsmlNS);

            if (list.Count == 0)
            {
                return(new DirectoryControl[0]);
            }
            DirectoryControl[] controlArray = new DirectoryControl[list.Count];
            int index = 0;

            foreach (XmlNode node in list)
            {
                controlArray[index] = new DirectoryControl((XmlElement)node);
                index++;
            }
            return(controlArray);
        }
Beispiel #19
0
		private DirectoryControl[] ControlsHelper()
		{
			XmlNodeList xmlNodeLists = this.dsmlNode.SelectNodes("dsml:control", this.dsmlNS);
			if (xmlNodeLists.Count != 0)
			{
				DirectoryControl[] directoryControl = new DirectoryControl[xmlNodeLists.Count];
				int num = 0;
				foreach (XmlNode xmlNodes in xmlNodeLists)
				{
					directoryControl[num] = new DirectoryControl((XmlElement)xmlNodes);
					num++;
				}
				return directoryControl;
			}
			else
			{
				return new DirectoryControl[0];
			}
		}
        private DirectoryControl[] ControlsHelper()
        {
            XmlNodeList xmlNodeLists = this.dsmlNode.SelectNodes("dsml:control", this.dsmlNS);

            if (xmlNodeLists.Count != 0)
            {
                DirectoryControl[] directoryControl = new DirectoryControl[xmlNodeLists.Count];
                int num = 0;
                foreach (XmlNode xmlNodes in xmlNodeLists)
                {
                    directoryControl[num] = new DirectoryControl((XmlElement)xmlNodes);
                    num++;
                }
                return(directoryControl);
            }
            else
            {
                return(new DirectoryControl[0]);
            }
        }
Beispiel #21
0
        internal DirectoryControl[] ControlsHelper(string primaryXPath)
        {
            XmlNodeList xmlNodeLists = this.dsmlNode.SelectNodes(primaryXPath, this.dsmlNS);

            if (xmlNodeLists.Count != 0)
            {
                DirectoryControl[] directoryControl = new DirectoryControl[xmlNodeLists.Count];
                int num = 0;
                foreach (XmlNode xmlNodes in xmlNodeLists)
                {
                    directoryControl[num] = new DirectoryControl((XmlElement)xmlNodes);
                    num++;
                }
                return(directoryControl);
            }
            else
            {
                return(new DirectoryControl[0]);
            }
        }
Beispiel #22
0
		internal static void TransformControls(DirectoryControl[] controls)
		{
			if (controls != null)
			{
				for (int i = 0; i < (int)controls.Length; i++)
				{
					if (!(controls[i].GetType() != typeof(DirectoryControl)) && controls[i].Type == "1.2.840.113556.1.4.1504")
					{
						byte[] value = controls[i].GetValue();
						object[] objArray = BerConverter.Decode("{e}", value);
						int num = (int)objArray[0];
						ADAsqResponseControl aDAsqResponseControl = new ADAsqResponseControl(num, controls[i].IsCritical, value);
						controls[i] = aDAsqResponseControl;
					}
				}
				return;
			}
			else
			{
				return;
			}
		}
Beispiel #23
0
        private DirectoryControl[] ControlsHelper()
        {
            XmlNodeList nodeList = _dsmlNode.SelectNodes("dsml:control", _dsmlNS);

            if (nodeList.Count == 0)
            {
                // the server returned no controls
                return(new DirectoryControl[0]);
            }

            // Build the DirectoryControl array
            DirectoryControl[] controls = new DirectoryControl[nodeList.Count];
            int index = 0;

            foreach (XmlNode node in nodeList)
            {
                Debug.Assert(node is XmlElement);

                controls[index] = new DirectoryControl((XmlElement)node);
                index++;
            }

            return(controls);
        }
Beispiel #24
0
 public bool Contains(DirectoryControl value)
 {
     return(List.Contains(value));
 }
Beispiel #25
0
 public int IndexOf(DirectoryControl value)
 {
     return(List.IndexOf(value));
 }
Beispiel #26
0
        internal static void TransformControls(DirectoryControl[] controls)
        {
            for (int i = 0; i < controls.Length; i++)
            {
                Debug.Assert(controls[i] != null);
                byte[] value = controls[i].GetValue();
                // if it is a page control
                if (controls[i].Type == "1.2.840.113556.1.4.319")
                {
                    object[] result = BerConverter.Decode("{iO}", value);
                    Debug.Assert((result != null) && (result.Length == 2));

                    int size = (int)result[0];
                    byte[] cookie = (byte[])result[1];
                    // user expects cookie with length 0 as paged search is done.
                    if (cookie == null)
                        cookie = new byte[0];

                    PageResultResponseControl pageControl = new PageResultResponseControl(size, cookie, controls[i].IsCritical, controls[i].GetValue());
                    controls[i] = pageControl;
                }
                else if (controls[i].Type == "1.2.840.113556.1.4.1504")
                {
                    // asq control
                    object[] o = null;
                    if (Utility.IsWin2kOS)
                        o = BerConverter.Decode("{i}", value);
                    else
                        o = BerConverter.Decode("{e}", value);
                    Debug.Assert((o != null) && (o.Length == 1));

                    int result = (int)o[0];
                    AsqResponseControl asq = new AsqResponseControl(result, controls[i].IsCritical, controls[i].GetValue());
                    controls[i] = asq;
                }
                else if (controls[i].Type == "1.2.840.113556.1.4.841")
                {
                    //dirsync control
                    object[] o = BerConverter.Decode("{iiO}", value);
                    Debug.Assert(o != null && o.Length == 3);

                    int moreData = (int)o[0];
                    int count = (int)o[1];
                    byte[] dirsyncCookie = (byte[])o[2];

                    DirSyncResponseControl dirsync = new DirSyncResponseControl(dirsyncCookie, (moreData == 0 ? false : true), count, controls[i].IsCritical, controls[i].GetValue());
                    controls[i] = dirsync;
                }
                else if (controls[i].Type == "1.2.840.113556.1.4.474")
                {
                    object[] o = null;
                    int result = 0;
                    string attribute = null;
                    bool decodeSucceeded;
                    //sort control

                    if (Utility.IsWin2kOS)
                        // win2k berencoding does not understand enumeration
                        o = BerConverter.TryDecode("{ia}", value, out decodeSucceeded);
                    else
                        o = BerConverter.TryDecode("{ea}", value, out decodeSucceeded);

                    // decode might fail as AD for example never returns attribute name, we don't want to unnecessarily throw and catch exception
                    if (decodeSucceeded)
                    {
                        Debug.Assert(o != null && o.Length == 2);
                        result = (int)o[0];
                        attribute = (string)o[1];
                    }
                    else
                    {
                        // decoding might fail as attribute is optional
                        if (Utility.IsWin2kOS)
                            // win2k berencoding does not understand enumeration
                            o = BerConverter.Decode("{i}", value);
                        else
                            o = BerConverter.Decode("{e}", value);
                        Debug.Assert(o != null && o.Length == 1);

                        result = (int)o[0];
                    }

                    SortResponseControl sort = new SortResponseControl((ResultCode)result, attribute, controls[i].IsCritical, controls[i].GetValue());
                    controls[i] = sort;
                }
                else if (controls[i].Type == "2.16.840.1.113730.3.4.10")
                {
                    int position;
                    int count;
                    int result;
                    byte[] context = null;
                    object[] o = null;
                    bool decodeSucceeded = false;

                    if (Utility.IsWin2kOS)
                        // win2k berencoding does not understand enumeration
                        o = BerConverter.TryDecode("{iiiO}", value, out decodeSucceeded);
                    else
                        o = BerConverter.TryDecode("{iieO}", value, out decodeSucceeded);

                    if (decodeSucceeded)
                    {
                        Debug.Assert(o != null && o.Length == 4);
                        position = (int)o[0];
                        count = (int)o[1];
                        result = (int)o[2];
                        context = (byte[])o[3];
                    }
                    else
                    {
                        if (Utility.IsWin2kOS)
                            // win2k berencoding does not understand enumeration
                            o = BerConverter.Decode("{iii}", value);
                        else
                            o = BerConverter.Decode("{iie}", value);
                        Debug.Assert(o != null && o.Length == 3);
                        position = (int)o[0];
                        count = (int)o[1];
                        result = (int)o[2];
                    }

                    VlvResponseControl vlv = new VlvResponseControl(position, count, context, (ResultCode)result, controls[i].IsCritical, controls[i].GetValue());
                    controls[i] = vlv;
                }
            }
        }
Beispiel #27
0
		internal static void TransformControls(DirectoryControl[] controls)
		{
			object[] objArray;
			object[] objArray1;
			int num;
			bool flag = false;
			int num1;
			int num2;
			int num3;
			object[] objArray2;
			bool flag1;
			for (int i = 0; i < (int)controls.Length; i++)
			{
				byte[] value = controls[i].GetValue();
				if (controls[i].Type != "1.2.840.113556.1.4.319")
				{
					if (controls[i].Type != "1.2.840.113556.1.4.1504")
					{
						if (controls[i].Type != "1.2.840.113556.1.4.841")
						{
							if (controls[i].Type != "1.2.840.113556.1.4.474")
							{
								if (controls[i].Type == "2.16.840.1.113730.3.4.10")
								{
									byte[] numArray = null;
									bool flag2 = false;
									if (!Utility.IsWin2kOS)
									{
										objArray2 = BerConverter.TryDecode("{iieO}", value, out flag2);
									}
									else
									{
										objArray2 = BerConverter.TryDecode("{iiiO}", value, out flag2);
									}
									if (!flag2)
									{
										if (!Utility.IsWin2kOS)
										{
											objArray2 = BerConverter.Decode("{iie}", value);
										}
										else
										{
											objArray2 = BerConverter.Decode("{iii}", value);
										}
										num1 = (int)objArray2[0];
										num2 = (int)objArray2[1];
										num3 = (int)objArray2[2];
									}
									else
									{
										num1 = (int)objArray2[0];
										num2 = (int)objArray2[1];
										num3 = (int)objArray2[2];
										numArray = (byte[])objArray2[3];
									}
									VlvResponseControl vlvResponseControl = new VlvResponseControl(num1, num2, numArray, (ResultCode)num3, controls[i].IsCritical, controls[i].GetValue());
									controls[i] = vlvResponseControl;
								}
							}
							else
							{
								string str = null;
								if (!Utility.IsWin2kOS)
								{
									objArray1 = BerConverter.TryDecode("{ea}", value, out flag);
								}
								else
								{
									objArray1 = BerConverter.TryDecode("{ia}", value, out flag);
								}
								if (!flag)
								{
									if (!Utility.IsWin2kOS)
									{
										objArray1 = BerConverter.Decode("{e}", value);
									}
									else
									{
										objArray1 = BerConverter.Decode("{i}", value);
									}
									num = (int)objArray1[0];
								}
								else
								{
									num = (int)objArray1[0];
									str = (string)objArray1[1];
								}
								SortResponseControl sortResponseControl = new SortResponseControl((ResultCode)num, str, controls[i].IsCritical, controls[i].GetValue());
								controls[i] = sortResponseControl;
							}
						}
						else
						{
							object[] objArray3 = BerConverter.Decode("{iiO}", value);
							int num4 = (int)objArray3[0];
							int num5 = (int)objArray3[1];
							byte[] numArray1 = (byte[])objArray3[2];
							byte[] numArray2 = numArray1;
							if (num4 == 0)
							{
								flag1 = false;
							}
							else
							{
								flag1 = true;
							}
							DirSyncResponseControl dirSyncResponseControl = new DirSyncResponseControl(numArray2, flag1, num5, controls[i].IsCritical, controls[i].GetValue());
							controls[i] = dirSyncResponseControl;
						}
					}
					else
					{
						if (!Utility.IsWin2kOS)
						{
							objArray = BerConverter.Decode("{e}", value);
						}
						else
						{
							objArray = BerConverter.Decode("{i}", value);
						}
						int num6 = (int)objArray[0];
						AsqResponseControl asqResponseControl = new AsqResponseControl(num6, controls[i].IsCritical, controls[i].GetValue());
						controls[i] = asqResponseControl;
					}
				}
				else
				{
					object[] objArray4 = BerConverter.Decode("{iO}", value);
					int num7 = (int)objArray4[0];
					byte[] numArray3 = (byte[])objArray4[1];
					if (numArray3 == null)
					{
						numArray3 = new byte[0];
					}
					PageResultResponseControl pageResultResponseControl = new PageResultResponseControl(num7, numArray3, controls[i].IsCritical, controls[i].GetValue());
					controls[i] = pageResultResponseControl;
				}
			}
		}
Beispiel #28
0
		internal CompareResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral)
		{
		}
Beispiel #29
0
 public void AddControl(DirectoryControl control)
 {
     this.UserControls.Add(control);
 }
		public void CopyTo(DirectoryControl[] array, int index)
		{
			base.List.CopyTo(array, index);
		}
Beispiel #31
0
        public void AddRange(DirectoryControl[] controls)
        {
            if (controls == null)
                throw new ArgumentNullException("controls");

            foreach (DirectoryControl c in controls)
            {
                if (c == null)
                {
                    throw new ArgumentException(Res.GetString(Res.ContainNullControl), "controls");
                }
            }

            InnerList.AddRange(controls);
        }
Beispiel #32
0
		internal SearchResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral)
		{
			this.referenceCollection = new SearchResultReferenceCollection();
			this.entryCollection = new SearchResultEntryCollection();
		}
		public int IndexOf(DirectoryControl value)
		{
			return base.List.IndexOf(value);
		}
Beispiel #34
0
        private DirectoryControl[] ControlsHelper()
        {
            XmlNodeList nodeList = _dsmlNode.SelectNodes("dsml:control", _dsmlNS);

            if (nodeList.Count == 0)
            {
                // the server returned no controls
                return new DirectoryControl[0];
            }

            // Build the DirectoryControl array
            DirectoryControl[] controls = new DirectoryControl[nodeList.Count];
            int index = 0;

            foreach (XmlNode node in nodeList)
            {
                Debug.Assert(node is XmlElement);

                controls[index] = new DirectoryControl((XmlElement)node);
                index++;
            }

            return controls;
        }
 public void Insert(int index, DirectoryControl value)
 {
     List.Insert(index, value);
 }
 public int Add(DirectoryControl control)
 {
     return(List.Add(control));
 }
Beispiel #37
0
 public void Remove(DirectoryControl value)
 {
     List.Remove(value);
 }
		public bool Contains(DirectoryControl value)
		{
			return base.List.Contains(value);
		}
Beispiel #39
0
		internal SearchResultEntry (SearchResultAttributeCollection attributes, DirectoryControl [] controls, string distinguishedName)
		{
			Attributes = attributes;
			Controls = controls;
			DistinguishedName = distinguishedName;
		}
		public void Remove(DirectoryControl value)
		{
			base.List.Remove(value);
		}
Beispiel #41
0
        internal unsafe int ConstructParsedResult(IntPtr ldapResult, ref int serverError, ref string responseDn, ref string responseMessage, ref Uri[] responseReferral, ref DirectoryControl[] responseControl)
        {
            IntPtr dn = (IntPtr)0;
            IntPtr message = (IntPtr)0;
            IntPtr referral = (IntPtr)0;
            IntPtr control = (IntPtr)0;
            int resulterror = 0;

            try
            {
                resulterror = Wldap32.ldap_parse_result(ldapHandle, ldapResult, ref serverError, ref dn, ref message, ref referral, ref control, 0 /* not free it */);

                if (resulterror == 0)
                {
                    // parsing dn
                    responseDn = Marshal.PtrToStringUni(dn);

                    // parsing message
                    responseMessage = Marshal.PtrToStringUni(message);

                    // parsing referral                    
                    if (referral != (IntPtr)0)
                    {
                        char** tempPtr = (char**)referral;
                        char* singleReferral = tempPtr[0];
                        int i = 0;
                        ArrayList referralList = new ArrayList();
                        while (singleReferral != null)
                        {
                            string s = Marshal.PtrToStringUni((IntPtr)singleReferral);
                            referralList.Add(s);

                            i++;
                            singleReferral = tempPtr[i];
                        }

                        if (referralList.Count > 0)
                        {
                            responseReferral = new Uri[referralList.Count];
                            for (int j = 0; j < referralList.Count; j++)
                                responseReferral[j] = new Uri((string)referralList[j]);
                        }
                    }

                    // parsing control                                                
                    if (control != (IntPtr)0)
                    {
                        int i = 0;
                        IntPtr tempControlPtr = control;
                        IntPtr singleControl = Marshal.ReadIntPtr(tempControlPtr, 0);
                        ArrayList controlList = new ArrayList();
                        while (singleControl != (IntPtr)0)
                        {
                            DirectoryControl directoryControl = ConstructControl(singleControl);
                            controlList.Add(directoryControl);

                            i++;
                            singleControl = Marshal.ReadIntPtr(tempControlPtr, i * Marshal.SizeOf(typeof(IntPtr)));
                        }

                        responseControl = new DirectoryControl[controlList.Count];
                        controlList.CopyTo(responseControl);
                    }
                }
                else
                {
                    // we need to take care of one special case, when can't connect to the server, ldap_parse_result fails with local error 
                    if (resulterror == (int)LdapError.LocalError)
                    {
                        int tmpResult = Wldap32.ldap_result2error(ldapHandle, ldapResult, 0 /* not free it */);
                        if (tmpResult != 0)
                        {
                            resulterror = tmpResult;
                        }
                    }
                }
            }
            finally
            {
                if (dn != (IntPtr)0)
                {
                    Wldap32.ldap_memfree(dn);
                }

                if (message != (IntPtr)0)
                    Wldap32.ldap_memfree(message);

                if (referral != (IntPtr)0)
                    Wldap32.ldap_value_free(referral);

                if (control != (IntPtr)0)
                    Wldap32.ldap_controls_free(control);
            }

            return resulterror;
        }
Beispiel #42
0
		internal DirectoryControl[] ControlsHelper(string primaryXPath)
		{
			XmlNodeList xmlNodeLists = this.dsmlNode.SelectNodes(primaryXPath, this.dsmlNS);
			if (xmlNodeLists.Count != 0)
			{
				DirectoryControl[] directoryControl = new DirectoryControl[xmlNodeLists.Count];
				int num = 0;
				foreach (XmlNode xmlNodes in xmlNodeLists)
				{
					directoryControl[num] = new DirectoryControl((XmlElement)xmlNodes);
					num++;
				}
				return directoryControl;
			}
			else
			{
				return new DirectoryControl[0];
			}
		}
Beispiel #43
0
		public ADSearchResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral)
		{
			this._entries = new List<ADObject>();
		}
Beispiel #44
0
		public ADAddResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral)
		{
		}
Beispiel #45
0
		public ADAddResponse(string dn, DirectoryControl[] controls, ResultCode result, string message) : base(dn, controls, result, message, null)
		{
		}
Beispiel #46
0
		internal unsafe int ConstructParsedResult(IntPtr ldapResult, ref int serverError, ref string responseDn, ref string responseMessage, ref Uri[] responseReferral, ref DirectoryControl[] responseControl)
		{
			IntPtr intPtr = (IntPtr)0;
			IntPtr intPtr1 = (IntPtr)0;
			IntPtr intPtr2 = (IntPtr)0;
			IntPtr intPtr3 = (IntPtr)0;
			int num = 0;
			try
			{
				num = Wldap32.ldap_parse_result(this.ldapHandle, ldapResult, ref serverError, ref intPtr, ref intPtr1, ref intPtr2, ref intPtr3, 0);
				if (num != 0)
				{
					if (num == 82)
					{
						int num1 = Wldap32.ldap_result2error(this.ldapHandle, ldapResult, 0);
						if (num1 != 0)
						{
							num = num1;
						}
					}
				}
				else
				{
					responseDn = Marshal.PtrToStringUni(intPtr);
					responseMessage = Marshal.PtrToStringUni(intPtr1);
					if (intPtr2 != (IntPtr)0)
					{
						char** chrPointer = (char**)((void*)intPtr2);
						char* chrPointer1 = (char*)((void*)(*(chrPointer)));
						int num2 = 0;
						ArrayList arrayLists = new ArrayList();
						while (chrPointer1 != null)
						{
							string stringUni = Marshal.PtrToStringUni((IntPtr)chrPointer1);
							arrayLists.Add(stringUni);
							num2++;
							chrPointer1 = (char*)((void*)(*(chrPointer + num2 * sizeof(char*))));
						}
						if (arrayLists.Count > 0)
						{
							responseReferral = new Uri[arrayLists.Count];
							for (int i = 0; i < arrayLists.Count; i++)
							{
								responseReferral[i] = new Uri((string)arrayLists[i]);
							}
						}
					}
					if (intPtr3 != (IntPtr)0)
					{
						int num3 = 0;
						IntPtr intPtr4 = intPtr3;
						IntPtr intPtr5 = Marshal.ReadIntPtr(intPtr4, 0);
						ArrayList arrayLists1 = new ArrayList();
						while (intPtr5 != (IntPtr)0)
						{
							DirectoryControl directoryControl = this.ConstructControl(intPtr5);
							arrayLists1.Add(directoryControl);
							num3++;
							intPtr5 = Marshal.ReadIntPtr(intPtr4, num3 * Marshal.SizeOf(typeof(IntPtr)));
						}
						responseControl = new DirectoryControl[arrayLists1.Count];
						arrayLists1.CopyTo(responseControl);
					}
				}
			}
			finally
			{
				if (intPtr != (IntPtr)0)
				{
					Wldap32.ldap_memfree(intPtr);
				}
				if (intPtr1 != (IntPtr)0)
				{
					Wldap32.ldap_memfree(intPtr1);
				}
				if (intPtr2 != (IntPtr)0)
				{
					Wldap32.ldap_value_free(intPtr2);
				}
				if (intPtr3 != (IntPtr)0)
				{
					Wldap32.ldap_controls_free(intPtr3);
				}
			}
			return num;
		}