Example #1
0
 internal static DateTime ParseDateTimeValue(string value, ADAttributeSyntax syntax)
 {
     if (syntax != ADAttributeSyntax.GeneralizedTime)
     {
         if (syntax != ADAttributeSyntax.UtcTime)
         {
             DebugLogger.LogWarning("ADTypeConverter", string.Concat("ParseDateTimeValue: Not supported syntax ", syntax.ToString()));
             throw new NotSupportedException();
         }
         else
         {
             int      num      = int.Parse(value.Substring(0, 2), NumberFormatInfo.InvariantInfo);
             int      num1     = int.Parse(value.Substring(2, 2), NumberFormatInfo.InvariantInfo);
             int      num2     = int.Parse(value.Substring(4, 2), NumberFormatInfo.InvariantInfo);
             int      num3     = int.Parse(value.Substring(6, 2), NumberFormatInfo.InvariantInfo);
             int      num4     = int.Parse(value.Substring(8, 2), NumberFormatInfo.InvariantInfo);
             int      num5     = int.Parse(value.Substring(10, 2), NumberFormatInfo.InvariantInfo);
             DateTime dateTime = new DateTime(num, num1, num2, num3, num4, num5, DateTimeKind.Utc);
             return(dateTime.ToLocalTime());
         }
     }
     else
     {
         int      num6      = int.Parse(value.Substring(0, 4), NumberFormatInfo.InvariantInfo);
         int      num7      = int.Parse(value.Substring(4, 2), NumberFormatInfo.InvariantInfo);
         int      num8      = int.Parse(value.Substring(6, 2), NumberFormatInfo.InvariantInfo);
         int      num9      = int.Parse(value.Substring(8, 2), NumberFormatInfo.InvariantInfo);
         int      num10     = int.Parse(value.Substring(10, 2), NumberFormatInfo.InvariantInfo);
         int      num11     = int.Parse(value.Substring(12, 2), NumberFormatInfo.InvariantInfo);
         DateTime dateTime1 = new DateTime(num6, num7, num8, num9, num10, num11, DateTimeKind.Utc);
         return(dateTime1.ToLocalTime());
     }
 }
Example #2
0
        private string FormatDateTimeValue(string propertyName, DateTime propertyValue)
        {
            object[]          objArray;
            ADAttributeSyntax propertyType      = this.GetPropertyType(propertyName, ADAttributeSyntax.GeneralizedTime);
            ADAttributeSyntax aDAttributeSyntax = propertyType;

            switch (aDAttributeSyntax)
            {
            case ADAttributeSyntax.Int64:
            {
                long fileTimeUtc = propertyValue.ToFileTimeUtc();
                return(fileTimeUtc.ToString());
            }

            case ADAttributeSyntax.Bool:
            case ADAttributeSyntax.Oid:
            {
                DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: DateTime value for ", propertyName, " of syntax ", propertyType.ToString()));
                objArray    = new object[1];
                objArray[0] = typeof(DateTime);
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
            }

            case ADAttributeSyntax.GeneralizedTime:
            {
                if (propertyValue.Year >= 0x3e8)
                {
                    propertyValue = propertyValue.ToUniversalTime();
                    return(propertyValue.ToString("yyyyMMddHHmmss.0Z"));
                }
                else
                {
                    int year = propertyValue.Year;
                    DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: Invalid year ", year.ToString(), " for ", propertyName));
                    throw new ArgumentOutOfRangeException(propertyName);
                }
            }

            case ADAttributeSyntax.UtcTime:
            {
                propertyValue = propertyValue.ToUniversalTime();
                return(propertyValue.ToString("yyMMddHHmmssZ"));
            }

            default:
            {
                DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: DateTime value for ", propertyName, " of syntax ", (object)propertyType.ToString()));
                objArray    = new object[1];
                objArray[0] = typeof(DateTime);
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
            }
            }
        }
Example #3
0
 public void AddRange(ADPropertyValueCollection value)
 {
     if (value != null)
     {
         base.InnerList.AddRange(value);
         return;
     }
     else
     {
         DebugLogger.LogWarning("ADPropertyValueCollection", "AddRange(ADPropertyValueCollection): null value");
         throw new ArgumentNullException("value");
     }
 }
Example #4
0
 public ADActiveObject(ADSessionInfo sessionInfo, ADObject obj)
 {
     this._sdFlags = SecurityMasks.Dacl;
     if (obj != null)
     {
         this._adSession = ADSession.ConstructSession(sessionInfo);
         this._adObject  = obj;
         return;
     }
     else
     {
         DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSessionInfo,ADObject) called with null obj");
         throw new ArgumentNullException("obj");
     }
 }
Example #5
0
 public void AddRange(object[] value)
 {
     if (value != null)
     {
         for (int i = 0; i < (int)value.Length; i++)
         {
             base.List.Add(value[i]);
         }
         return;
     }
     else
     {
         DebugLogger.LogWarning("ADPropertyValueCollection", "AddRange(object[]): null value");
         throw new ArgumentNullException("value");
     }
 }
 private void DictionaryAdd(string key, ADPropertyValueCollection value)
 {
     this.OnValidate(key, value);
     this.OnInsert(key, value);
     this.InnerDictionary.Add(key, value);
     try
     {
         this.OnInsertComplete(key, value);
     }
     catch
     {
         this.InnerDictionary.Remove(key);
         DebugLogger.LogWarning("ADPropertyCollection", string.Concat("Add: OnInsertComplete failed for key ", key, ". Value was ", value.ToString()));
         throw;
     }
 }
Example #7
0
 public void AddRange(ADPropertyValueCollection <T> value)
 {
     if (value != null)
     {
         int count = value.Count;
         for (int i = 0; i < count; i++)
         {
             base.List.Add(value[i]);
         }
         return;
     }
     else
     {
         DebugLogger.LogWarning("ADPropertyValueCollection<T>", "AddRange(ADPropertyValueCollection): null value");
         throw new ArgumentNullException("value");
     }
 }
Example #8
0
 public void Create()
 {
     this.Init();
     DebugLogger.WriteLine("ADActiveObject", string.Concat("Create called for ", this._adObject.DistinguishedName));
     if (this._adObject.ObjectClass != null)
     {
         DirectoryAttribute[] directoryAttributeArray = new DirectoryAttribute[this._adObject.NonNullCount - 1];
         int  num  = 0;
         bool flag = false;
         foreach (KeyValuePair <string, ADPropertyValueCollection> keyValuePair in this._adObject)
         {
             string key = keyValuePair.Key;
             if (flag || string.Compare(key, "distinguishedName", StringComparison.OrdinalIgnoreCase) != 0)
             {
                 DirectoryAttribute directoryAttribute = this.CreateDirectoryAttribute(key, keyValuePair.Value, null);
                 if (directoryAttribute == null)
                 {
                     continue;
                 }
                 directoryAttributeArray[num] = directoryAttribute;
                 num++;
             }
             else
             {
                 flag = true;
             }
         }
         ADAddRequest aDAddRequest = new ADAddRequest(this._adObject.DistinguishedName, directoryAttributeArray);
         if (this._sdFlags != SecurityMasks.None)
         {
             aDAddRequest.Controls.Add(new SecurityDescriptorFlagControl(this._sdFlags));
         }
         this._syncOps.Add(this._sessionHandle, aDAddRequest);
         DebugLogger.WriteLine("ADActiveObject", string.Concat("Create succeeded for ", this._adObject.DistinguishedName));
         return;
     }
     else
     {
         DebugLogger.LogWarning("ADActiveObject", "Create called with null objectClass");
         throw new ArgumentNullException("objectClass");
     }
 }
        private void DictionaryRemove(string key)
        {
            ADPropertyValueCollection aDPropertyValueCollection = null;

            if (this.InnerDictionary.TryGetValue(key, out aDPropertyValueCollection))
            {
                this.OnValidate(key, aDPropertyValueCollection);
                this.OnRemove(key, aDPropertyValueCollection);
                this.InnerDictionary.Remove(key);
                try
                {
                    this.OnRemoveComplete(key, aDPropertyValueCollection);
                }
                catch
                {
                    this.InnerDictionary.Add(key, aDPropertyValueCollection);
                    DebugLogger.LogWarning("ADPropertyCollection", string.Concat("Remove: OnRemoveComplete failed for key ", key));
                    throw;
                }
            }
        }
Example #10
0
 protected internal void BoxValue(object value)
 {
     if (value != null)
     {
         if (value as ADPropertyValueCollection <T> == null)
         {
             if (!(value is T))
             {
                 if (!(value is T[]))
                 {
                     DebugLogger.LogWarning("ADPropertyValueCollection<T>", string.Concat("BoxValue: invalid value type ", value.GetType().ToString()));
                     object[] type = new object[1];
                     type[0] = value.GetType();
                     throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, type), "value");
                 }
                 else
                 {
                     this.AddRange((T[])value);
                     return;
                 }
             }
             else
             {
                 base.List.Add(value);
                 return;
             }
         }
         else
         {
             this.AddRange((ADPropertyValueCollection <T>)value);
             return;
         }
     }
     else
     {
         return;
     }
 }
Example #11
0
 private ADActiveObject(ADSession session, ADObject obj)
 {
     this._sdFlags = SecurityMasks.Dacl;
     if (obj != null)
     {
         if (session != null)
         {
             this._adObject  = obj;
             this._adSession = session;
             return;
         }
         else
         {
             DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSession,ADObject) called with null session");
             throw new ArgumentNullException("session");
         }
     }
     else
     {
         DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSession,ADObject) called with null obj");
         throw new ArgumentNullException("obj");
     }
 }
Example #12
0
        public List <ADObject> PagedSearch(ref object pageCookie, out bool hasSizeLimitExceeded, int pageSize, int sizeLimit)
        {
            hasSizeLimitExceeded = false;
            Dictionary <string, ADObject> strs = null;
            HashSet <string> strs1             = null;
            HashSet <string> strs2             = null;
            int num = -2147483648;

            this.Init();
            if (this._searchRoot != null)
            {
                ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl(pageSize);
                if (pageCookie != null)
                {
                    aDPageResultRequestControl.Cookie = pageCookie;
                }
                ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
                aDSearchRequest.SizeLimit = sizeLimit;
                ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
                this.ProcessResponseControls(aDSearchResponse);
                if (aDSearchResponse.ResultCode == ResultCode.SizeLimitExceeded)
                {
                    hasSizeLimitExceeded = true;
                }
                List <ADObject> aDObjects = new List <ADObject>(aDSearchResponse.Entries.Count);
                if (this._autoRangeRetrieve)
                {
                    strs  = new Dictionary <string, ADObject>(StringComparer.OrdinalIgnoreCase);
                    strs1 = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    strs2 = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                }
                foreach (ADObject entry in aDSearchResponse.Entries)
                {
                    ADObject aDObject = this.CreateRichADObject(entry);
                    aDObjects.Add(aDObject);
                    if (!this._autoRangeRetrieve)
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(aDObject.DistinguishedName))
                    {
                        strs.Add(aDObject.DistinguishedName, aDObject);
                        ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject, aDObject, strs1, strs2, ref num);
                    }
                }
                while (this._autoRangeRetrieve && strs2.Count > 0 && strs1.Count > 0 && num != -2147483648)
                {
                    using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._adSession.SessionInfo))
                    {
                        IEnumerable <ADObject> aDObjects1 = ADObjectSearcher.FetchRemainingRangeRetrievalAttributeValues(aDObjectSearcher, this, strs1, strs2, num);
                        strs1.Clear();
                        strs2.Clear();
                        num = -2147483648;
                        foreach (ADObject aDObject1 in aDObjects1)
                        {
                            ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject1, strs[aDObject1.DistinguishedName], strs1, strs2, ref num);
                        }
                    }
                }
                pageCookie = null;
                DirectoryControl[] controls = aDSearchResponse.Controls;
                int num1 = 0;
                while (num1 < (int)controls.Length)
                {
                    if (controls[num1] as ADPageResultResponseControl == null)
                    {
                        num1++;
                    }
                    else
                    {
                        pageCookie = ((ADPageResultResponseControl)controls[num1]).Cookie;
                        break;
                    }
                }
                return(aDObjects);
            }
            else
            {
                DebugLogger.LogWarning("ADObjectSearcher", "PagedSearch: SearchRoot is null");
                throw new ArgumentNullException("SearchRoot");
            }
        }
 protected virtual void OnSet(object key, object oldValue, object newValue)
 {
     DebugLogger.LogWarning("ADPropertyCollection", "OnSet: not supported");
     throw new NotSupportedException();
 }
Example #14
0
        private string[] FormatDateTimeValue(string propertyName, IList valueList)
        {
            DateTime item;

            object[]          objArray;
            string[]          str               = null;
            ADAttributeSyntax propertyType      = this.GetPropertyType(propertyName, ADAttributeSyntax.GeneralizedTime);
            ADAttributeSyntax aDAttributeSyntax = propertyType;

            if (aDAttributeSyntax == ADAttributeSyntax.Int64)
            {
                str = new string[valueList.Count];
                for (int i = 0; i < valueList.Count; i++)
                {
                    item = (DateTime)valueList[i];
                    long fileTimeUtc = item.ToFileTimeUtc();
                    str[i] = fileTimeUtc.ToString();
                }
            }
            else if (aDAttributeSyntax == ADAttributeSyntax.Bool || aDAttributeSyntax == ADAttributeSyntax.Oid)
            {
                DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: DateTime value for ", propertyName, " of syntax ", (object)propertyType.ToString()));
                objArray    = new object[1];
                objArray[0] = typeof(DateTime);
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
            }
            else if (aDAttributeSyntax == ADAttributeSyntax.GeneralizedTime)
            {
                str = new string[valueList.Count];
                int num = 0;
                while (num < valueList.Count)
                {
                    item = (DateTime)valueList[num];
                    if (item.Year >= 0x3e8)
                    {
                        item     = item.ToUniversalTime();
                        str[num] = item.ToString("yyyyMMddHHmmss.0Z");
                        num++;
                    }
                    else
                    {
                        int year = item.Year;
                        DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: Invalid year ", year.ToString(), " for ", propertyName));
                        throw new ArgumentOutOfRangeException(propertyName, (object)item, StringResources.InvalidYear);
                    }
                }
            }
            else if (aDAttributeSyntax == ADAttributeSyntax.UtcTime)
            {
                str = new string[valueList.Count];
                for (int j = 0; j < valueList.Count; j++)
                {
                    item   = (DateTime)valueList[j];
                    item   = item.ToUniversalTime();
                    str[j] = item.ToString("yyMMddHHmmssZ");
                }
            }
            else
            {
                DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: DateTime value for ", propertyName, " of syntax ", (object)propertyType.ToString()));
                objArray    = new object[1];
                objArray[0] = typeof(DateTime);
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
            }
            return(str);

            DebugLogger.LogWarning("ADTypeConverter", string.Concat("FormatDateTimeValue: DateTime value for ", propertyName, " of syntax ", propertyType.ToString()));
            objArray    = new object[1];
            objArray[0] = typeof(DateTime);
            throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
        }
Example #15
0
        public object[] ConvertToRaw(string propertyName, IList valueList)
        {
            string[] item;
            byte[][] securityDescriptorBinaryForm;
            object[] objArray;
            string   str;

            if (valueList == null || valueList.Count == 0)
            {
                return(null);
            }
            else
            {
                Type     type     = valueList[0].GetType();
                TypeCode typeCode = Type.GetTypeCode(type);
                switch (typeCode)
                {
                case TypeCode.Object:
                {
                    if (type != typeof(byte[]))
                    {
                        if (type != typeof(Guid))
                        {
                            if (type != typeof(SecurityIdentifier))
                            {
                                if (type != typeof(ActiveDirectorySecurity))
                                {
                                    if (!typeof(X509Certificate).IsAssignableFrom(type))
                                    {
                                        DebugLogger.LogWarning("ADTypeConverter", string.Concat("ConvertToRaw: invalid value type ", type.ToString(), " for ", propertyName));
                                        object[] objArray1 = new object[1];
                                        objArray1[0] = type;
                                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray1), propertyName);
                                    }
                                    else
                                    {
                                        return(this.FormatCertificateValue(propertyName, valueList));
                                    }
                                }
                                else
                                {
                                    securityDescriptorBinaryForm = new byte[valueList.Count][];
                                    for (int i = 0; i < valueList.Count; i++)
                                    {
                                        securityDescriptorBinaryForm[i] = ((ActiveDirectorySecurity)valueList[i]).GetSecurityDescriptorBinaryForm();
                                    }
                                    return(securityDescriptorBinaryForm);
                                }
                            }
                            else
                            {
                                securityDescriptorBinaryForm = new byte[valueList.Count][];
                                for (int j = 0; j < valueList.Count; j++)
                                {
                                    SecurityIdentifier securityIdentifier = (SecurityIdentifier)valueList[j];
                                    byte[]             numArray           = new byte[securityIdentifier.BinaryLength];
                                    securityIdentifier.GetBinaryForm(numArray, 0);
                                    securityDescriptorBinaryForm[j] = numArray;
                                }
                                return(securityDescriptorBinaryForm);
                            }
                        }
                        else
                        {
                            return(this.FormatGuidValue(propertyName, valueList));
                        }
                    }
                    else
                    {
                        securityDescriptorBinaryForm = new byte[valueList.Count][];
                        for (int k = 0; k < valueList.Count; k++)
                        {
                            securityDescriptorBinaryForm[k] = (byte[])valueList[k];
                        }
                        return(securityDescriptorBinaryForm);
                    }
                }

                case TypeCode.DBNull:
                case TypeCode.Object | TypeCode.DateTime:
                {
                    DebugLogger.LogWarning("ADTypeConverter", string.Concat("ConvertToRaw: invalid value type ", type.ToString(), " for ", propertyName));
                    objArray    = new object[1];
                    objArray[0] = type;
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
                }

                case TypeCode.Boolean:
                {
                    item = new string[valueList.Count];
                    for (int l = 0; l < valueList.Count; l++)
                    {
                        if (!(bool)valueList[l])
                        {
                            item[l] = "FALSE";
                        }
                        else
                        {
                            item[l] = "TRUE";
                        }
                    }
                    return(item);
                }

                case TypeCode.Char:
                case TypeCode.SByte:
                case TypeCode.Byte:
                case TypeCode.Int16:
                case TypeCode.UInt16:
                case TypeCode.Int32:
                case TypeCode.UInt32:
                case TypeCode.Int64:
                case TypeCode.UInt64:
                case TypeCode.Single:
                case TypeCode.Double:
                case TypeCode.Decimal:
                {
                    item = new string[valueList.Count];
                    for (int m = 0; m < valueList.Count; m++)
                    {
                        IFormattable formattable = valueList[m] as IFormattable;
                        string[]     strArrays   = item;
                        int          num         = m;
                        if (formattable != null)
                        {
                            str = formattable.ToString(string.Empty, NumberFormatInfo.InvariantInfo);
                        }
                        else
                        {
                            str = valueList[m].ToString();
                        }
                        strArrays[num] = str;
                    }
                    return(item);
                }

                case TypeCode.DateTime:
                {
                    return(this.FormatDateTimeValue(propertyName, valueList));
                }

                case TypeCode.String:
                {
                    item = new string[valueList.Count];
                    for (int n = 0; n < valueList.Count; n++)
                    {
                        item[n] = (string)valueList[n];
                    }
                    return(item);
                }

                default:
                {
                    DebugLogger.LogWarning("ADTypeConverter", string.Concat("ConvertToRaw: invalid value type ", type.ToString(), " for ", propertyName));
                    objArray    = new object[1];
                    objArray[0] = type;
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
                }
                }
            }
        }
Example #16
0
        public object ConvertToRaw(string propertyName, object propertyValue)
        {
            object[] objArray;
            if (propertyValue != null)
            {
                Type     type     = propertyValue.GetType();
                TypeCode typeCode = Type.GetTypeCode(type);
                switch (typeCode)
                {
                case TypeCode.Object:
                {
                    if (type != typeof(byte[]))
                    {
                        if (type != typeof(Guid))
                        {
                            if (type != typeof(SecurityIdentifier))
                            {
                                if (type != typeof(ActiveDirectorySecurity))
                                {
                                    if (!typeof(X509Certificate).IsAssignableFrom(type))
                                    {
                                        DebugLogger.LogWarning("ADTypeConverter", string.Concat("ConvertToRaw: invalid value type ", type.ToString(), " for ", propertyName));
                                        object[] objArray1 = new object[1];
                                        objArray1[0] = type;
                                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray1), propertyName);
                                    }
                                    else
                                    {
                                        return(this.FormatCertificateValue(propertyName, (X509Certificate)propertyValue));
                                    }
                                }
                                else
                                {
                                    return(((ActiveDirectorySecurity)propertyValue).GetSecurityDescriptorBinaryForm());
                                }
                            }
                            else
                            {
                                SecurityIdentifier securityIdentifier = (SecurityIdentifier)propertyValue;
                                byte[]             numArray           = new byte[securityIdentifier.BinaryLength];
                                securityIdentifier.GetBinaryForm(numArray, 0);
                                return(numArray);
                            }
                        }
                        else
                        {
                            return(this.FormatGuidValue(propertyName, (Guid)propertyValue));
                        }
                    }
                    else
                    {
                        return(propertyValue);
                    }
                }

                case TypeCode.DBNull:
                case TypeCode.Single:
                case TypeCode.Double:
                case TypeCode.Decimal:
                case TypeCode.Object | TypeCode.DateTime:
                {
                    DebugLogger.LogWarning("ADTypeConverter", string.Concat("ConvertToRaw: invalid value type ", type.ToString(), " for ", propertyName));
                    objArray    = new object[1];
                    objArray[0] = type;
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
                }

                case TypeCode.Boolean:
                {
                    if (!(bool)propertyValue)
                    {
                        return("FALSE");
                    }
                    else
                    {
                        return("TRUE");
                    }
                }

                case TypeCode.Char:
                case TypeCode.SByte:
                case TypeCode.Byte:
                case TypeCode.Int16:
                case TypeCode.UInt16:
                case TypeCode.Int32:
                case TypeCode.UInt32:
                case TypeCode.Int64:
                case TypeCode.UInt64:
                {
                    IFormattable formattable = propertyValue as IFormattable;
                    if (formattable != null)
                    {
                        return(formattable.ToString(string.Empty, NumberFormatInfo.InvariantInfo));
                    }
                    else
                    {
                        return(propertyValue.ToString());
                    }
                }

                case TypeCode.DateTime:
                {
                    return(this.FormatDateTimeValue(propertyName, (DateTime)propertyValue));
                }

                case TypeCode.String:
                {
                    return(propertyValue);
                }

                default:
                {
                    DebugLogger.LogWarning("ADTypeConverter", string.Concat("ConvertToRaw: invalid value type ", type.ToString(), " for ", propertyName));
                    objArray    = new object[1];
                    objArray[0] = type;
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidType, objArray), propertyName);
                }
                }
            }
            else
            {
                return(null);
            }
        }