public static IADOPathNode ToSearchAccountExpirationDate(string extendedAttribute, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) { bool flag; BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode; if (binaryADOPathNode == null) { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } else { PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]); IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode; if (rightNode == null) { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } else { ObjectADOPathNode objectADOPathNode = new ObjectADOPathNode(rightNode.DataObject); objectADOPathNode.EncodeAsteriskChar = rightNode.EncodeAsteriskChar; IADOPathNode searchDateTimeUsingSchemaInfo = new BinaryADOPathNode(binaryADOPathNode.Operator, propertyADOPathNode, objectADOPathNode); searchDateTimeUsingSchemaInfo = SearchConverters.ToSearchDateTimeUsingSchemaInfo(extendedAttribute, directoryAttributes, searchDateTimeUsingSchemaInfo, cmdletSessionInfo); bool flag1 = true; if (binaryADOPathNode.Operator != ADOperator.Eq) { if (binaryADOPathNode.Operator == ADOperator.Like) { if (rightNode.DataObject as string == null) { flag = false; } else { flag = ADOPathUtil.IsValueAllAsterisk((string)rightNode.DataObject); } flag1 = flag; } } else { flag1 = false; } if (!flag1) { return searchDateTimeUsingSchemaInfo; } else { IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2]; aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, directoryAttributes[0], 0); aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, directoryAttributes[0], 0x7fffffffffffffffL); IADOPathNode aDOPathNode = ADOPathUtil.CreateNotClause(ADOPathUtil.CreateOrClause(aDOPathNodeArray)); IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2]; aDOPathNodeArray1[0] = searchDateTimeUsingSchemaInfo; aDOPathNodeArray1[1] = aDOPathNode; return ADOPathUtil.CreateAndClause(aDOPathNodeArray1); } } } }
internal static IADOPathNode CreateRelationalExpressionNode(ADOperator op, IADOPathNode leftExpr, IADOPathNode rightExpr, ConvertSearchFilterDelegate searchFilterConverter) { if (op == ADOperator.Eq || op == ADOperator.Ne) { VariableADOPathNode variableADOPathNode = rightExpr as VariableADOPathNode; if (variableADOPathNode != null) { variableADOPathNode.EncodeAsteriskChar = true; } TextDataADOPathNode textDataADOPathNode = rightExpr as TextDataADOPathNode; if (textDataADOPathNode != null) { textDataADOPathNode.EncodeAsteriskChar = true; } } IADOPathNode binaryADOPathNode = new BinaryADOPathNode(op, leftExpr, rightExpr); if (searchFilterConverter != null) { binaryADOPathNode = searchFilterConverter(binaryADOPathNode); } return(binaryADOPathNode); }
public static IADOPathNode ToSearchGroupScope(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) { ADGroupScope aDGroupScope = ADGroupScope.DomainLocal; BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode; if (binaryADOPathNode == null) { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } else { if (binaryADOPathNode.Operator == ADOperator.Eq || binaryADOPathNode.Operator == ADOperator.Ne) { IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode; if (rightNode == null) { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } else { if (!Utils.TryParseEnum<ADGroupScope>(rightNode.DataObject.ToString(), out aDGroupScope)) { object[] str = new object[2]; str[0] = rightNode.DataObject.ToString(); str[1] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterInvalidValue, str)); } else { PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]); ObjectADOPathNode objectADOPathNode = new ObjectADOPathNode((object)GroupTypeUtils.GetDirectoryGroupTypeValue(aDGroupScope)); IADOPathNode aDOPathNode = new BinaryADOPathNode(ADOperator.Band, propertyADOPathNode, objectADOPathNode); if (binaryADOPathNode.Operator != ADOperator.Eq) { return ADOPathUtil.CreateNotClause(aDOPathNode); } else { return aDOPathNode; } } } } else { object[] objArray = new object[2]; ADOperator[] aDOperatorArray = new ADOperator[2]; aDOperatorArray[1] = ADOperator.Ne; objArray[0] = SearchConverters.ConvertOperatorListToString(aDOperatorArray); objArray[1] = extendedAttributeName; throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, objArray)); } } }
internal static string ChangeNodeToWhereFilterSyntax(IADOPathNode node) { if (node != null) { if (node as UnaryADOPathNode == null) { if (node as BinaryADOPathNode == null) { if (node as TextDataADOPathNode == null) { if (node as VariableADOPathNode == null) { if (node as CompositeADOPathNode == null) { if (node as IDataNode == null) { object[] type = new object[1]; type[0] = node.GetType(); throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Node type: {0} not supported", type)); } else { IDataNode dataNode = (IDataNode)node; return(dataNode.DataObject.ToString()); } } else { CompositeADOPathNode compositeADOPathNode = (CompositeADOPathNode)node; StringBuilder stringBuilder = new StringBuilder("( "); int num = 0; foreach (IADOPathNode childNode in compositeADOPathNode.ChildNodes) { if (num > 0) { stringBuilder.Append(" -"); stringBuilder.Append(compositeADOPathNode.Operator); stringBuilder.Append(" "); } stringBuilder.Append(ADOPathUtil.ChangeNodeToWhereFilterSyntax(childNode)); num++; } stringBuilder.Append(" )"); return(stringBuilder.ToString()); } } else { VariableADOPathNode variableADOPathNode = (VariableADOPathNode)node; return(string.Concat("$", variableADOPathNode.VariableExpression)); } } else { TextDataADOPathNode textDataADOPathNode = (TextDataADOPathNode)node; return(string.Concat("\"", textDataADOPathNode.TextValue, "\"")); } } else { BinaryADOPathNode binaryADOPathNode = (BinaryADOPathNode)node; if (binaryADOPathNode.Operator == ADOperator.Approx || binaryADOPathNode.Operator == ADOperator.RecursiveMatch) { object[] str = new object[1]; str[0] = binaryADOPathNode.Operator.ToString(); throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Operator type: {0} is not supported", str)); } else { StringBuilder stringBuilder1 = new StringBuilder("( "); if (binaryADOPathNode.LeftNode as VariableADOPathNode == null) { stringBuilder1.Append("$_."); stringBuilder1.Append(ADOPathUtil.ChangeNodeToWhereFilterSyntax(binaryADOPathNode.LeftNode)); } else { IDataNode leftNode = (VariableADOPathNode)binaryADOPathNode.LeftNode; stringBuilder1.Append("$_."); stringBuilder1.Append(leftNode.DataObject.ToString()); } if (ADOperator.Like != binaryADOPathNode.Operator || string.Compare(binaryADOPathNode.RightNode.GetLdapFilterString(), "*", StringComparison.OrdinalIgnoreCase) != 0) { stringBuilder1.Append(" -"); stringBuilder1.Append(binaryADOPathNode.Operator.ToString()); stringBuilder1.Append(" "); stringBuilder1.Append(ADOPathUtil.ChangeNodeToWhereFilterSyntax(binaryADOPathNode.RightNode)); stringBuilder1.Append(" )"); } else { stringBuilder1.Append(" -"); stringBuilder1.Append(ADOperator.Ne.ToString()); stringBuilder1.Append(" "); stringBuilder1.Append("$null"); stringBuilder1.Append(" )"); } return(stringBuilder1.ToString()); } } } else { UnaryADOPathNode unaryADOPathNode = (UnaryADOPathNode)node; StringBuilder stringBuilder2 = new StringBuilder("-"); stringBuilder2.Append(unaryADOPathNode.Operator.ToString()); stringBuilder2.Append("( "); stringBuilder2.Append(ADOPathUtil.ChangeNodeToWhereFilterSyntax(unaryADOPathNode.ChildNode)); stringBuilder2.Append(" )"); return(stringBuilder2.ToString()); } } else { throw new ArgumentNullException("node"); } }
internal static IADOPathNode CreateRelationalExpressionNode(ADOperator op, IADOPathNode leftExpr, IADOPathNode rightExpr, ConvertSearchFilterDelegate searchFilterConverter) { if (op == ADOperator.Eq || op == ADOperator.Ne) { VariableADOPathNode variableADOPathNode = rightExpr as VariableADOPathNode; if (variableADOPathNode != null) { variableADOPathNode.EncodeAsteriskChar = true; } TextDataADOPathNode textDataADOPathNode = rightExpr as TextDataADOPathNode; if (textDataADOPathNode != null) { textDataADOPathNode.EncodeAsteriskChar = true; } } IADOPathNode binaryADOPathNode = new BinaryADOPathNode(op, leftExpr, rightExpr); if (searchFilterConverter != null) { binaryADOPathNode = searchFilterConverter(binaryADOPathNode); } return binaryADOPathNode; }