示例#1
0
 private void Init()
 {
     if (this._adSchema == null)
     {
         this._adSchema = new ADSchema(this._sessionInfo);
     }
     if (this._adTypeConverter == null)
     {
         this._adTypeConverter = new ADTypeConverter(this._sessionInfo);
     }
 }
示例#2
0
 private void Init()
 {
     if (!this._disposed)
     {
         if (this._syncOps == null)
         {
             this._sessionHandle = this._adSession.GetSessionHandle();
             this._syncOps       = this._adSession.GetSyncOperationsInterface();
             this._typeConverter = new ADTypeConverter(this._adSession.SessionInfo);
         }
         return;
     }
     else
     {
         throw new ObjectDisposedException(this.GetType().Name);
     }
 }
示例#3
0
        private void Init()
        {
            object obj;

            if (!this._disposed)
            {
                if (this._syncOps == null)
                {
                    if (string.IsNullOrEmpty(this._adObject.DistinguishedName))
                    {
                        string   str       = "ADActiveObject";
                        string   str1      = "Init: DistinguishedName is {0}";
                        object[] objArray  = new object[1];
                        object[] objArray1 = objArray;
                        int      num       = 0;
                        if (this._adObject.DistinguishedName == null)
                        {
                            obj = "null";
                        }
                        else
                        {
                            obj = "empty";
                        }
                        objArray1[num] = obj;
                        DebugLogger.LogInfo(str, str1, objArray);
                    }
                    this._sessionHandle = this._adSession.GetSessionHandle();
                    this._syncOps       = this._adSession.GetSyncOperationsInterface();
                    this._typeConverter = new ADTypeConverter(this._adSession.SessionInfo);
                }
                return;
            }
            else
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
        }
示例#4
0
		private void Init()
		{
			if (this._adSchema == null)
			{
				this._adSchema = new ADSchema(this._sessionInfo);
			}
			if (this._adTypeConverter == null)
			{
				this._adTypeConverter = new ADTypeConverter(this._sessionInfo);
			}
		}
示例#5
0
		private void Init()
		{
			if (!this._disposed)
			{
				if (this._syncOps == null)
				{
					this._sessionHandle = this._adSession.GetSessionHandle();
					this._syncOps = this._adSession.GetSyncOperationsInterface();
					this._typeConverter = new ADTypeConverter(this._adSession.SessionInfo);
				}
				return;
			}
			else
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}
		}
示例#6
0
		private void Init()
		{
			object obj;
			if (!this._disposed)
			{
				if (this._syncOps == null)
				{
					if (string.IsNullOrEmpty(this._adObject.DistinguishedName))
					{
						string str = "ADActiveObject";
						string str1 = "Init: DistinguishedName is {0}";
						object[] objArray = new object[1];
						object[] objArray1 = objArray;
						int num = 0;
						if (this._adObject.DistinguishedName == null)
						{
							obj = "null";
						}
						else
						{
							obj = "empty";
						}
						objArray1[num] = obj;
						DebugLogger.LogInfo(str, str1, objArray);
					}
					this._sessionHandle = this._adSession.GetSessionHandle();
					this._syncOps = this._adSession.GetSyncOperationsInterface();
					this._typeConverter = new ADTypeConverter(this._adSession.SessionInfo);
				}
				return;
			}
			else
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}
		}
示例#7
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);
            }
        }
示例#8
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);
            }
        }