internal static void ToCompatibleResourceTypes(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains("msDS-ClaimValueType") || !directoryObj.Contains("msDS-ClaimIsValueSpaceRestricted")) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(null); userObj.Add(extendedAttribute, aDPropertyValueCollection); return; } else { long value = (long)directoryObj["msDS-ClaimValueType"].Value; bool flag = directoryObj.Contains("msDS-ClaimPossibleValues"); IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-ClaimValueType", value); IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-IsPossibleValuesPresent", flag); IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = aDOPathNode; aDOPathNodeArray[1] = aDOPathNode1; IADOPathNode aDOPathNode2 = ADOPathUtil.CreateAndClause(aDOPathNodeArray); ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType> aDResourcePropertyValueTypeFactory = new ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType>(); aDResourcePropertyValueTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo); string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Value Types,CN=Claims Configuration,CN=Services,", ADPathFormat.X500); int? nullable = null; int? nullable1 = null; IEnumerable <ADResourcePropertyValueType> extendedObjectFromFilter = aDResourcePropertyValueTypeFactory.GetExtendedObjectFromFilter(aDOPathNode2, str, ADSearchScope.OneLevel, null, nullable, nullable1, false); List <string> strs = new List <string>(); foreach (ADResourcePropertyValueType aDResourcePropertyValueType in extendedObjectFromFilter) { strs.Add(aDResourcePropertyValueType.Name); } userObj.Add(extendedAttribute, new ADPropertyValueCollection(strs)); 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; } }
public static void ToDirectoryGroupScope(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { ADGroupScope aDGroupScope = ADGroupScope.DomainLocal; if (extendedData != null) { if (extendedData.Value != null) { ADGroupScope value = (ADGroupScope)extendedData.Value; int directoryGroupTypeValue = GroupTypeUtils.GetDirectoryGroupTypeValue(value); if (!directoryObj.Contains(directoryAttributes[0])) { directoryObj.Add(directoryAttributes[0], directoryGroupTypeValue); } else { int num = (int)directoryObj[directoryAttributes[0]].Value; if (GroupTypeUtils.TryGetExtendedGroupScopeValue(num, out aDGroupScope)) { int directoryGroupTypeValue1 = GroupTypeUtils.GetDirectoryGroupTypeValue(aDGroupScope); num = num & ~directoryGroupTypeValue1; } directoryObj[directoryAttributes[0]].Value = num + directoryGroupTypeValue; return; } } else { return; } } }
public static void ToExtendedGroupScope(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection(null)); } else { int value = (int)directoryObj[directoryAttributes[0]].Value; if ((value & 4) != 4) { if ((value & 2) != 2) { if ((value & 8) == 8) { userObj.Add(extendedAttribute, ADGroupScope.Universal); return; } } else { userObj.Add(extendedAttribute, ADGroupScope.Global); return; } } else { userObj.Add(extendedAttribute, ADGroupScope.DomainLocal); return; } } }
internal static void ToExtendedFromIntToValueTypeEnum(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (directoryObj.Contains(directoryAttributes[0])) { ADClaimValueType aDClaimValueType = ADClaimValueType.Invalid; long value = (long)directoryObj[directoryAttributes[0]].Value; if (!Enum.IsDefined(typeof(ADClaimValueType), value)) { object[] objArray = new object[2]; objArray[0] = directoryObj["distinguishedName"].Value; objArray[1] = value; cmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidClaimValueType, objArray)); } else { aDClaimValueType = (ADClaimValueType)value; } userObj.Add(extendedAttribute, new ADPropertyValueCollection((object)aDClaimValueType)); return; } else { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(null); userObj.Add(extendedAttribute, aDPropertyValueCollection); return; } }
internal static void ToPolicyRuleStringFromRuleXml(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection()); } else { try { string str = ADClaimTransformPolicyFactory <T> .ParseRules(directoryObj[directoryAttributes[0]].Value as string); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(str); userObj.Add(extendedAttribute, aDPropertyValueCollection); } catch (Exception exception1) { Exception exception = exception1; if (exception as ADException != null || exception as XmlException != null) { object[] value = new object[3]; value[0] = directoryObj["distinguishedName"].Value; value[1] = exception.Message; value[2] = directoryObj[directoryAttributes[0]].Value; cmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(string.Format(CultureInfo.CurrentCulture, StringResources.ClaimPolicyXmlWarning, value)); userObj.Add(extendedAttribute, new ADPropertyValueCollection()); } else { throw exception; } } } }
internal static void MergeADObjectProperties(ADEntity parentObj, ADEntity childObj) { parentObj.TrackChanges = false; foreach (string propertyName in childObj.PropertyNames) { if (parentObj.Contains(propertyName)) { continue; } parentObj.Add(propertyName, childObj[propertyName].Value); } parentObj.TrackChanges = true; }
internal static void ToExtendedIPv6(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection()); return; } else { string value = directoryObj[directoryAttributes[0]].Value as string; userObj.Add(extendedAttribute, IPUtil.GetIPAddress(value, IPUtil.IPVersion.IPv6)); return; } }
internal static void ToExtendedGPLink(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection()); return; } else { string value = directoryObj[directoryAttributes[0]].Value as string; userObj.Add(extendedAttribute, GPLinkUtil.ConvertLinkedGroupPolicyObjects(value)); return; } }
internal override T Construct(ADEntity directoryObj, AttributeSetRequest requestedAttributes) { T t = base.Construct(directoryObj, requestedAttributes); string[] internalLdapAttributes = DirectoryAttrConstants.InternalLdapAttributes; for (int i = 0; i < (int)internalLdapAttributes.Length; i++) { string str = internalLdapAttributes[i]; if (!t.InternalProperties.Contains(str) && directoryObj.Contains(str) && directoryObj[str] != null) { t.InternalProperties.SetValue(str, directoryObj[str]); } } return(t); }
internal static void ToExtendedADSuggestedValueEntryListFromXml(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(null); userObj.Add(extendedAttribute, aDPropertyValueCollection); } else { string value = (string)directoryObj[directoryAttributes[0]].Value; try { bool flag = false; List <ADSuggestedValueEntry> suggestedValueEntryList = ADCBACUtil.ConvertSuggestedValueXmlToSuggestedValueEntryList(value, out flag); ADPropertyValueCollection aDPropertyValueCollection1 = new ADPropertyValueCollection(suggestedValueEntryList.ToArray()); userObj.Add(extendedAttribute, aDPropertyValueCollection1); if (flag) { object[] objArray = new object[2]; objArray[0] = directoryObj["name"].Value; objArray[1] = "msDS-ClaimPossibleValues"; cmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(string.Format(CultureInfo.CurrentCulture, StringResources.NextVersionPossibleValuesXml, objArray)); } } catch (Exception exception1) { Exception exception = exception1; if (exception as XmlException != null || exception as XmlSchemaException != null || exception as InvalidOperationException != null) { object[] value1 = new object[1]; value1[0] = directoryObj["distinguishedName"].Value; cmdletSessionInfo.CmdletMessageWriter.WriteWarningBuffered(string.Format(CultureInfo.CurrentCulture, StringResources.InvalidPossibleValuesXml, value1)); ADPropertyValueCollection aDPropertyValueCollection2 = new ADPropertyValueCollection(null); userObj.Add(extendedAttribute, aDPropertyValueCollection2); } else { throw; } } } }
internal static void ToExtendedFromTransportTypeToISTPEnum(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0]) || directoryObj[directoryAttributes[0]].Value == null) { userObj.Add(extendedAttribute, new ADPropertyValueCollection()); return; } else { string value = (string)directoryObj[directoryAttributes[0]].Value; string childName = ADPathModule.GetChildName(value, ADPathFormat.X500); ADInterSiteTransportProtocolType aDInterSiteTransportProtocolType = ADInterSiteTransportProtocolType.IP; if (string.Compare("CN=IP", childName, StringComparison.OrdinalIgnoreCase) != 0) { aDInterSiteTransportProtocolType = ADInterSiteTransportProtocolType.SMTP; } ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection((object)aDInterSiteTransportProtocolType); userObj.Add(extendedAttribute, aDPropertyValueCollection); return; } }
private static bool VerifyResourcePropertyValueType(ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo, out ADObject resourcePropertyValueTypeObj, StringBuilder errorBuffer) { bool flag = false; resourcePropertyValueTypeObj = null; if (directoryObj.Contains("msDS-ValueTypeReference")) { string value = directoryObj["msDS-ValueTypeReference"].Value as string; ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType> aDResourcePropertyValueTypeFactory = new ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType>(); aDResourcePropertyValueTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADResourcePropertyValueType aDResourcePropertyValueType = new ADResourcePropertyValueType(); aDResourcePropertyValueType.Identity = value; string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Value Types,CN=Claims Configuration,CN=Services,", ADPathFormat.X500); resourcePropertyValueTypeObj = aDResourcePropertyValueTypeFactory.GetExtendedObjectFromIdentity(aDResourcePropertyValueType, str); } else { flag = true; errorBuffer.AppendLine(StringResources.RCTNoResourcePropertyValueTypeError); } return(!flag); }
public static void ToExtendedGroupCategory(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (!directoryObj.Contains(directoryAttributes[0])) { userObj.Add(extendedAttribute, new ADPropertyValueCollection(null)); return; } else { int value = (int)directoryObj[directoryAttributes[0]].Value; if ((value & -2147483648) != -2147483648) { userObj.Add(extendedAttribute, ADGroupCategory.Distribution); return; } else { userObj.Add(extendedAttribute, ADGroupCategory.Security); return; } } }
internal static void ToExtendedPasswordProperties(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { bool flag; if (directoryObj.Contains(directoryAttributes[0])) { int value = (int)directoryObj[directoryAttributes[0]].Value; int bit = PasswordPropertiesUtil.StringToBit(extendedAttribute); if (!PasswordPropertiesUtil.IsInverseBit(bit)) { flag = (value & bit) != 0; } else { flag = (value & bit) == 0; } userObj.Add(extendedAttribute, flag); return; } else { 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); } }
internal static void ToDirectoryFromSourceAttributeToDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { directoryObj.ForceRemove(directoryAttributes[0]); return; } else { ADSchemaObjectFactory <ADSchemaObject> aDSchemaObjectFactory = new ADSchemaObjectFactory <ADSchemaObject>(); aDSchemaObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADSchemaObject aDSchemaObject = new ADSchemaObject(); aDSchemaObject.Identity = extendedData.Value; ADObject extendedObjectFromIdentity = aDSchemaObjectFactory.GetExtendedObjectFromIdentity(aDSchemaObject, cmdletSessionInfo.ADRootDSE.SchemaNamingContext, ADClaimTypeFactory <T> .SchemaAttributeProperties); if (extendedObjectFromIdentity != null) { if (!extendedObjectFromIdentity.Contains("lDAPDisplayName") || !extendedObjectFromIdentity.Contains("attributeSyntax")) { object[] value = new object[1]; value[0] = extendedData.Value; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.SPCTInvalidSourceAttribute, value)); } else { string str = (string)extendedObjectFromIdentity["lDAPDisplayName"].Value; string value1 = (string)extendedObjectFromIdentity["attributeSyntax"].Value; HashSet <string> strs = new HashSet <string>(ADClaimTypeFactory <T> .BlockedAttributes, StringComparer.OrdinalIgnoreCase); if (!strs.Contains(str)) { if (!extendedObjectFromIdentity.Contains("systemFlags") || ((int)extendedObjectFromIdentity["systemFlags"].Value & ADClaimTypeFactory <T> .FLAG_ATTR_NOT_REPLICATED) == 0) { if (!extendedObjectFromIdentity.Contains("searchFlags") || ((int)extendedObjectFromIdentity["searchFlags"].Value & ADClaimTypeFactory <T> .RODCFilteredAttribute) == 0) { if (!extendedObjectFromIdentity.Contains("isDefunct") || !(bool)extendedObjectFromIdentity["isDefunct"].Value) { ADClaimValueType aDClaimValueType = ADClaimValueType.Invalid; HashSet <string> strs1 = new HashSet <string>(ADClaimTypeFactory <T> .ValidAttributeSyntaxInt, StringComparer.OrdinalIgnoreCase); HashSet <string> strs2 = new HashSet <string>(ADClaimTypeFactory <T> .ValidAttributeSyntaxString, StringComparer.OrdinalIgnoreCase); if (!strs2.Contains(value1)) { if (!strs1.Contains(value1)) { if (string.Compare(value1, ADClaimTypeFactory <T> .ValidAttributeSyntaxUInt, true, CultureInfo.InvariantCulture) != 0) { if (string.Compare(value1, ADClaimTypeFactory <T> .ValidBooleanAttributeSyntax, true, CultureInfo.InvariantCulture) != 0) { throw new ADException(StringResources.SPCTInvalidAttributeSyntax); } else { aDClaimValueType = ADClaimValueType.Boolean; } } else { aDClaimValueType = ADClaimValueType.UInt64; } } else { aDClaimValueType = ADClaimValueType.Int64; } } else { aDClaimValueType = ADClaimValueType.String; } directoryObj[directoryAttributes[0]].Value = extendedObjectFromIdentity.DistinguishedName; if (!directoryObj.Contains("msDS-ClaimValueType")) { directoryObj.Add("msDS-ClaimValueType", (long)aDClaimValueType); } else { long?nullable = (long?)(directoryObj["msDS-ClaimValueType"].Value as long?); if ((ADClaimValueType)nullable.Value != aDClaimValueType) { throw new ADException(StringResources.CTSourceAttributeValueTypeError); } } directoryObj.InternalProperties[directoryAttributes[0]].Value = str; return; } else { throw new ADException(StringResources.SPCTDefuctSourceAttr); } } else { throw new ADException(StringResources.SPCTRODCFilteredSourceAttr); } } else { throw new ADException(StringResources.SPCTNonREPLSourceAttrError); } } else { throw new ADException(StringResources.SPCTBlockedSourceAttribute); } } } else { throw new ADException(StringResources.SPCTInvalidSourceAttributeName); } } }