Ejemplo n.º 1
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;
                    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

                    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
                        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;

                    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
                    {
                        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;
                }
            }
        }
Ejemplo n.º 2
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;
				}
			}
		}
Ejemplo n.º 3
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;
                }
            }
        }
 internal static void TransformControls(DirectoryControl[] controls)
 {
     for (int i = 0; i < controls.Length; i++)
     {
         byte[] buffer = controls[i].GetValue();
         if (controls[i].Type == "1.2.840.113556.1.4.319")
         {
             object[] objArray = BerConverter.Decode("{iO}", buffer);
             int      count    = (int)objArray[0];
             byte[]   cookie   = (byte[])objArray[1];
             if (cookie == null)
             {
                 cookie = new byte[0];
             }
             controls[i] = new PageResultResponseControl(count, cookie, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "1.2.840.113556.1.4.1504")
         {
             object[] objArray2 = null;
             if (Utility.IsWin2kOS)
             {
                 objArray2 = BerConverter.Decode("{i}", buffer);
             }
             else
             {
                 objArray2 = BerConverter.Decode("{e}", buffer);
             }
             int result = (int)objArray2[0];
             controls[i] = new AsqResponseControl(result, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "1.2.840.113556.1.4.841")
         {
             object[] objArray3  = BerConverter.Decode("{iiO}", buffer);
             int      num4       = (int)objArray3[0];
             int      resultSize = (int)objArray3[1];
             byte[]   buffer3    = (byte[])objArray3[2];
             controls[i] = new DirSyncResponseControl(buffer3, num4 != 0, resultSize, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "1.2.840.113556.1.4.474")
         {
             bool     flag;
             object[] objArray4     = null;
             int      num6          = 0;
             string   attributeName = null;
             if (Utility.IsWin2kOS)
             {
                 objArray4 = BerConverter.TryDecode("{ia}", buffer, out flag);
             }
             else
             {
                 objArray4 = BerConverter.TryDecode("{ea}", buffer, out flag);
             }
             if (flag)
             {
                 num6          = (int)objArray4[0];
                 attributeName = (string)objArray4[1];
             }
             else
             {
                 if (Utility.IsWin2kOS)
                 {
                     objArray4 = BerConverter.Decode("{i}", buffer);
                 }
                 else
                 {
                     objArray4 = BerConverter.Decode("{e}", buffer);
                 }
                 num6 = (int)objArray4[0];
             }
             controls[i] = new SortResponseControl((ResultCode)num6, attributeName, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "2.16.840.1.113730.3.4.10")
         {
             int      num7;
             int      num8;
             int      num9;
             byte[]   context         = null;
             object[] objArray5       = null;
             bool     decodeSucceeded = false;
             if (Utility.IsWin2kOS)
             {
                 objArray5 = BerConverter.TryDecode("{iiiO}", buffer, out decodeSucceeded);
             }
             else
             {
                 objArray5 = BerConverter.TryDecode("{iieO}", buffer, out decodeSucceeded);
             }
             if (decodeSucceeded)
             {
                 num7    = (int)objArray5[0];
                 num8    = (int)objArray5[1];
                 num9    = (int)objArray5[2];
                 context = (byte[])objArray5[3];
             }
             else
             {
                 if (Utility.IsWin2kOS)
                 {
                     objArray5 = BerConverter.Decode("{iii}", buffer);
                 }
                 else
                 {
                     objArray5 = BerConverter.Decode("{iie}", buffer);
                 }
                 num7 = (int)objArray5[0];
                 num8 = (int)objArray5[1];
                 num9 = (int)objArray5[2];
             }
             controls[i] = new VlvResponseControl(num7, num8, context, (ResultCode)num9, controls[i].IsCritical, controls[i].GetValue());
         }
     }
 }
Ejemplo n.º 5
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;
                }
            }
        }
 internal static void TransformControls(DirectoryControl[] controls)
 {
     for (int i = 0; i < controls.Length; i++)
     {
         byte[] buffer = controls[i].GetValue();
         if (controls[i].Type == "1.2.840.113556.1.4.319")
         {
             object[] objArray = BerConverter.Decode("{iO}", buffer);
             int count = (int) objArray[0];
             byte[] cookie = (byte[]) objArray[1];
             if (cookie == null)
             {
                 cookie = new byte[0];
             }
             controls[i] = new PageResultResponseControl(count, cookie, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "1.2.840.113556.1.4.1504")
         {
             object[] objArray2 = null;
             if (Utility.IsWin2kOS)
             {
                 objArray2 = BerConverter.Decode("{i}", buffer);
             }
             else
             {
                 objArray2 = BerConverter.Decode("{e}", buffer);
             }
             int result = (int) objArray2[0];
             controls[i] = new AsqResponseControl(result, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "1.2.840.113556.1.4.841")
         {
             object[] objArray3 = BerConverter.Decode("{iiO}", buffer);
             int num4 = (int) objArray3[0];
             int resultSize = (int) objArray3[1];
             byte[] buffer3 = (byte[]) objArray3[2];
             controls[i] = new DirSyncResponseControl(buffer3, num4 != 0, resultSize, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "1.2.840.113556.1.4.474")
         {
             bool flag;
             object[] objArray4 = null;
             int num6 = 0;
             string attributeName = null;
             if (Utility.IsWin2kOS)
             {
                 objArray4 = BerConverter.TryDecode("{ia}", buffer, out flag);
             }
             else
             {
                 objArray4 = BerConverter.TryDecode("{ea}", buffer, out flag);
             }
             if (flag)
             {
                 num6 = (int) objArray4[0];
                 attributeName = (string) objArray4[1];
             }
             else
             {
                 if (Utility.IsWin2kOS)
                 {
                     objArray4 = BerConverter.Decode("{i}", buffer);
                 }
                 else
                 {
                     objArray4 = BerConverter.Decode("{e}", buffer);
                 }
                 num6 = (int) objArray4[0];
             }
             controls[i] = new SortResponseControl((ResultCode) num6, attributeName, controls[i].IsCritical, controls[i].GetValue());
         }
         else if (controls[i].Type == "2.16.840.1.113730.3.4.10")
         {
             int num7;
             int num8;
             int num9;
             byte[] context = null;
             object[] objArray5 = null;
             bool decodeSucceeded = false;
             if (Utility.IsWin2kOS)
             {
                 objArray5 = BerConverter.TryDecode("{iiiO}", buffer, out decodeSucceeded);
             }
             else
             {
                 objArray5 = BerConverter.TryDecode("{iieO}", buffer, out decodeSucceeded);
             }
             if (decodeSucceeded)
             {
                 num7 = (int) objArray5[0];
                 num8 = (int) objArray5[1];
                 num9 = (int) objArray5[2];
                 context = (byte[]) objArray5[3];
             }
             else
             {
                 if (Utility.IsWin2kOS)
                 {
                     objArray5 = BerConverter.Decode("{iii}", buffer);
                 }
                 else
                 {
                     objArray5 = BerConverter.Decode("{iie}", buffer);
                 }
                 num7 = (int) objArray5[0];
                 num8 = (int) objArray5[1];
                 num9 = (int) objArray5[2];
             }
             controls[i] = new VlvResponseControl(num7, num8, context, (ResultCode) num9, controls[i].IsCritical, controls[i].GetValue());
         }
     }
 }