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); } }
internal static void InsertClaimTransformRule(ADParameterSet parameters, CmdletSessionInfo cmdletSessionInfo) { if (parameters.GetSwitchParameterBooleanValue("DenyAll")) { parameters["Rule"] = ADCBACUtil.CreateClaimTransformDenyRule(null); } if (!parameters.GetSwitchParameterBooleanValue("AllowAll")) { if (!parameters.Contains("AllowAllExcept") || parameters["AllowAllExcept"] == null) { if (parameters.Contains("DenyAllExcept") && parameters["DenyAllExcept"] != null) { string[] claimTypeName = ADCBACUtil.GetClaimTypeName((ADClaimType[])parameters["DenyAllExcept"], cmdletSessionInfo, "DenyAllExcept"); parameters["Rule"] = ADCBACUtil.CreateClaimTransformDenyRule(claimTypeName); } return; } else { string[] strArrays = ADCBACUtil.GetClaimTypeName((ADClaimType[])parameters["AllowAllExcept"], cmdletSessionInfo, "AllowAllExcept"); parameters["Rule"] = ADCBACUtil.CreateClaimTransformAllowRule(strArrays); return; } } else { parameters["Rule"] = ADCBACUtil.CreateClaimTransformAllowRule(null); return; } }
private bool ADResourcePropertyPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj) { if (operation == ADFactory <T> .DirectoryOperation.Create || ADFactory <T> .DirectoryOperation.Update == operation) { bool flag = true; ADObject aDObject = null; StringBuilder stringBuilder = new StringBuilder(); flag = flag & ADResourcePropertyFactory <T> .VerifyResourcePropertyValueType(directoryObj, base.CmdletSessionInfo, out aDObject, stringBuilder); if (aDObject != null && aDObject.Contains("ValueType")) { ADClaimValueType?value = (ADClaimValueType?)(aDObject["ValueType"].Value as ADClaimValueType?); flag = flag & ADCBACUtil.VerifyAndSetPossibleValues(directoryObj, value.Value, stringBuilder); } flag = flag & ADResourcePropertyFactory <T> .VerifySharesPossibleValueWithAndPossibleValueExclusiveness(directoryObj, operation, stringBuilder); flag = flag & ADResourcePropertyFactory <T> .VerifyIsSuggestedValuePresentAttribute(directoryObj, stringBuilder, aDObject); flag = flag & ADResourcePropertyFactory <T> .VerifySharesValuesWith(directoryObj, stringBuilder, aDObject, base.CmdletSessionInfo); if (flag) { return(false); } else { stringBuilder.AppendLine(StringResources.CTParameterValidationFailure); throw new ADException(stringBuilder.ToString()); } } else { return(false); } }
internal override string GenerateObjectName(ADParameterSet parameters) { if (parameters.Contains("ID")) { ADCBACUtil.ValidateClaimID(parameters["ID"] as string); return(parameters["ID"] as string); } else { return(ADCBACUtil.GenerateClaimID(parameters["DisplayName"] as string)); } }
private bool NewADResourcePropertyCmdletValidationCSRoutine() { if (string.IsNullOrEmpty(this._cmdletParameters.DisplayName) || !ADCBACUtil.IsAttributeValueUsed <ADResourcePropertyFactory <ADResourceProperty>, ADResourceProperty>("displayName", this._cmdletParameters.DisplayName, this.GetCmdletSessionInfo(), this.GetDefaultCreationPathBase())) { return(true); } else { object[] displayName = new object[1]; displayName[0] = this._cmdletParameters.DisplayName; base.WriteError(new ErrorRecord(new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.DisplayNameNotUniqueError, displayName)), "NewADResourceProperty:NewADResourcePropertyCmdletValidationCSRoutine", ErrorCategory.InvalidData, null)); return(false); } }
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 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 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); }
private bool SetADClaimTransformPolicyBeginCSRoutine() { ADCBACUtil.InsertClaimTransformRule(this._cmdletParameters, this.GetCmdletSessionInfo()); return(true); }
internal static List <ADSuggestedValueEntry> ConvertSuggestedValueXmlToSuggestedValueEntryList(string suggestedValuesXmlBlob, out bool hasUnknownElements) { ADCBACUtil.VerifyADSuggestedValuesXml(suggestedValuesXmlBlob); List <ADSuggestedValueEntry> aDSuggestedValueEntries = new List <ADSuggestedValueEntry>(); hasUnknownElements = false; XmlSerializer xmlSerializer = new XmlSerializer(typeof(PossibleClaimValuesType)); PossibleClaimValuesType possibleClaimValuesType = (PossibleClaimValuesType)xmlSerializer.Deserialize(new StringReader(suggestedValuesXmlBlob)); if (possibleClaimValuesType.Item as StringListType == null) { if (possibleClaimValuesType.Item as IntegerListType == null) { if (possibleClaimValuesType.Item as UnsignedIntegerListType == null) { hasUnknownElements = true; } else { UnsignedIntegerListType item = (UnsignedIntegerListType)possibleClaimValuesType.Item; UnsignedIntegerItemType[] unsignedIntegerItemTypeArray = item.Item; for (int i = 0; i < (int)unsignedIntegerItemTypeArray.Length; i++) { UnsignedIntegerItemType unsignedIntegerItemType = unsignedIntegerItemTypeArray[i]; ADSuggestedValueEntry aDSuggestedValueEntry = new ADSuggestedValueEntry((object)unsignedIntegerItemType.Value, unsignedIntegerItemType.ValueDisplayName, unsignedIntegerItemType.ValueDescription, unsignedIntegerItemType.ValueGUID); aDSuggestedValueEntries.Add(aDSuggestedValueEntry); if (unsignedIntegerItemType.Any != null) { hasUnknownElements = true; } } } } else { IntegerListType integerListType = (IntegerListType)possibleClaimValuesType.Item; IntegerItemType[] integerItemTypeArray = integerListType.Item; for (int j = 0; j < (int)integerItemTypeArray.Length; j++) { IntegerItemType integerItemType = integerItemTypeArray[j]; ADSuggestedValueEntry aDSuggestedValueEntry1 = new ADSuggestedValueEntry((object)integerItemType.Value, integerItemType.ValueDisplayName, integerItemType.ValueDescription, integerItemType.ValueGUID); aDSuggestedValueEntries.Add(aDSuggestedValueEntry1); if (integerItemType.Any != null) { hasUnknownElements = true; } } } } else { StringListType stringListType = (StringListType)possibleClaimValuesType.Item; StringItemType[] stringItemTypeArray = stringListType.Item; for (int k = 0; k < (int)stringItemTypeArray.Length; k++) { StringItemType stringItemType = stringItemTypeArray[k]; ADSuggestedValueEntry aDSuggestedValueEntry2 = new ADSuggestedValueEntry(stringItemType.Value, stringItemType.ValueDisplayName, stringItemType.ValueDescription, stringItemType.ValueGUID); aDSuggestedValueEntries.Add(aDSuggestedValueEntry2); if (stringItemType.Any != null) { hasUnknownElements = true; } } } return(aDSuggestedValueEntries); }