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; } }
private bool ADClaimTypePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj) { bool classes = true; StringBuilder stringBuilder = new StringBuilder(); if (operation == ADFactory <T> .DirectoryOperation.Create || ADFactory <T> .DirectoryOperation.Update == operation) { bool switchParameterBooleanValue = parameters.GetSwitchParameterBooleanValue("SourceTransformPolicy"); if (switchParameterBooleanValue) { directoryObj.SetValue("msDS-ClaimSourceType", "TransformPolicy"); directoryObj.ForceRemove("msDS-ClaimAttributeSource"); directoryObj.ForceRemove("msDS-ClaimSource"); } classes = classes & ADClaimTypeFactory <T> .VerifyClaimSourceAndAttributeExclusiveness(directoryObj, stringBuilder, operation); classes = classes & ADClaimTypeFactory <T> .VerifyClaimSourceAndPossibleValueExclusiveness(directoryObj, stringBuilder); classes = classes & ADClaimTypeFactory <T> .SetAndValidateClaimSourceType(directoryObj, stringBuilder); classes = classes & ADClaimTypeFactory <T> .VerifyRestrictValues(directoryObj, stringBuilder, base.CmdletSessionInfo, operation); if (directoryObj.Contains("msDS-ClaimValueType")) { ADClaimValueType num = (ADClaimValueType)((long)Convert.ToInt32(directoryObj["msDS-ClaimValueType"].Value, CultureInfo.InvariantCulture)); classes = classes & ADCBACUtil.VerifyAndSetPossibleValues(directoryObj, num, stringBuilder); } classes = classes & ADClaimTypeFactory <T> .VerifyAppliesToClasses(directoryObj, stringBuilder, base.CmdletSessionInfo); if (classes) { return(false); } else { stringBuilder.AppendLine(StringResources.CTParameterValidationFailure); throw new ADException(stringBuilder.ToString()); } } else { return(false); } }
internal static bool VerifyAndSetPossibleValues(ADObject directoryObj, ADClaimValueType valueType, StringBuilder errorBuffer) { bool flag = false; if (directoryObj.InternalProperties.Contains("SuggestedValues") && directoryObj.InternalProperties["SuggestedValues"].Value != null) { if (directoryObj.Contains("msDS-ClaimPossibleValues") && directoryObj["msDS-ClaimPossibleValues"].Value != null) { bool flag1 = false; try { ADCBACUtil.ConvertSuggestedValueXmlToSuggestedValueEntryList(directoryObj["msDS-ClaimPossibleValues"].Value as string, out flag1); if (flag1) { flag = true; object[] value = new object[2]; value[0] = directoryObj["name"].Value as string; value[1] = "msDS-ClaimPossibleValues"; errorBuffer.AppendLine(string.Format(CultureInfo.CurrentCulture, StringResources.CannotOverwriteNextVersionXml, value)); } } catch (Exception exception1) { Exception exception = exception1; if (exception as XmlException == null && exception as XmlSchemaException == null && exception as InvalidOperationException == null) { throw; } } } if (!flag) { ADSuggestedValueEntry[] valueList = directoryObj.InternalProperties["SuggestedValues"].ValueList as ADSuggestedValueEntry[]; ADCBACUtil.AddSuggestedValueXmlFromADSuggestedValueEntryList(valueList, directoryObj, valueType); } } return(!flag); }
internal static ADSuggestedValueType GetsuggestedValueTypeFromClaimType(ADClaimValueType claimValaueType) { ADSuggestedValueType aDSuggestedValueType = ADSuggestedValueType.Invalid; ADClaimValueType aDClaimValueType = claimValaueType; if (aDClaimValueType <= ADClaimValueType.SID) { if (aDClaimValueType >= ADClaimValueType.Int64) { if ((int)(aDClaimValueType - ADClaimValueType.Int64) == 0) { aDSuggestedValueType = ADSuggestedValueType.Int64; return(aDSuggestedValueType); } else if ((int)(aDClaimValueType - ADClaimValueType.Int64) == 1) { aDSuggestedValueType = ADSuggestedValueType.UInt64; return(aDSuggestedValueType); } else if ((int)(aDClaimValueType - ADClaimValueType.Int64) == 2 || (int)(aDClaimValueType - ADClaimValueType.Int64) == 3 || (int)(aDClaimValueType - ADClaimValueType.Int64) == 4) { aDSuggestedValueType = ADSuggestedValueType.String; return(aDSuggestedValueType); } } else { return(aDSuggestedValueType); } } if (aDClaimValueType != ADClaimValueType.OctetString) { return(aDSuggestedValueType); } aDSuggestedValueType = ADSuggestedValueType.String; return(aDSuggestedValueType); }
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); } } }
internal static void AddSuggestedValueXmlFromADSuggestedValueEntryList(ADSuggestedValueEntry[] claimValues, ADEntity directoryObj, ADClaimValueType valueType) { if (valueType != ADClaimValueType.Invalid) { HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); ADSuggestedValueEntry[] aDSuggestedValueEntryArray = claimValues; int num = 0; while (num < (int)aDSuggestedValueEntryArray.Length) { ADSuggestedValueEntry aDSuggestedValueEntry = aDSuggestedValueEntryArray[num]; if (!strs.Contains(aDSuggestedValueEntry.Value.ToString())) { strs.Add(aDSuggestedValueEntry.Value.ToString()); num++; } else { object[] str = new object[1]; str[0] = aDSuggestedValueEntry.Value.ToString(); throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.SuggestedValueNotUniqueError, str)); } } string suggestedValueXmlFromSuggestedValueEntryList = ADCBACUtil.GetSuggestedValueXmlFromSuggestedValueEntryList(claimValues, ADCBACUtil.GetsuggestedValueTypeFromClaimType(valueType)); directoryObj["msDS-ClaimPossibleValues"].Value = suggestedValueXmlFromSuggestedValueEntryList; return; } else { throw new ADException(StringResources.InvalidValueTypeForPossibleValueXml); } }