public override byte[] GetValue()
 {
     object[] objArray = new object[1];
     objArray[0] = (int)this.flag;
     this.directoryControlValue = BerConverter.Encode("{i}", objArray);
     return(base.GetValue());
 }
Ejemplo n.º 2
0
 public override byte[] GetValue()
 {
     object[] objArray = new object[2];
     objArray[0] = this.size;
     objArray[1] = this.pageCookie;
     object[] objArray1 = objArray;
     this.directoryControlValue = BerConverter.Encode("{io}", objArray1);
     return(base.GetValue());
 }
Ejemplo n.º 3
0
 public override byte[] GetValue()
 {
     object[] objArray = new object[3];
     objArray[0] = (int)this.flag;
     objArray[1] = this.count;
     objArray[2] = this.dirsyncCookie;
     object[] objArray1 = objArray;
     this.directoryControlValue = BerConverter.Encode("{iio}", objArray1);
     return(base.GetValue());
 }
 public override byte[] GetValue()
 {
     byte[] bytes = null;
     if (this.ServerName != null)
     {
         bytes = new UnicodeEncoding().GetBytes(this.ServerName);
     }
     base.directoryControlValue = BerConverter.Encode("{io}", new object[] { this.flag, bytes });
     return(base.GetValue());
 }
Ejemplo n.º 5
0
 public override byte[] GetValue()
 {
     byte[] tmpValue = null;
     if (ServerName != null)
     {
         UnicodeEncoding unicode = new UnicodeEncoding();
         tmpValue = unicode.GetBytes(ServerName);
     }
     this.directoryControlValue = BerConverter.Encode("{io}", new object[] { _flag, tmpValue });
     return(base.GetValue());
 }
Ejemplo n.º 6
0
        public static object[] Decode(string format, byte[] value)
        {
            bool flag = false;

            object[] objArray = BerConverter.TryDecode(format, value, out flag);
            if (!flag)
            {
                throw new BerConversionException();
            }
            else
            {
                return(objArray);
            }
        }
Ejemplo n.º 7
0
 public override byte[] GetValue()
 {
     byte[] bytes = null;
     if (this.ServerName != null)
     {
         UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
         bytes = unicodeEncoding.GetBytes(this.ServerName);
     }
     object[] objArray = new object[2];
     objArray[0] = this.flag;
     objArray[1] = bytes;
     this.directoryControlValue = BerConverter.Encode("{io}", objArray);
     return(base.GetValue());
 }
Ejemplo n.º 8
0
        public override byte[] GetValue()
        {
            StringBuilder seq     = new StringBuilder(10);
            ArrayList     objList = new ArrayList();

            // first encode the before and the after count.
            seq.Append("{ii");
            objList.Add(BeforeCount);
            objList.Add(AfterCount);

            // encode Target if it is not null
            if (Target.Length != 0)
            {
                seq.Append("t");
                objList.Add(0x80 | 0x1);
                seq.Append("o");
                objList.Add(Target);
            }
            else
            {
                seq.Append("t{");
                objList.Add(0xa0);
                seq.Append("ii");
                objList.Add(Offset);
                objList.Add(EstimateCount);
                seq.Append("}");
            }

            // encode the contextID if present
            if (ContextId.Length != 0)
            {
                seq.Append("o");
                objList.Add(ContextId);
            }

            seq.Append("}");
            object[] values = new object[objList.Count];
            for (int i = 0; i < objList.Count; i++)
            {
                values[i] = objList[i];
            }

            directoryControlValue = BerConverter.Encode(seq.ToString(), values);
            return(base.GetValue());
        }
Ejemplo n.º 9
0
        public override byte[] GetValue()
        {
            StringBuilder builder = new StringBuilder(10);
            ArrayList     list    = new ArrayList();

            builder.Append("{ii");
            list.Add(this.BeforeCount);
            list.Add(this.AfterCount);
            if (this.Target.Length != 0)
            {
                builder.Append("t");
                list.Add(0x81);
                builder.Append("o");
                list.Add(this.Target);
            }
            else
            {
                builder.Append("t{");
                list.Add(160);
                builder.Append("ii");
                list.Add(this.Offset);
                list.Add(this.EstimateCount);
                builder.Append("}");
            }
            if (this.ContextId.Length != 0)
            {
                builder.Append("o");
                list.Add(this.ContextId);
            }
            builder.Append("}");
            object[] objArray = new object[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                objArray[i] = list[i];
            }
            base.directoryControlValue = BerConverter.Encode(builder.ToString(), objArray);
            return(base.GetValue());
        }
Ejemplo n.º 10
0
        public override byte[] GetValue()
        {
            StringBuilder stringBuilder = new StringBuilder(10);
            ArrayList     arrayLists    = new ArrayList();

            stringBuilder.Append("{ii");
            arrayLists.Add(this.BeforeCount);
            arrayLists.Add(this.AfterCount);
            if ((int)this.Target.Length == 0)
            {
                stringBuilder.Append("t{");
                arrayLists.Add(160);
                stringBuilder.Append("ii");
                arrayLists.Add(this.Offset);
                arrayLists.Add(this.EstimateCount);
                stringBuilder.Append("}");
            }
            else
            {
                stringBuilder.Append("t");
                arrayLists.Add(129);
                stringBuilder.Append("o");
                arrayLists.Add(this.Target);
            }
            if ((int)this.ContextId.Length != 0)
            {
                stringBuilder.Append("o");
                arrayLists.Add(this.ContextId);
            }
            stringBuilder.Append("}");
            object[] item = new object[arrayLists.Count];
            for (int i = 0; i < arrayLists.Count; i++)
            {
                item[i] = arrayLists[i];
            }
            this.directoryControlValue = BerConverter.Encode(stringBuilder.ToString(), item);
            return(base.GetValue());
        }
Ejemplo n.º 11
0
 public override byte[] GetValue()
 {
     object[] o = new object[] { _size, _pageCookie };
     this.directoryControlValue = BerConverter.Encode("{io}", o);
     return(base.GetValue());
 }
Ejemplo n.º 12
0
 public override byte[] GetValue()
 {
     object[] o = new object[] { (int)_flag, _count, _dirsyncCookie };
     this.directoryControlValue = BerConverter.Encode("{iio}", o);
     return(base.GetValue());
 }
Ejemplo n.º 13
0
        public static byte[] Encode(string format, object[] value)
        {
            int num;

            Utility.CheckOSVersion();
            if (format != null)
            {
                UTF8Encoding uTF8Encoding = new UTF8Encoding();
                byte[]       numArray     = null;
                if (value == null)
                {
                    value = new object[0];
                }
                BerSafeHandle berSafeHandle = new BerSafeHandle();
                int           num1          = 0;
                int           num2          = 0;
                int           num3          = 0;
                while (num3 < format.Length)
                {
                    char chr = format[num3];
                    if (chr == '{' || chr == '}' || chr == '[' || chr == ']' || chr == 'n')
                    {
                        num2 = Wldap32.ber_printf_emptyarg(berSafeHandle, new string(chr, 1));
                    }
                    else
                    {
                        if (chr == 't' || chr == 'i' || chr == 'e')
                        {
                            if (num1 < (int)value.Length)
                            {
                                if (value[num1] is int)
                                {
                                    num2 = Wldap32.ber_printf_int(berSafeHandle, new string(chr, 1), (int)value[num1]);
                                    num1++;
                                }
                                else
                                {
                                    throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                }
                            }
                            else
                            {
                                throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                            }
                        }
                        else
                        {
                            if (chr != 'b')
                            {
                                if (chr != 's')
                                {
                                    if (chr == 'o' || chr == 'X')
                                    {
                                        if (num1 < (int)value.Length)
                                        {
                                            if (value[num1] == null || value[num1] as byte[] != null)
                                            {
                                                byte[] numArray1 = (byte[])value[num1];
                                                num2 = BerConverter.EncodingByteArrayHelper(berSafeHandle, numArray1, chr);
                                                num1++;
                                            }
                                            else
                                            {
                                                throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                            }
                                        }
                                        else
                                        {
                                            throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                        }
                                    }
                                    else
                                    {
                                        if (chr != 'v')
                                        {
                                            if (chr != 'V')
                                            {
                                                throw new ArgumentException(Res.GetString("BerConverterUndefineChar"));
                                            }
                                            else
                                            {
                                                if (num1 < (int)value.Length)
                                                {
                                                    if (value[num1] == null || value[num1] as byte[][] != null)
                                                    {
                                                        byte[][] numArray2 = (byte[][])value[num1];
                                                        num2 = BerConverter.EncodingMultiByteArrayHelper(berSafeHandle, numArray2, chr);
                                                        num1++;
                                                    }
                                                    else
                                                    {
                                                        throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                                    }
                                                }
                                                else
                                                {
                                                    throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (num1 < (int)value.Length)
                                            {
                                                if (value[num1] == null || value[num1] as string[] != null)
                                                {
                                                    string[] strArrays = (string[])value[num1];
                                                    byte[][] bytes     = null;
                                                    if (strArrays != null)
                                                    {
                                                        bytes = new byte[(int)strArrays.Length][];
                                                        for (int i = 0; i < (int)strArrays.Length; i++)
                                                        {
                                                            string str = strArrays[i];
                                                            if (str != null)
                                                            {
                                                                bytes[i] = uTF8Encoding.GetBytes(str);
                                                            }
                                                            else
                                                            {
                                                                bytes[i] = null;
                                                            }
                                                        }
                                                    }
                                                    num2 = BerConverter.EncodingMultiByteArrayHelper(berSafeHandle, bytes, 'V');
                                                    num1++;
                                                }
                                                else
                                                {
                                                    throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                                }
                                            }
                                            else
                                            {
                                                throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (num1 < (int)value.Length)
                                    {
                                        if (value[num1] == null || value[num1] as string != null)
                                        {
                                            byte[] bytes1 = null;
                                            if (value[num1] != null)
                                            {
                                                bytes1 = uTF8Encoding.GetBytes((string)value[num1]);
                                            }
                                            num2 = BerConverter.EncodingByteArrayHelper(berSafeHandle, bytes1, 'o');
                                            num1++;
                                        }
                                        else
                                        {
                                            throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                        }
                                    }
                                    else
                                    {
                                        throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                    }
                                }
                            }
                            else
                            {
                                if (num1 < (int)value.Length)
                                {
                                    if (value[num1] is bool)
                                    {
                                        BerSafeHandle berSafeHandle1 = berSafeHandle;
                                        string        str1           = new string(chr, 1);
                                        if ((bool)value[num1])
                                        {
                                            num = 1;
                                        }
                                        else
                                        {
                                            num = 0;
                                        }
                                        num2 = Wldap32.ber_printf_int(berSafeHandle1, str1, num);
                                        num1++;
                                    }
                                    else
                                    {
                                        throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                    }
                                }
                                else
                                {
                                    throw new ArgumentException(Res.GetString("BerConverterNotMatch"));
                                }
                            }
                        }
                    }
                    if (num2 != -1)
                    {
                        num3++;
                    }
                    else
                    {
                        throw new BerConversionException();
                    }
                }
                berval _berval = new berval();
                IntPtr intPtr  = (IntPtr)0;
                try
                {
                    num2 = Wldap32.ber_flatten(berSafeHandle, ref intPtr);
                    if (num2 != -1)
                    {
                        if (intPtr != (IntPtr)0)
                        {
                            Marshal.PtrToStructure(intPtr, _berval);
                        }
                        if (_berval == null || _berval.bv_len == 0)
                        {
                            numArray = new byte[0];
                        }
                        else
                        {
                            numArray = new byte[_berval.bv_len];
                            Marshal.Copy(_berval.bv_val, numArray, 0, _berval.bv_len);
                        }
                    }
                    else
                    {
                        throw new BerConversionException();
                    }
                }
                finally
                {
                    if (intPtr != (IntPtr)0)
                    {
                        Wldap32.ber_bvfree(intPtr);
                    }
                }
                return(numArray);
            }
            else
            {
                throw new ArgumentNullException("format");
            }
        }
Ejemplo n.º 14
0
 public override byte[] GetValue()
 {
     this.directoryControlValue = BerConverter.Encode("{s}", new object[] { _name });
     return(base.GetValue());
 }
Ejemplo n.º 15
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;
                }
            }
        }
 public override byte[] GetValue()
 {
     object[] objArray = new object[] { (int)this.flag, this.count, this.dirsyncCookie };
     base.directoryControlValue = BerConverter.Encode("{iio}", objArray);
     return(base.GetValue());
 }
Ejemplo n.º 17
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.º 18
0
 internal static object[] TryDecode(string format, byte[] value, out bool decodeSucceeded)
 {
     Utility.CheckOSVersion();
     if (format != null)
     {
         UTF8Encoding  uTF8Encoding  = new UTF8Encoding(false, true);
         berval        _berval       = new berval();
         ArrayList     arrayLists    = new ArrayList();
         BerSafeHandle berSafeHandle = null;
         object[]      item          = null;
         decodeSucceeded = false;
         if (value != null)
         {
             _berval.bv_len = (int)value.Length;
             _berval.bv_val = Marshal.AllocHGlobal((int)value.Length);
             Marshal.Copy(value, 0, _berval.bv_val, (int)value.Length);
         }
         else
         {
             _berval.bv_len = 0;
             _berval.bv_val = (IntPtr)0;
         }
         try
         {
             berSafeHandle = new BerSafeHandle(_berval);
         }
         finally
         {
             if (_berval.bv_val != (IntPtr)0)
             {
                 Marshal.FreeHGlobal(_berval.bv_val);
             }
         }
         int num  = 0;
         int num1 = 0;
         while (num1 < format.Length)
         {
             char chr = format[num1];
             if (chr == '{' || chr == '}' || chr == '[' || chr == ']' || chr == 'n' || chr == 'x')
             {
                 num = Wldap32.ber_scanf(berSafeHandle, new string(chr, 1));
                 if (num != 0)
                 {
                 }
             }
             else
             {
                 if (chr == 'i' || chr == 'e' || chr == 'b')
                 {
                     int num2 = 0;
                     num = Wldap32.ber_scanf_int(berSafeHandle, new string(chr, 1), ref num2);
                     if (num == 0)
                     {
                         if (chr != 'b')
                         {
                             arrayLists.Add(num2);
                         }
                         else
                         {
                             bool flag = false;
                             if (num2 != 0)
                             {
                                 flag = true;
                             }
                             else
                             {
                                 flag = false;
                             }
                             arrayLists.Add(flag);
                         }
                     }
                 }
                 else
                 {
                     if (chr != 'a')
                     {
                         if (chr != 'O')
                         {
                             if (chr != 'B')
                             {
                                 if (chr != 'v')
                                 {
                                     if (chr != 'V')
                                     {
                                         throw new ArgumentException(Res.GetString("BerConverterUndefineChar"));
                                     }
                                     else
                                     {
                                         byte[][] numArray = BerConverter.DecodingMultiByteArrayHelper(berSafeHandle, chr, ref num);
                                         if (num == 0)
                                         {
                                             arrayLists.Add(numArray);
                                         }
                                     }
                                 }
                                 else
                                 {
                                     string[] str       = null;
                                     byte[][] numArray1 = BerConverter.DecodingMultiByteArrayHelper(berSafeHandle, 'V', ref num);
                                     if (num == 0)
                                     {
                                         if (numArray1 != null)
                                         {
                                             str = new string[(int)numArray1.Length];
                                             for (int i = 0; i < (int)numArray1.Length; i++)
                                             {
                                                 if (numArray1[i] != null)
                                                 {
                                                     str[i] = uTF8Encoding.GetString(numArray1[i]);
                                                 }
                                                 else
                                                 {
                                                     str[i] = null;
                                                 }
                                             }
                                         }
                                         arrayLists.Add(str);
                                     }
                                 }
                             }
                             else
                             {
                                 IntPtr intPtr = (IntPtr)0;
                                 int    num3   = 0;
                                 num = Wldap32.ber_scanf_bitstring(berSafeHandle, "B", ref intPtr, ref num3);
                                 if (num == 0)
                                 {
                                     byte[] numArray2 = null;
                                     if (intPtr != (IntPtr)0)
                                     {
                                         numArray2 = new byte[num3];
                                         Marshal.Copy(intPtr, numArray2, 0, num3);
                                     }
                                     arrayLists.Add(numArray2);
                                 }
                             }
                         }
                         else
                         {
                             byte[] numArray3 = BerConverter.DecodingByteArrayHelper(berSafeHandle, chr, ref num);
                             if (num == 0)
                             {
                                 arrayLists.Add(numArray3);
                             }
                         }
                     }
                     else
                     {
                         byte[] numArray4 = BerConverter.DecodingByteArrayHelper(berSafeHandle, 'O', ref num);
                         if (num == 0)
                         {
                             string str1 = null;
                             if (numArray4 != null)
                             {
                                 str1 = uTF8Encoding.GetString(numArray4);
                             }
                             arrayLists.Add(str1);
                         }
                     }
                 }
             }
             if (num == 0)
             {
                 num1++;
             }
             else
             {
                 return(item);
             }
         }
         item = new object[arrayLists.Count];
         for (int j = 0; j < arrayLists.Count; j++)
         {
             item[j] = arrayLists[j];
         }
         decodeSucceeded = true;
         return(item);
     }
     else
     {
         throw new ArgumentNullException("format");
     }
 }
Ejemplo n.º 19
0
 public override byte[] GetValue()
 {
     object[] objArray = new object[] { this.size, this.pageCookie };
     base.directoryControlValue = BerConverter.Encode("{io}", objArray);
     return(base.GetValue());
 }
Ejemplo n.º 20
0
 public override byte[] GetValue()
 {
     this.directoryControlValue = BerConverter.Encode("{i}", new object[] { (int)_format });
     return base.GetValue();
 }
Ejemplo n.º 21
0
 public override byte[] GetValue()
 {
     this.directoryControlValue = BerConverter.Encode("{o}", new object[] { _sid });
     return base.GetValue();
 }
 public override byte[] GetValue()
 {
     base.directoryControlValue = BerConverter.Encode("{i}", new object[] { (int)this.flag });
     return(base.GetValue());
 }
 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());
         }
     }
 }