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 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 ToExtendedSourceNameFromDN(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { string value = (string)directoryObj[directoryAttributes[0]].Value; value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500); value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500); ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(value); userObj.Add(extendedAttribute, aDPropertyValueCollection); }
internal static bool IsNamingContext(ADEntity directoryObj) { ADPropertyValueCollection item = directoryObj["instanceType"]; int ret = directoryObj["instanceType"].Value is int?(int)directoryObj["instanceType"].Value : 1; if (directoryObj["instanceType"].Value == null || ret == 0) { return(false); } else { return(Utils.HasFlagsSet((int)item.Value, 1)); } }
internal static void ToExtendedFeatureScope(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); int value = (int)directoryObj[directoryAttributes[0]].Value; foreach (ADOptionalFeatureScope aDOptionalFeatureScope in Enum.GetValues(typeof(ADOptionalFeatureScope))) { if ((aDOptionalFeatureScope & (ADOptionalFeatureScope)value) <= ADOptionalFeatureScope.Unknown) { continue; } aDPropertyValueCollection.Add(aDOptionalFeatureScope); } userObj.Add(extendedAttribute, aDPropertyValueCollection); }
internal static void ToExtendedFromDNToISTPEnum(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { string value = (string)directoryObj[directoryAttributes[0]].Value; value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500); 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); }
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; } } } }
public ADPropertyValueCollection ConvertToADPropertyValueCollection(string parameterName) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); aDPropertyValueCollection.TrackChanges = true; T[] tArray = this._array; for (int i = 0; i < (int)tArray.Length; i++) { T t = tArray[i]; if (t != null) { aDPropertyValueCollection.Add(t); } else { aDPropertyValueCollection.Value = null; } } return(aDPropertyValueCollection); }
private static ADPropertyValueCollection ConvertLinkedGroupPolicyObjects(string rawGPLink) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); if (rawGPLink != null && rawGPLink.Length > 0) { string[] strArrays = rawGPLink.Split(GPLinkUtil.GpLinkSplitChars, StringSplitOptions.RemoveEmptyEntries); if (strArrays != null && (int)strArrays.Length > 0) { string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { string str = strArrays1[i]; Match match = GPLinkUtil.GpLinkRegEx.Match(str); if (match.Success) { aDPropertyValueCollection.Add(match.Groups[GPLinkUtil.GpLinkRegExDNGroup].Value); } } } } return(aDPropertyValueCollection); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) { string returnString = string.Empty; ADPropertyValueCollection collection = (ADPropertyValueCollection)value; if (collection.Count > 0) { for (int i = 0; i < collection.Count; i++) { returnString = returnString + collection[i].ToString() + ";"; } } if (returnString.EndsWith(";")) { returnString = returnString.Remove(returnString.Length - 1); } return(returnString); } else { return(null); } }
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 ToDirectoryServiceAccountSamAccountName(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { int num; if (extendedData == null || extendedData.Value == null) { AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); return; } else { string value = extendedData.Value as string; if (!string.IsNullOrEmpty(value)) { bool flag = value.EndsWith("$", StringComparison.OrdinalIgnoreCase); int length = value.Length; if (flag) { num = 16; } else { num = 15; } if (length <= num) { if (!flag) { value = string.Concat(value, "$"); } } else { object[] objArray = new object[1]; objArray[0] = value; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ServiceAccountNameLengthInvalid, objArray)); } } AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, new ADPropertyValueCollection(value), directoryObj, cmdletSessionInfo); 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 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 ToDirectoryFromTopologyObjectNameListToDNList <F, O>(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) where F : ADFactory <O>, new() where O : ADEntity, new() { AttributeConverters.ToDirectoryMultivalueObjectConvertor(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo, new MultiValueAttributeConvertorDelegate(ADTopologyUtil.FromNameToTopologyDN <F, O>)); }
public ADPropertyValueCollection ConvertToADPropertyValueCollection(string parameterName) { ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(); aDPropertyValueCollection.TrackChanges = true; string str = null; string str1 = null; string str2 = null; if (this._hash != null) { foreach (object key in this._hash.Keys) { if (string.Compare((string)key, "Add", StringComparison.OrdinalIgnoreCase) != 0) { if (string.Compare((string)key, "Remove", StringComparison.OrdinalIgnoreCase) != 0) { if (string.Compare((string)key, "Replace", StringComparison.OrdinalIgnoreCase) != 0) { continue; } str2 = (string)key; } else { str1 = (string)key; } } else { str = (string)key; } } if (str2 != null) { if (this._hash[str2] != null) { aDPropertyValueCollection.Clear(); this.processMultivalueElement(PropertyModifyOp.Replace, aDPropertyValueCollection, this._hash[str2], parameterName); } else { aDPropertyValueCollection.Value = null; } } else { if (str != null) { this.processMultivalueElement(PropertyModifyOp.Add, aDPropertyValueCollection, this._hash[str], parameterName); } if (str1 != null) { this.processMultivalueElement(PropertyModifyOp.Remove, aDPropertyValueCollection, this._hash[str1], parameterName); } } } else { aDPropertyValueCollection.Value = null; } return(aDPropertyValueCollection); }
internal virtual void InvokeToDirectoryConverter(ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { this._toDirectoryDelegate(base.ExtendedAttribute, this.DirectoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal static void ToRuleXmlFromPolicyString(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; string str = string.Format(CultureInfo.InvariantCulture, ADClaimTransformPolicyFactory <T> .RuleXml, value); RulesParser rulesParser = new RulesParser(); try { rulesParser.ValidateRules(str); } catch (XmlParseException xmlParseException1) { XmlParseException xmlParseException = xmlParseException1; object[] message = new object[2]; message[0] = extendedData.Value; message[1] = xmlParseException.Message; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.XmlFormattingError, message)); } catch (PolicyValidationException policyValidationException1) { PolicyValidationException policyValidationException = policyValidationException1; object[] objArray = new object[2]; objArray[0] = extendedData.Value; objArray[1] = policyValidationException.Message; throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.RuleValidationFailure, objArray)); } directoryObj[directoryAttributes[0]].Value = str; return; } }
internal static void ToDirectoryXmlFromADSuggestedValueEntryList(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { directoryObj.ForceRemove(directoryAttributes[0]); return; } else { ADSuggestedValueEntry[] valueList = extendedData.ValueList as ADSuggestedValueEntry[]; directoryObj.InternalProperties["SuggestedValues"].Value = valueList; return; } }
internal static void ToDirectoryFromSchemaObjectNameListToDNList(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { AttributeConverters.ToDirectoryMultivalueObjectConvertor(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo, new MultiValueAttributeConvertorDelegate(ADCBACUtil.FromNameToSchemaDN)); }
protected internal virtual void WritePropertiesToOutput(O inputIdentity, ADEntity constructedIdentityObject) { bool flag = false; if (constructedIdentityObject == null) { DebugLogger.LogInfo("ADGetPropertiesCmdletBase", string.Format("Identity: {0} not found", inputIdentity)); } else { CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); ADPropertyValueCollection item = constructedIdentityObject[this.SourceProperty]; RO rO = Activator.CreateInstance <RO>(); if (item == null) { DebugLogger.LogInfo("ADGetPropertiesCmdletBase", string.Format("Could not find property: {0} for identity: {1}", this.SourceProperty, inputIdentity)); return; } else { List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>(this._pageSize); foreach (string str in item) { try { string str1 = this.ExtractIdentityInfoFromSourcePropertyValue(str, out flag); if (str1 != null) { rO.Identity = str1; if (!flag) { RO extendedObjectFromIdentity = this._returnObjectFactory.GetExtendedObjectFromIdentity(rO, cmdletSessionInfo.DefaultPartitionPath); base.WriteObject(extendedObjectFromIdentity); } else { IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", Utils.EscapeDNForFilter(str1)); aDOPathNodes.Add(aDOPathNode); if (aDOPathNodes.Count >= this._pageSize) { this.WriteObjectsInBatch(aDOPathNodes); aDOPathNodes.Clear(); } } } else { DebugLogger.LogInfo("ADGetPropertiesCmdletBase", string.Format("ExtractIdentityInfoFromSourcePropertyValue returned NULL for propertyValue: {0} - skipping this value", str)); } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; base.WriteError(ADUtilities.GetErrorRecord(aDIdentityNotFoundException, "ADGetPropertiesCmdletBase:WritePropertiesToOutput", str)); } } if (aDOPathNodes.Count > 0) { this.WriteObjectsInBatch(aDOPathNodes); aDOPathNodes.Clear(); return; } } } }
private void processMultivalueElement(PropertyModifyOp operation, ADPropertyValueCollection collection, object value, string parameterName) { object baseObject; if (value as object[] == null) { if (value.GetType() == typeof(PSObject)) { value = ((PSObject)value).BaseObject; } if (operation != PropertyModifyOp.Add) { if (operation != PropertyModifyOp.Remove) { if (operation != PropertyModifyOp.Replace) { throw new ArgumentException(); } else { collection.Add(value); return; } } else { collection.ForceRemove(value); return; } } else { collection.Add(value); return; } } else { object[] objArray = (object[])value; for (int i = 0; i < (int)objArray.Length; i++) { object obj = objArray[i]; if (obj.GetType() != typeof(PSObject)) { baseObject = obj; } else { baseObject = ((PSObject)obj).BaseObject; } if (operation != PropertyModifyOp.Add) { if (operation != PropertyModifyOp.Remove) { if (operation != PropertyModifyOp.Replace) { throw new ArgumentException(); } else { collection.Add(baseObject); } } else { collection.ForceRemove(baseObject); } } else { collection.Add(baseObject); } } return; } }
internal static void ToDirectoryComputerSamAccountName(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData == null || extendedData.Value == null) { AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); return; } else { string value = extendedData.Value as string; if (!string.IsNullOrEmpty(value) && !value.EndsWith("$", StringComparison.OrdinalIgnoreCase)) { value = string.Concat(value, "$"); } AttributeConverters.ToDirectoryObject(extendedAttribute, directoryAttributes, new ADPropertyValueCollection(value), directoryObj, cmdletSessionInfo); 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; } } }
internal static void ToDirectoryFromServerNameToNTDSSettings(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADDirectoryServerFactory <ADDirectoryServer>, ADDirectoryServer>(cmdletSessionInfo.ADRootDSE.DefaultNamingContext, "NTDSSettingsObjectDN", extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal static void ToDirectoryCapMember(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { if (extendedData != null && directoryObj["msAuthz-MemberRulesInCentralAccessPolicy"] != null) { int count = extendedData.AddedValues.Count - extendedData.DeletedValues.Count; if (directoryObj["msAuthz-MemberRulesInCentralAccessPolicy"].Count + count > CentralAccessPolicyConstants.MaximumCARsPerCap) { object[] maximumCARsPerCap = new object[1]; maximumCARsPerCap[0] = CentralAccessPolicyConstants.MaximumCARsPerCap; throw new ArgumentOutOfRangeException("Members", string.Format(CultureInfo.CurrentCulture, StringResources.CAPMemberMaximumExceeded, maximumCARsPerCap)); } } AttributeConverters.ToDirectoryMultivalueObjectConvertor(extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo, new MultiValueAttributeConvertorDelegate(AttributeConverters.MultiValueNoOpConvertor)); }
internal static void ToDirectoryFromSiteNameToDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Sites,", ADPathFormat.X500); AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADReplicationSiteFactory <ADReplicationSite>, ADReplicationSite>(str, null, extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
internal static void ToDirectoryFromNameToManagedByDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo) { AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADPrincipalFactory <ADPrincipal>, ADPrincipal>(cmdletSessionInfo.ADRootDSE.DefaultNamingContext, null, extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo); }
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; } }