internal static IADOPathNode ToSearchUsingSchemaInfo(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) { ADTypeConverter aDTypeConverter = new ADTypeConverter(cmdletSessionInfo.ADSessionInfo); BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode; if (binaryADOPathNode == null) { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } else { PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]); ObjectADOPathNode objectADOPathNode = new ObjectADOPathNode(null); IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode; if (rightNode == null) { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } else { object raw = aDTypeConverter.ConvertToRaw(directoryAttributes[0], rightNode.DataObject); objectADOPathNode.DataObject = raw; objectADOPathNode.EncodeAsteriskChar = rightNode.EncodeAsteriskChar; return(new BinaryADOPathNode(binaryADOPathNode.Operator, propertyADOPathNode, objectADOPathNode)); } } }
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 IADOPathNode ToSearchEnum <T>(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) { T t = default(T); BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode; if (binaryADOPathNode == null) { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } else { PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]); ObjectADOPathNode objectADOPathNode = new ObjectADOPathNode(null); IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode; if (rightNode == null) { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } else { if (!Utils.TryParseEnum <T>(rightNode.DataObject.ToString(), out t)) { object[] objArray = new object[1]; objArray[0] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterRHSNotMatchEnumValue, objArray)); } else { if (Enum.GetUnderlyingType(typeof(T)) != typeof(int)) { objectADOPathNode.DataObject = Convert.ToInt64(t, CultureInfo.InvariantCulture); } else { objectADOPathNode.DataObject = Convert.ToInt32(t, CultureInfo.InvariantCulture); } return(new BinaryADOPathNode(binaryADOPathNode.Operator, propertyADOPathNode, objectADOPathNode)); } } } }
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 ToSearchFromADEntityToAttributeValue <F, O>(string searchBase, string attributeName, string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) where F : ADFactory <O>, new() where O : ADEntity, new() { ADEntity extendedObjectFromIdentity; IADOPathNode binaryADOPathNode; BinaryADOPathNode binaryADOPathNode1 = filterClause as BinaryADOPathNode; if (binaryADOPathNode1 == null) { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } else { if (binaryADOPathNode1.Operator == ADOperator.Eq || binaryADOPathNode1.Operator == ADOperator.Ne) { IDataNode rightNode = binaryADOPathNode1.RightNode as IDataNode; if (rightNode == null) { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } else { PropertyADOPathNode propertyADOPathNode = new PropertyADOPathNode(directoryAttributes[0]); ObjectADOPathNode objectADOPathNode = new ObjectADOPathNode(null); O dataObject = (O)(rightNode.DataObject as O); if (dataObject == null) { string str = rightNode.DataObject as string; if (str != null) { dataObject = Activator.CreateInstance <O>(); dataObject.Identity = str; } } if (dataObject == null) { object[] objArray = new object[2]; objArray[0] = rightNode.DataObject.ToString(); objArray[1] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterInvalidValue, objArray)); } else { F f = Activator.CreateInstance <F>(); f.SetCmdletSessionInfo(cmdletSessionInfo); try { if (attributeName != null) { HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase); strs.Add(attributeName); extendedObjectFromIdentity = f.GetExtendedObjectFromIdentity(dataObject, searchBase, strs, false); objectADOPathNode.DataObject = (string)extendedObjectFromIdentity[attributeName].Value; } else { extendedObjectFromIdentity = f.GetDirectoryObjectFromIdentity(dataObject, searchBase); objectADOPathNode.DataObject = (string)extendedObjectFromIdentity["DistinguishedName"].Value; } binaryADOPathNode = new BinaryADOPathNode(binaryADOPathNode1.Operator, propertyADOPathNode, objectADOPathNode); } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; object[] message = new object[2]; message[0] = extendedAttributeName; message[1] = aDIdentityNotFoundException.Message; throw new ADIdentityResolutionException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityInExtendedAttributeCannotBeResolved, message), aDIdentityNotFoundException); } catch (ADIdentityResolutionException aDIdentityResolutionException1) { ADIdentityResolutionException aDIdentityResolutionException = aDIdentityResolutionException1; object[] message1 = new object[2]; message1[0] = extendedAttributeName; message1[1] = aDIdentityResolutionException.Message; throw new ADIdentityResolutionException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityInExtendedAttributeCannotBeResolved, message1), aDIdentityResolutionException); } return(binaryADOPathNode); } } } else { object[] str1 = new object[2]; ADOperator[] aDOperatorArray = new ADOperator[2]; aDOperatorArray[1] = ADOperator.Ne; str1[0] = SearchConverters.ConvertOperatorListToString(aDOperatorArray); str1[1] = extendedAttributeName; throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, str1)); } } }