internal static IADOPathNode ToSearchFlagInInt(int bit, bool isInverted, string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) { BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode; if (binaryADOPathNode != null) { IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode; if (rightNode != null) { if (rightNode.DataObject is bool) { ADOperator @operator = binaryADOPathNode.Operator; if (@operator == ADOperator.Eq || @operator == ADOperator.Ne) { IADOPathNode aDOPathNode = new BinaryADOPathNode(ADOperator.Bor, new PropertyADOPathNode(directoryAttributes[0]), new ObjectADOPathNode((object)bit)); bool dataObject = !(bool)rightNode.DataObject; if (@operator == ADOperator.Ne) { dataObject = !dataObject; } if (isInverted) { dataObject = !dataObject; } if (dataObject) { aDOPathNode = ADOPathUtil.CreateNotClause(aDOPathNode); } return(aDOPathNode); } else { object[] str = new object[2]; ADOperator[] aDOperatorArray = new ADOperator[2]; aDOperatorArray[1] = ADOperator.Ne; str[0] = SearchConverters.ConvertOperatorListToString(aDOperatorArray); str[1] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, str)); } } else { object[] type = new object[2]; type[0] = rightNode.DataObject.GetType(); type[1] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterRHSInvalidType, type)); } } else { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } } else { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } }
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)); } } }
private bool SearchADAccountBeginCSRoutine() { IADOPathNode item; DateTime value; DateTime dateTime; List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>(); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); this.ValidateParameters(); string[] strArrays = new string[6]; strArrays[0] = "Enabled"; strArrays[1] = "LockedOut"; strArrays[2] = "PasswordNeverExpires"; strArrays[3] = "PasswordExpired"; strArrays[4] = "AccountExpirationDate"; strArrays[5] = "LastLogonDate"; this._cmdletParameters["Properties"] = strArrays; base.BuildPropertySet(); new StringBuilder(); int num = 0; //TODO: Review: this._cmdletParameters.ComputersOnly; if (this._cmdletParameters.ComputersOnly) { aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "computer")); num++; } //TODO: Review: this._cmdletParameters.UsersOnly; if (this._cmdletParameters.UsersOnly) { aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Ne, "objectClass", "computer")); num++; } if (num <= 1) { double? nullable = null; DateTime?nullable1 = null; if (this._cmdletParameters.Contains("TimeSpan")) { //TODO: Review: this._cmdletParameters.TimeSpan; TimeSpan timeSpan = this._cmdletParameters.TimeSpan; nullable = new double?(timeSpan.TotalDays); } if (this._cmdletParameters.Contains("DateTime")) { //TODO: Review: this._cmdletParameters.DateTime; nullable1 = new DateTime?(this._cmdletParameters.DateTime); } if (!this._cmdletParameters.AccountDisabled) { if (!this._cmdletParameters.PasswordNeverExpires) { if (!this._cmdletParameters.PasswordExpired) { if (!this._cmdletParameters.AccountExpiring) { if (!this._cmdletParameters.AccountExpired) { if (!this._cmdletParameters.AccountInactive) { if (this._cmdletParameters.LockedOut) { aDOPathNodes.Add(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["AccountLockoutTime"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Ge, "AccountLockoutTime", 1), cmdletSessionInfo)); base.OutputFilterFunction = new ADGetCmdletBase <SearchADAccountParameterSet, ADAccountFactory <ADAccount>, ADAccount> .OutputFilterDelegate(this.FilterIsLockedOut); } } else { double inactiveTimeSpanDays = this.GetInactiveTimeSpanDays(cmdletSessionInfo); if (!nullable1.HasValue) { if (!nullable.HasValue) { DateTime now = DateTime.Now; dateTime = now.AddDays(-inactiveTimeSpanDays); } else { DateTime now1 = DateTime.Now; dateTime = now1.AddDays(-(nullable.Value + inactiveTimeSpanDays)); } } else { DateTime value1 = nullable1.Value; dateTime = value1.AddDays(-inactiveTimeSpanDays); } aDOPathNodes.Add(ADOPathUtil.CreateNotClause(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["LastLogonDate"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Ge, "LastLogonDate", dateTime), cmdletSessionInfo))); } } else { aDOPathNodes.Add(ADOPathUtil.CreateNotClause(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["AccountExpirationDate"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Ge, "AccountExpirationDate", DateTime.Now), cmdletSessionInfo))); aDOPathNodes.Add(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["AccountExpirationDate"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Like, "AccountExpirationDate", "*"), cmdletSessionInfo)); } } else { DateTime dateTime1 = DateTime.Now; if (!nullable1.HasValue) { if (!nullable.HasValue) { value = dateTime1.AddDays(5); } else { value = dateTime1.AddDays(nullable.Value); } } else { value = nullable1.Value; } aDOPathNodes.Add(ADOPathUtil.CreateNotClause(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["AccountExpirationDate"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Ge, "AccountExpirationDate", value), cmdletSessionInfo))); aDOPathNodes.Add(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["AccountExpirationDate"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Ge, "AccountExpirationDate", dateTime1), cmdletSessionInfo)); } } else { aDOPathNodes.Add(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["PasswordExpired"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "PasswordExpired", true), cmdletSessionInfo)); } } else { aDOPathNodes.Add(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["PasswordNeverExpires"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "PasswordNeverExpires", true), cmdletSessionInfo)); } } else { aDOPathNodes.Add(ADAccountFactory <ADAccount> .AttributeTable[cmdletSessionInfo.ConnectedADServerType]["Enabled"].InvokeToSearcherConverter(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "Enabled", false), cmdletSessionInfo)); } if (aDOPathNodes.Count <= 0) { this.OutputSearchResults(null); } else { if (aDOPathNodes.Count != 1) { item = ADOPathUtil.CreateAndClause(aDOPathNodes.ToArray()); } else { item = aDOPathNodes[0]; } this.OutputSearchResults(item); } return(true); } else { throw new ParameterBindingException(string.Format(StringResources.ParameterRequiredOnlyOne, string.Format("{0} {1}", "ComputersOnly", "UsersOnly"))); } }
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 ToSearchFlagEnumerationInInt <T>(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo) { T t = default(T); object num; IADOPathNode item; BinaryADOPathNode binaryADOPathNode = filterClause as BinaryADOPathNode; if (binaryADOPathNode != null) { IDataNode rightNode = binaryADOPathNode.RightNode as IDataNode; if (rightNode != null) { ADOperator @operator = binaryADOPathNode.Operator; if (@operator == ADOperator.Eq || @operator == ADOperator.Ne) { char[] chrArray = new char[1]; chrArray[0] = ','; string[] strArrays = rightNode.DataObject.ToString().Split(chrArray); List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>(); string[] strArrays1 = strArrays; int num1 = 0; while (num1 < (int)strArrays1.Length) { string str = strArrays1[num1]; if (!Utils.TryParseEnum <T>(str, 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)) { num = Convert.ToInt64(t, CultureInfo.InvariantCulture); } else { num = Convert.ToInt32(t, CultureInfo.InvariantCulture); } IADOPathNode aDOPathNode = new BinaryADOPathNode(ADOperator.Bor, new PropertyADOPathNode(directoryAttributes[0]), new ObjectADOPathNode(num)); aDOPathNodes.Add(aDOPathNode); num1++; } } if (aDOPathNodes.Count <= 1) { if (aDOPathNodes.Count != 1) { object[] objArray1 = new object[1]; objArray1[0] = extendedAttributeName; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterRHSNotMatchEnumValue, objArray1)); } else { item = aDOPathNodes[0]; } } else { item = ADOPathUtil.CreateAndClause(aDOPathNodes.ToArray()); } if (@operator == ADOperator.Ne) { item = ADOPathUtil.CreateNotClause(item); } return(item); } 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 ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.SearchConverterSupportedOperatorListErrorMessage, str1)); } } else { throw new ArgumentException(StringResources.SearchConverterRHSNotDataNode); } } else { throw new ArgumentException(StringResources.SearchConverterNotBinaryNode); } }