internal static void ToExtendedAttributeMetadataValue(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { string value = directoryObj["sourceXmlAttribute"].Value as string; if (!string.Equals("msDS-ReplAttributeMetaData", value, StringComparison.OrdinalIgnoreCase)) { if (string.Equals("msDS-ReplValueMetaData", value, StringComparison.OrdinalIgnoreCase)) { AttributeConverters.ToExtendedObject(extendedAttribute, directoryAttributes, userObj, directoryObj, cmdletSessionInfo); } return; } else { string str = directoryObj["pszAttributeName"].Value as string; if (string.IsNullOrEmpty(str)) { userObj.SetValue(extendedAttribute, null); return; } else { userObj.SetValue(extendedAttribute, directoryObj[str]); return; } } }
internal static void ToDirectoryPasswordProperties(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains("pwdProperties")) { throw new NotSupportedException(); } else { int value = (int)directoryObj["pwdProperties"].Value; bool item = (bool)extendedData[0]; int bit = PasswordPropertiesUtil.StringToBit(extendedAttribute); if (PasswordPropertiesUtil.IsInverseBit(bit)) { item = !item; } if (!item) { value = value & ~bit; } else { value = value | bit; } directoryObj.SetValue("pwdProperties", value); return; } }
internal static void ToExtendedTransportTypeFromDrsOptions(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { bool hasValue; bool flag; AttributeConverters.ToExtendedFlagFromInt(128, false, extendedAttribute, directoryAttributes, userObj, directoryObj, cmdletSessionInfo); bool?value = (bool?)(userObj[extendedAttribute].Value as bool?); bool?nullable = value; if (!nullable.GetValueOrDefault()) { hasValue = false; } else { hasValue = nullable.HasValue; } if (!hasValue) { bool?nullable1 = value; if (nullable1.GetValueOrDefault()) { flag = false; } else { flag = nullable1.HasValue; } if (flag) { userObj.SetValue(extendedAttribute, ADInterSiteTransportProtocolType.IP); } return; } else { userObj.SetValue(extendedAttribute, ADInterSiteTransportProtocolType.SMTP); return; } }
public static void ToDirectoryAccountExpirationDate(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData.Count != 0 && extendedData[0] != null) { DateTime item = (DateTime)extendedData[0]; if (item.Ticks != 0x89f7ff5f7b58000L) { AttributeConverters.ToDirectoryDateTime(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); return; } } directoryObj.SetValue(directoryAttributes[0], 0x7fffffffffffffffL); }
internal static void ToDirectoryResouceConditionFromString(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { directoryObj.ForceRemove(directoryAttributes[0]); return; } else { object[] value = new object[1]; value[0] = extendedData.Value as string; string str = string.Format(CultureInfo.InvariantCulture, "D:(XA;;GA;;;S-1-1-0;({0}))", value); int num = AttributeConverters.ValidateSDDLString(str, cmdletSessionInfo); if (num != 0) { object[] objArray = new object[1]; objArray[0] = extendedData.Value as string; Win32Exception win32Exception = new Win32Exception(num, string.Format(CultureInfo.CurrentCulture, StringResources.ResouceConditionValidationFailed, objArray)); cmdletSessionInfo.CmdletBase.ThrowTerminatingError(new ErrorRecord(win32Exception, num.ToString(CultureInfo.InvariantCulture), ErrorCategory.InvalidArgument, directoryObj)); } directoryObj.SetValue(directoryAttributes[0], extendedData.Value); return; } }
internal virtual IEnumerable <ADEntity> GetADEntityFromXmlAttribute(ADEntity sourceEntity, string xmlAttributeName, string xmlAttributeObjectTypeName) { IEnumerable <ADEntity> aDEntities; List <ADEntity> aDEntities1 = new List <ADEntity>(); if (sourceEntity[xmlAttributeName] != null) { IEnumerator enumerator = sourceEntity[xmlAttributeName].GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; XmlDocument xmlDocument = new XmlDocument(); ADEntity aDEntity = new ADEntity(); string str = current as string; aDEntity.SessionInfo = sourceEntity.SessionInfo; if (str == null) { continue; } try { xmlDocument.LoadXml(this.RemoveInvalidXmlChars(str)); } catch (XmlException xmlException) { aDEntities = aDEntities1; return(aDEntities); } if (xmlDocument.ChildNodes.Count == 1) { if (xmlDocument.FirstChild.Name.Equals(xmlAttributeObjectTypeName, StringComparison.OrdinalIgnoreCase)) { IEnumerator enumerator1 = sourceEntity.PropertyNames.GetEnumerator(); try { while (enumerator1.MoveNext()) { string current1 = (string)enumerator1.Current; aDEntity.SetValue(current1, sourceEntity[current1]); } } finally { IDisposable disposable = enumerator1 as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (!aDEntity.Contains("sourceXmlAttribute")) { aDEntity.SetValue("sourceXmlAttribute", xmlAttributeName); } IEnumerator enumerator2 = xmlDocument.FirstChild.ChildNodes.GetEnumerator(); try { while (enumerator2.MoveNext()) { XmlNode xmlNodes = (XmlNode)enumerator2.Current; if (string.IsNullOrEmpty(xmlNodes.InnerText)) { continue; } aDEntity.SetValue(xmlNodes.Name, xmlNodes.InnerText); } } finally { IDisposable disposable1 = enumerator2 as IDisposable; if (disposable1 != null) { disposable1.Dispose(); } } aDEntities1.Add(aDEntity); } else { aDEntities = aDEntities1; return(aDEntities); } } else { aDEntities = aDEntities1; return(aDEntities); } } return(aDEntities1); } finally { IDisposable disposable2 = enumerator as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } return(aDEntities); } else { return(aDEntities1); } }