예제 #1
0
        private static void ExtractRangeRetrievalDataFromAttributes(ADObject fetchedObject, ADObject targetObject, HashSet <string> rangeRetrievedObjects, HashSet <string> rangeRetrievedAttributes, ref int rangeRetrievalNextIndex)
        {
            string str = null;
            int    num = 0;

            string[] strArrays = new string[fetchedObject.PropertyNames.Count];
            fetchedObject.PropertyNames.CopyTo(strArrays, 0);
            string[] strArrays1 = strArrays;
            for (int i = 0; i < (int)strArrays1.Length; i++)
            {
                string str1 = strArrays1[i];
                if (ADObjectSearcher.ContainsRangeRetrievalTag(str1, out str, out num))
                {
                    rangeRetrievedObjects.Add(fetchedObject.DistinguishedName);
                    if (num != -1)
                    {
                        rangeRetrievedAttributes.Add(str);
                        if (rangeRetrievalNextIndex == -2147483648)
                        {
                            rangeRetrievalNextIndex = num + 1;
                        }
                    }
                    //targetObject[str];
                    targetObject[str].AddRange(fetchedObject[str1]);
                    if (targetObject.Contains(str1))
                    {
                        targetObject.Remove(str1);
                    }
                }
            }
        }
예제 #2
0
        internal ADPropertyValueCollection ConvertFromRaw(string propertyName, ADPropertyValueCollection propertyValues)
        {
            string str = null;
            int    num = 0;
            ADPropertyValueCollection aDPropertyValueCollection;

            byte[] bytes;
            this.Init();
            if (propertyValues.Count != 0)
            {
                ADObjectSearcher.ContainsRangeRetrievalTag(propertyName, out str, out num);
                ADAttributeSyntax propertyType      = this._adSchema.GetPropertyType(str);
                ADAttributeSyntax aDAttributeSyntax = propertyType;
                switch (aDAttributeSyntax)
                {
                case ADAttributeSyntax.DirectoryString:
                case ADAttributeSyntax.DN:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }

                case ADAttributeSyntax.OctetString:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }

                case ADAttributeSyntax.SecurityDescriptor:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            byte[] current = (byte[])enumerator.Current;
                            ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity();
                            activeDirectorySecurity.SetSecurityDescriptorBinaryForm(current);
                            aDPropertyValueCollection.Add(activeDirectorySecurity);
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Int:
                case ADAttributeSyntax.Enumeration:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator1 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator1.MoveNext())
                        {
                            string current1 = (string)enumerator1.Current;
                            aDPropertyValueCollection.Add(int.Parse(current1, NumberFormatInfo.InvariantInfo));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable1 = enumerator1 as IDisposable;
                        if (disposable1 != null)
                        {
                            disposable1.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Int64:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator2 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            string str1 = (string)enumerator2.Current;
                            aDPropertyValueCollection.Add(long.Parse(str1, NumberFormatInfo.InvariantInfo));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator2 as IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Bool:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator3 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator3.MoveNext())
                        {
                            string current2 = (string)enumerator3.Current;
                            if (string.Compare(current2, "TRUE", StringComparison.OrdinalIgnoreCase) != 0)
                            {
                                aDPropertyValueCollection.Add(false);
                            }
                            else
                            {
                                aDPropertyValueCollection.Add(true);
                            }
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable3 = enumerator3 as IDisposable;
                        if (disposable3 != null)
                        {
                            disposable3.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Oid:
                case ADAttributeSyntax.DNWithBinary:
                case ADAttributeSyntax.DNWithString:
                case ADAttributeSyntax.IA5String:
                case ADAttributeSyntax.PrintableString:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }

                case ADAttributeSyntax.GeneralizedTime:
                case ADAttributeSyntax.UtcTime:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator4 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator4.MoveNext())
                        {
                            string str2 = (string)enumerator4.Current;
                            aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str2, propertyType));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable4 = enumerator4 as IDisposable;
                        if (disposable4 != null)
                        {
                            disposable4.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Sid:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator5 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator5.MoveNext())
                        {
                            object obj = enumerator5.Current;
                            if (obj as string == null)
                            {
                                bytes = (byte[])obj;
                            }
                            else
                            {
                                bytes = ADTypeConverter._encoder.GetBytes((string)obj);
                            }
                            aDPropertyValueCollection.Add(new SecurityIdentifier(bytes, 0));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable5 = enumerator5 as IDisposable;
                        if (disposable5 != null)
                        {
                            disposable5.Dispose();
                        }
                    }
                }

                default:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }
                }
                return(aDPropertyValueCollection);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        internal ADPropertyValueCollection ConvertFromRaw(DirectoryAttribute property)
        {
            string str = null;
            int    num = 0;

            this.Init();
            if (property == null || property.Count == 0)
            {
                return(null);
            }
            else
            {
                ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
                ADObjectSearcher.ContainsRangeRetrievalTag(property.Name, out str, out num);
                ADAttributeSyntax propertyType      = this._adSchema.GetPropertyType(str);
                string[]          values            = null;
                byte[][]          numArray          = null;
                ADAttributeSyntax aDAttributeSyntax = propertyType;
                switch (aDAttributeSyntax)
                {
                case ADAttributeSyntax.DirectoryString:
                case ADAttributeSyntax.DN:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }

                case ADAttributeSyntax.OctetString:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
                    break;
                }

                case ADAttributeSyntax.SecurityDescriptor:
                {
                    numArray = (byte[][])property.GetValues(typeof(byte[]));
                    byte[][] numArray1 = numArray;
                    for (int i = 0; i < (int)numArray1.Length; i++)
                    {
                        byte[] numArray2 = numArray1[i];
                        ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity();
                        activeDirectorySecurity.SetSecurityDescriptorBinaryForm(numArray2);
                        aDPropertyValueCollection.Add(activeDirectorySecurity);
                    }
                    break;
                }

                case ADAttributeSyntax.Int:
                case ADAttributeSyntax.Enumeration:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays = values;
                    for (int j = 0; j < (int)strArrays.Length; j++)
                    {
                        string str1 = strArrays[j];
                        aDPropertyValueCollection.Add(int.Parse(str1, NumberFormatInfo.InvariantInfo));
                    }
                    break;
                }

                case ADAttributeSyntax.Int64:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays1 = values;
                    for (int k = 0; k < (int)strArrays1.Length; k++)
                    {
                        string str2 = strArrays1[k];
                        aDPropertyValueCollection.Add(long.Parse(str2, NumberFormatInfo.InvariantInfo));
                    }
                    break;
                }

                case ADAttributeSyntax.Bool:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays2 = values;
                    for (int l = 0; l < (int)strArrays2.Length; l++)
                    {
                        string str3 = strArrays2[l];
                        if (string.Compare(str3, "TRUE", StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            aDPropertyValueCollection.Add(false);
                        }
                        else
                        {
                            aDPropertyValueCollection.Add(true);
                        }
                    }
                    break;
                }

                case ADAttributeSyntax.Oid:
                case ADAttributeSyntax.DNWithBinary:
                case ADAttributeSyntax.DNWithString:
                case ADAttributeSyntax.IA5String:
                case ADAttributeSyntax.PrintableString:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }

                case ADAttributeSyntax.GeneralizedTime:
                case ADAttributeSyntax.UtcTime:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays3 = values;
                    for (int m = 0; m < (int)strArrays3.Length; m++)
                    {
                        string str4 = strArrays3[m];
                        aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str4, propertyType));
                    }
                    break;
                }

                case ADAttributeSyntax.Sid:
                {
                    numArray = (byte[][])property.GetValues(typeof(byte[]));
                    byte[][] numArray3 = numArray;
                    for (int n = 0; n < (int)numArray3.Length; n++)
                    {
                        byte[] numArray4 = numArray3[n];
                        aDPropertyValueCollection.Add(new SecurityIdentifier(numArray4, 0));
                    }
                    break;
                }

                default:
                {
                    if (aDAttributeSyntax == ADAttributeSyntax.ReplicaLink)
                    {
                        aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
                        break;
                    }
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }
                }
                return(aDPropertyValueCollection);
            }
        }