コード例 #1
0
        internal string GetRDNPrefix(string objectClass)
        {
            ADObject         aDObject;
            ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);

            using (aDObjectSearcher)
            {
                ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE();
                aDObjectSearcher.SearchRoot = rootDSE.SchemaNamingContext;
                aDObjectSearcher.Properties.Add("rDNAttID");
                IADOPathNode   aDOPathNode      = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
                IADOPathNode   aDOPathNode1     = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "lDAPDisplayName", objectClass);
                IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
                aDOPathNodeArray[0] = aDOPathNode;
                aDOPathNodeArray[1] = aDOPathNode1;
                IADOPathNode aDOPathNode2 = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
                aDObjectSearcher.Filter = aDOPathNode2;
                aDObject = aDObjectSearcher.FindOne();
            }
            if (aDObject == null)
            {
                return(null);
            }
            else
            {
                return((string)aDObject["rDNAttID"][0]);
            }
        }
コード例 #2
0
 string Microsoft.ActiveDirectory.Management.IADOPathNode.GetLdapFilterString()
 {
     if (this._data == null)
     {
         return("");
     }
     else
     {
         return(ADOPathUtil.LdapSearchEncodeObject(this._data, this._encodeAsteriskChar));
     }
 }
コード例 #3
0
        string Microsoft.ActiveDirectory.Management.IADOPathNode.GetLdapFilterString()
        {
            StringBuilder stringBuilder = new StringBuilder("(");

            stringBuilder.Append(ADOPathUtil.GetLdapFilterString(this._operator));
            foreach (IADOPathNode _childNode in this._childNodes)
            {
                stringBuilder.Append(_childNode.GetLdapFilterString());
            }
            stringBuilder.Append(")");
            return(stringBuilder.ToString());
        }
コード例 #4
0
 private void Refresh(ADRootDSE rootDSE)
 {
     if (rootDSE != null)
     {
         if (rootDSE.SessionInfo != null)
         {
             if (this._forestId.Equals(rootDSE.SubSchemaSubEntry, StringComparison.OrdinalIgnoreCase))
             {
                 object[] objArray = new object[1];
                 objArray[0] = this._forestId;
                 DebugLogger.LogInfo("ADForestPartitionInfo", "Refreshing PartitionList of Forest: {0}", objArray);
                 List <string> strs        = new List <string>();
                 ADSessionInfo sessionInfo = rootDSE.SessionInfo;
                 if (rootDSE.ServerType == ADServerType.ADDS && sessionInfo.ConnectedToGC)
                 {
                     sessionInfo = sessionInfo.Copy();
                     sessionInfo.SetEffectivePort(LdapConstants.LDAP_PORT);
                 }
                 using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
                 {
                     aDObjectSearcher.SchemaTranslation = false;
                     aDObjectSearcher.SearchRoot        = string.Concat("CN=Partitions,", rootDSE.ConfigurationNamingContext);
                     aDObjectSearcher.Properties.Add("nCName");
                     aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRef");
                     foreach (ADObject aDObject in aDObjectSearcher.FindAll())
                     {
                         if (aDObject["nCName"] == null || aDObject["nCName"].Count <= 0)
                         {
                             continue;
                         }
                         strs.Add((string)aDObject["nCName"][0]);
                     }
                     this._forestPartitionList = new ReadOnlyCollection <string>(strs);
                 }
                 return;
             }
             else
             {
                 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ForestIdDoesNotMatch, new object[0]));
             }
         }
         else
         {
             throw new ArgumentNullException("rootDSE.SessionInfo");
         }
     }
     else
     {
         throw new ArgumentNullException("rootDSE");
     }
 }
コード例 #5
0
ファイル: ADOPathUtil.cs プロジェクト: modulexcite/pash-1
        public static IADOPathNode CreateFilterClause(ADOperator op, string attributeName, object value)
        {
            IADOPathNode objectADOPathNode;
            IADOPathNode propertyADOPathNode = new PropertyADOPathNode(attributeName);
            string       str = value as string;

            if (str == null)
            {
                objectADOPathNode = new ObjectADOPathNode(value);
            }
            else
            {
                objectADOPathNode = new TextDataADOPathNode(str);
            }
            return(ADOPathUtil.CreateRelationalExpressionNode(op, propertyADOPathNode, objectADOPathNode, null));
        }
コード例 #6
0
        private void ReadConstructedSchema(ADObjectSearcher searcher, ADSchema adSchema)
        {
            searcher.SchemaTranslation = false;
            ADRootDSE rootDSE = searcher.GetRootDSE();

            searcher.SearchRoot = rootDSE.SubSchemaSubEntry;
            searcher.Filter     = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
            searcher.Scope      = ADSearchScope.Base;
            searcher.Properties.Clear();
            searcher.Properties.Add("extendedAttributeInfo");
            searcher.Properties.Add("attributeTypes");
            ADObject aDObject = searcher.FindOne();
            int      success  = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.NameGroup);
            int      num      = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.SyntaxGroup);
            int      num1     = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.SingleValueGroup);

            adSchema._schemaProperties = new Dictionary <string, ADSchemaAttribute>(1, StringComparer.OrdinalIgnoreCase);
            foreach (string item in aDObject["attributeTypes"])
            {
                Match match = SchemaConstants.AttributeTypesRegex.Match(item);
                if (match != null)
                {
                    if (!match.Groups[success].Success)
                    {
                        DebugLogger.LogError("adschema", string.Format("AttributeType {0} no match on Name", item));
                    }
                    if (!match.Groups[num].Success)
                    {
                        DebugLogger.LogError("adschema", string.Format("AttributeType {0} no match on Syntax", item));
                    }
                    adSchema._schemaProperties.Add(match.Groups[success].Value, new ADSchemaAttribute(ADSyntax.OIDToSyntax(match.Groups[num].Value), match.Groups[num1].Success, false));
                }
                else
                {
                    DebugLogger.LogError("adschema", string.Format("unable to match AttributeType {0}", item));
                    throw new ADException();
                }
            }
            success = SchemaConstants.ExtendedAttrInfoRegex.GroupNumberFromName(SchemaConstants.NameGroup);
            int num2 = SchemaConstants.ExtendedAttrInfoRegex.GroupNumberFromName(SchemaConstants.SystemOnlyGroup);

            foreach (string str in aDObject["extendedAttributeInfo"])
            {
                Match match1 = SchemaConstants.ExtendedAttrInfoRegex.Match(str);
                adSchema._schemaProperties[match1.Groups[success].Value].IsSystemOnly = match1.Groups[num2].Success;
            }
        }
コード例 #7
0
        private void ReadObjectSchema(ADObjectSearcher searcher, ADSchema adSchema)
        {
            searcher.SchemaTranslation = false;
            ADRootDSE rootDSE = searcher.GetRootDSE();

            searcher.SearchRoot = rootDSE.SchemaNamingContext;
            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3];
            aDOPathNodeArray[0] = ADOPathUtil.CreateNotClause(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "isDefunct", true));
            aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "attributeSchema");
            IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[3];
            aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "attributeSyntax", SchemaConstants.SidAttributeSyntax);
            aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Like, "linkID", "*");
            aDOPathNodeArray1[2] = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", SchemaConstants.systemFlagsConstructedBitMask);
            aDOPathNodeArray[2]  = ADOPathUtil.CreateOrClause(aDOPathNodeArray1);
            searcher.Filter      = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
            searcher.Scope       = ADSearchScope.Subtree;
            searcher.PageSize    = 0x100;
            searcher.Properties.Clear();
            searcher.Properties.Add("lDAPDisplayName");
            searcher.Properties.Add("linkID");
            searcher.Properties.Add("systemFlags");
            searcher.Properties.Add("attributeSyntax");
            IEnumerable <ADObject> aDObjects = searcher.FindAll();

            foreach (ADObject nullable in aDObjects)
            {
                if (adSchema._schemaProperties.ContainsKey((string)nullable["lDAPDisplayName"].Value))
                {
                    if (nullable.Contains("linkID"))
                    {
                        adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].LinkID = new int?(int.Parse(nullable["linkID"].Value as string, NumberFormatInfo.InvariantInfo));
                    }
                    if (nullable.Contains("systemFlags") && (long)0 != (ulong.Parse(nullable["systemFlags"].Value as string, NumberFormatInfo.InvariantInfo) & SchemaConstants.systemFlagsConstructedBitMask))
                    {
                        adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].IsConstructed = true;
                    }
                    if (!nullable.Contains("attributeSyntax") || string.Compare(nullable["attributeSyntax"].Value as string, SchemaConstants.SidAttributeSyntax, true) != 0)
                    {
                        continue;
                    }
                    adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].Syntax = ADAttributeSyntax.Sid;
                }
            }
        }
コード例 #8
0
        string Microsoft.ActiveDirectory.Management.IADOPathNode.GetLdapFilterString()
        {
            StringBuilder stringBuilder = new StringBuilder("(");

            stringBuilder.Append(ADOPathUtil.GetLdapFilterString(this._operator));
            string ldapFilterString = this._childExpr.GetLdapFilterString();

            if (this._childExpr as UnaryADOPathNode != null)
            {
                UnaryADOPathNode unaryADOPathNode = (UnaryADOPathNode)this._childExpr;
                if (unaryADOPathNode._operator == ADOperator.Not && this._operator == ADOperator.Not)
                {
                    return(unaryADOPathNode._childExpr.GetLdapFilterString());
                }
            }
            stringBuilder.Append(ldapFilterString);
            stringBuilder.Append(")");
            return(stringBuilder.ToString());
        }
コード例 #9
0
ファイル: ADOPathUtil.cs プロジェクト: modulexcite/pash-1
 internal static string LdapSearchEncodeObject(object obj, bool encodeAsterisk)
 {
     if (obj as byte[] == null)
     {
         if (!(obj is bool))
         {
             if (!(obj is int))
             {
                 if (!(obj is long))
                 {
                     string str = obj.ToString();
                     return(ADOPathUtil.LdapSearchEncodeString(str, encodeAsterisk));
                 }
                 else
                 {
                     long num = (long)obj;
                     return(num.ToString(CultureInfo.InvariantCulture));
                 }
             }
             else
             {
                 int num1 = (int)obj;
                 return(num1.ToString(CultureInfo.InvariantCulture));
             }
         }
         else
         {
             if ((bool)obj)
             {
                 return("TRUE");
             }
             else
             {
                 return("FALSE");
             }
         }
     }
     else
     {
         return(ADOPathUtil.LdapSearchEncodeByteArray((byte[])obj));
     }
 }
コード例 #10
0
        private static IEnumerable <ADObject> FetchRemainingRangeRetrievalAttributeValues(ADObjectSearcher newSearcher, ADObjectSearcher originalSearcher, HashSet <string> rangeRetrievedObjects, HashSet <string> rangeRetrievedAttributes, int rangeRetrievalNextIndex)
        {
            DebugLogger.LogInfo("ADObjectSearcher", string.Concat("Inside FetchRemainingRangeRetrievalAttributeValues. Fetching next range starting from: ", rangeRetrievalNextIndex));
            newSearcher.AutoRangeRetrieve   = false;
            newSearcher.PageSize            = originalSearcher.PageSize;
            newSearcher.Scope               = originalSearcher.Scope;
            newSearcher.SearchRoot          = originalSearcher.SearchRoot;
            newSearcher.SchemaTranslation   = originalSearcher.SchemaTranslation;
            newSearcher.ShowDeleted         = originalSearcher.ShowDeleted;
            newSearcher.ShowDeactivatedLink = originalSearcher.ShowDeactivatedLink;
            newSearcher.SuppressServerRangeRetrievalError = true;
            List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>();

            foreach (string rangeRetrievedObject in rangeRetrievedObjects)
            {
                aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", rangeRetrievedObject));
            }
            if (aDOPathNodes.Count != 1)
            {
                newSearcher.Filter = ADOPathUtil.CreateOrClause(aDOPathNodes.ToArray());
            }
            else
            {
                newSearcher.Filter = aDOPathNodes[0];
            }
            List <string> strs          = new List <string>(rangeRetrievedAttributes.Count);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string rangeRetrievedAttribute in rangeRetrievedAttributes)
            {
                stringBuilder.Remove(0, stringBuilder.Length);
                stringBuilder.Append(rangeRetrievedAttribute).Append(";range=").Append(rangeRetrievalNextIndex).Append("-*");
                strs.Add(stringBuilder.ToString());
            }
            newSearcher.Properties = strs;
            return(newSearcher.FindAll());
        }
コード例 #11
0
 public ADObjectSearcher(ADSessionInfo sessionInfo, ADObject obj)
 {
     this._searchScope              = ADSearchScope.Subtree;
     this._filter                   = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
     this._propertyList             = new List <string>(ADObject.DefaultProperties);
     this._timeLimit                = TimeSpan.Zero;
     this._schemaTranslationEnabled = true;
     this._pageSize                 = 0x100;
     this._searchOption             = null;
     this._autoRangeRetrieve        = true;
     this._sdFlags                  = SecurityMasks.Owner | SecurityMasks.Group | SecurityMasks.Dacl;
     if (sessionInfo == null)
     {
         if (obj == null)
         {
             this._adSession = ADSession.ConstructSession(null);
         }
         else
         {
             this._adSession = ADSession.ConstructSession(obj.SessionInfo);
         }
     }
     else
     {
         this._adSession = ADSession.ConstructSession(sessionInfo);
     }
     if (obj != null)
     {
         this._adObject   = obj;
         this._searchRoot = this._adObject.DistinguishedName;
         foreach (string propertyName in this._adObject.PropertyNames)
         {
             this._propertyList.Add(propertyName);
         }
     }
 }
コード例 #12
0
        private HashSet <string> GetUserSubClasses(ADObjectSearcher searcher, ADRootDSE rootDSE)
        {
            HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            searcher.SearchRoot = rootDSE.SchemaNamingContext;
            searcher.Properties.Add("lDAPDisplayName");
            string       str          = string.Concat("CN=Person,", rootDSE.SchemaNamingContext);
            IADOPathNode aDOPathNode  = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
            IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "subClassOf", "user");
            IADOPathNode aDOPathNode2 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "defaultObjectCategory", str);

            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
            aDOPathNodeArray[0] = aDOPathNode;
            IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2];
            aDOPathNodeArray1[0] = aDOPathNode1;
            aDOPathNodeArray1[1] = aDOPathNode2;
            aDOPathNodeArray[1]  = ADOPathUtil.CreateAndClause(aDOPathNodeArray1);
            IADOPathNode aDOPathNode3 = ADOPathUtil.CreateAndClause(aDOPathNodeArray);

            searcher.Filter = aDOPathNode3;
            IEnumerable <ADObject> aDObjects = searcher.FindAll();

            foreach (ADObject aDObject in aDObjects)
            {
                var ldapDisplayName = aDObject["lDAPDisplayName"];
                if (ldapDisplayName != null)
                {
                    if (ldapDisplayName.Count > 0)
                    {
                        strs.Add((string)ldapDisplayName[0]);
                    }
                }
            }
            strs.Add("user");
            return(strs);
        }
コード例 #13
0
        private void AddSchemaClassObjects(ADObjectSearcher searcher, ADSchema adSchema)
        {
            searcher.SchemaTranslation = false;
            ADRootDSE rootDSE = searcher.GetRootDSE();

            searcher.SearchRoot = rootDSE.SchemaNamingContext;
            IADOPathNode aDOPathNode  = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
            IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.NotLike, "isDefunct", "*");

            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
            aDOPathNodeArray[0] = aDOPathNode;
            aDOPathNodeArray[1] = aDOPathNode1;
            searcher.Filter     = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
            searcher.Scope      = ADSearchScope.Subtree;
            searcher.PageSize   = 0x100;
            searcher.Properties.Clear();
            searcher.Properties.Add("lDAPDisplayName");
            searcher.Properties.Add("subClassOf");
            searcher.Properties.Add("systemMayContain");
            searcher.Properties.Add("mayContain");
            searcher.Properties.Add("mustContain");
            searcher.Properties.Add("systemMustContain");
            searcher.Properties.Add("auxiliaryClass");
            searcher.Properties.Add("systemAuxiliaryClass");
            IEnumerable <ADObject> aDObjects = searcher.FindAll();

            foreach (ADObject aDObject in aDObjects)
            {
                if (!aDObject.Contains("lDAPDisplayName") || aDObject["lDAPDisplayName"].Value == null)
                {
                    continue;
                }
                adSchema._schemaClasses.Add((string)aDObject["lDAPDisplayName"].Value, aDObject);
                adSchema._schemaClassesDnHash.Add((string)aDObject["distinguishedName"].Value, (string)aDObject["lDAPDisplayName"].Value);
            }
        }
コード例 #14
0
 static ADObjectSearcher()
 {
     ADObjectSearcher.AllProperties             = "*";
     ADObjectSearcher.DefaultSearchFilterString = "(objectClass=*)";
     ADObjectSearcher.DefaultSearchFilter       = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
 }
コード例 #15
0
        private int yyparse()
        {
            int num;
            int num2;

            this.init_stacks();
            this.yynerrs   = 0;
            this.yyerrflag = 0;
            this.yychar    = -1;
            int state = 0;

            this.state_push(state);
Label_0025:
            num = yydefred[state];
            if (num == 0)
            {
                if (this.yychar < 0)
                {
                    this.yychar = this.yylex();
                    if (this.yychar < 0)
                    {
                        this.yychar = 0;
                    }
                }
                num = yysindex[state];
                if (((num != 0) && ((num += this.yychar) >= 0)) && ((num <= YYTABLESIZE) && (yycheck[num] == this.yychar)))
                {
                    state = yytable[num];
                    this.state_push(state);
                    this.val_push(this.yylval);
                    this.yychar = -1;
                    if (this.yyerrflag > 0)
                    {
                        this.yyerrflag--;
                    }
                }
                else
                {
                    num = yyrindex[state];
                    if (((num != 0) && ((num += this.yychar) >= 0)) && ((num <= YYTABLESIZE) && (yycheck[num] == this.yychar)))
                    {
                        num = yytable[num];
                        goto Label_01D9;
                    }
                    if (this.yyerrflag == 0)
                    {
                        this.yyerror("syntax error");
                        this.yynerrs++;
                    }
                    if (this.yyerrflag < 3)
                    {
                        this.yyerrflag = 3;
                        while (true)
                        {
                            if (this.stateptr < 0)
                            {
                                goto Label_0849;
                            }
                            num = yysindex[this.state_peek(0)];
                            if (((num != 0) && ((num += YYERRCODE) >= 0)) && ((num <= YYTABLESIZE) && (yycheck[num] == YYERRCODE)))
                            {
                                if (this.stateptr < 0)
                                {
                                    goto Label_0849;
                                }
                                state = yytable[num];
                                this.state_push(state);
                                this.val_push(this.yylval);
                                goto Label_0025;
                            }
                            if (this.stateptr < 0)
                            {
                                goto Label_0849;
                            }
                            this.state_pop();
                            this.val_pop();
                        }
                    }
                    if (this.yychar == 0)
                    {
                        goto Label_0854;
                    }
                    this.yychar = -1;
                }
                goto Label_0025;
            }
Label_01D9:
            num2       = yylen[num];
            this.yyval = this.val_peek(num2 - 1);
            switch (num)
            {
            case 1:
                this._filterExprTree = null;
                break;

            case 2:
                this._filterExprTree = (IADOPathNode)this.val_peek(1);
                break;

            case 3:
                this.yyval = this.val_peek(0);
                break;

            case 4:
                this.yyval = new CompositeADOPathNode(ADOperator.And, new IADOPathNode[] { (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0) });
                break;

            case 5:
                this.yyval = new CompositeADOPathNode(ADOperator.Or, new IADOPathNode[] { (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0) });
                break;

            case 6:
                this.yyval = this.val_peek(1);
                break;

            case 7:
                this.yyval = new UnaryADOPathNode(ADOperator.Not, (IADOPathNode)this.val_peek(0));
                break;

            case 8:
                this.yyval = this.val_peek(1);
                break;

            case 9:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Eq, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 10:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Ne, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 11:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Gt, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 12:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Lt, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 13:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Ge, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 14:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Le, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 15:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Like, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 0x10:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.NotLike, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 0x11:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Approx, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 0x12:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Band, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 0x13:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.Bor, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 20:
                this.yyval = ADOPathUtil.CreateRelationalExpressionNode(ADOperator.RecursiveMatch, (IADOPathNode)this.val_peek(2), (IADOPathNode)this.val_peek(0), this._searchFilterConverter);
                break;

            case 0x15:
                this.yyval = this.val_peek(1);
                break;

            case 0x16:
                if (this.val_peek(0) != null)
                {
                    throw new ADFilterParsingException(this._query, "Operator Not supported: " + this.lexer.yytext(), this.pos + 1);
                }
                break;

            case 0x17:
                this.yyval = this.val_peek(0);
                break;

            case 0x18:
            {
                string data = this.lexer.yytext().Substring(1, this.lexer.yytext().Length - 2).Replace("''", "'");
                this.yyval = new TextDataADOPathNode(data);
                break;
            }

            case 0x19:
            {
                string str2 = this.lexer.yytext().Substring(1, this.lexer.yytext().Length - 2).Replace("`\"", "\"");
                this.yyval = new TextDataADOPathNode(str2);
                break;
            }

            case 0x1a:
                this.yyval = new NumberADOPathNode(this.lexer.yytext());
                break;

            case 0x1b:
                this.yyval = new NumberADOPathNode(this.lexer.yytext());
                break;

            case 0x1c:
                this.yyval = this.val_peek(0);
                break;

            case 0x1d:
                this.yyval = new PropertyADOPathNode(this.lexer.yytext());
                break;

            case 30:
            {
                string varNameStr = this.lexer.yytext().Substring(1);
                this.yyval = new VariableADOPathNode(varNameStr, new EvaluateVariableDelegate(this._varExpressionConverter.GetVariableExpressionValue));
                break;
            }

            case 0x1f:
            {
                string str4 = this.lexer.yytext();
                str4 = str4.Substring(2, str4.Length - 2);
                int index = str4.IndexOf("}");
                str4       = str4.Remove(index, 1);
                this.yyval = new VariableADOPathNode(str4, new EvaluateVariableDelegate(this._varExpressionConverter.GetVariableExpressionValue));
                break;
            }
            }
            this.state_drop(num2);
            state = this.state_peek(0);
            this.val_drop(num2);
            num2 = yylhs[num];
            if ((state == 0) && (num2 == 0))
            {
                state = YYFINAL;
                this.state_push(YYFINAL);
                this.val_push(this.yyval);
                if (this.yychar < 0)
                {
                    this.yychar = this.yylex();
                    if (this.yychar < 0)
                    {
                        this.yychar = 0;
                    }
                }
                if (this.yychar == 0)
                {
                    return(0);
                }
                goto Label_0025;
            }
            num = yygindex[num2];
            if (((num != 0) && ((num += state) >= 0)) && ((num <= YYTABLESIZE) && (yycheck[num] == state)))
            {
                state = yytable[num];
            }
            else
            {
                state = yydgoto[num2];
            }
            if (this.stateptr >= 0)
            {
                this.state_push(state);
                this.val_push(this.yyval);
                goto Label_0025;
            }
Label_0849:
            this.yyerror("yacc stack overflow");
Label_0854:
            return(1);
        }
コード例 #16
0
        string Microsoft.ActiveDirectory.Management.IADOPathNode.GetLdapFilterString()
        {
            ADOperator    aDOperator;
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag          = false;
            bool          flag1         = false;

            if (this._operator == ADOperator.Gt || this._operator == ADOperator.Lt || this._operator == ADOperator.Ne || this._operator == ADOperator.NotLike)
            {
                flag  = true;
                flag1 = true;
                ADOperator aDOperator1 = this._operator;
                if (aDOperator1 == ADOperator.Lt)
                {
                    aDOperator = ADOperator.Ge;
                    stringBuilder.Append("(");
                    if (flag)
                    {
                        stringBuilder.Append("!");
                    }
                    stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                    stringBuilder.Append(ADOPathUtil.GetLdapFilterString(aDOperator));
                    stringBuilder.Append(this._rightExpr.GetLdapFilterString());
                    stringBuilder.Append(")");
                    if (flag1)
                    {
                        stringBuilder.Insert(0, "(&");
                        stringBuilder.Append("(");
                        stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                        stringBuilder.Append("=*))");
                    }
                    return(stringBuilder.ToString());
                }
                else if (aDOperator1 == ADOperator.Gt)
                {
                    aDOperator = ADOperator.Le;
                    stringBuilder.Append("(");
                    if (flag)
                    {
                        stringBuilder.Append("!");
                    }
                    stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                    stringBuilder.Append(ADOPathUtil.GetLdapFilterString(aDOperator));
                    stringBuilder.Append(this._rightExpr.GetLdapFilterString());
                    stringBuilder.Append(")");
                    if (flag1)
                    {
                        stringBuilder.Insert(0, "(&");
                        stringBuilder.Append("(");
                        stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                        stringBuilder.Append("=*))");
                    }
                    return(stringBuilder.ToString());
                }
                else if (aDOperator1 == ADOperator.Approx || aDOperator1 == ADOperator.RecursiveMatch)
                {
                    throw new InvalidOperationException("Code flow should never come here");
                }
                else if (aDOperator1 == ADOperator.Ne)
                {
                    aDOperator = ADOperator.Eq;
                    stringBuilder.Append("(");
                    if (flag)
                    {
                        stringBuilder.Append("!");
                    }
                    stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                    stringBuilder.Append(ADOPathUtil.GetLdapFilterString(aDOperator));
                    stringBuilder.Append(this._rightExpr.GetLdapFilterString());
                    stringBuilder.Append(")");
                    if (flag1)
                    {
                        stringBuilder.Insert(0, "(&");
                        stringBuilder.Append("(");
                        stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                        stringBuilder.Append("=*))");
                    }
                    return(stringBuilder.ToString());
                }
                if (aDOperator1 != ADOperator.NotLike)
                {
                    throw new InvalidOperationException("Code flow should never come here");
                }
                aDOperator = ADOperator.Eq;
                string ldapFilterString = this._rightExpr.GetLdapFilterString();
                if (ADOPathUtil.IsValueAllAsterisk(ldapFilterString))
                {
                    flag1 = false;
                }
            }
            else
            {
                aDOperator = this._operator;
            }
            stringBuilder.Append("(");
            if (flag)
            {
                stringBuilder.Append("!");
            }
            stringBuilder.Append(this._leftExpr.GetLdapFilterString());
            stringBuilder.Append(ADOPathUtil.GetLdapFilterString(aDOperator));
            stringBuilder.Append(this._rightExpr.GetLdapFilterString());
            stringBuilder.Append(")");
            if (flag1)
            {
                stringBuilder.Insert(0, "(&");
                stringBuilder.Append("(");
                stringBuilder.Append(this._leftExpr.GetLdapFilterString());
                stringBuilder.Append("=*))");
            }
            return(stringBuilder.ToString());

            throw new InvalidOperationException("Code flow should never come here");
        }
コード例 #17
0
ファイル: ADOPathUtil.cs プロジェクト: modulexcite/pash-1
 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");
     }
 }
コード例 #18
0
 string Microsoft.ActiveDirectory.Management.IADOPathNode.GetLdapFilterString()
 {
     return(ADOPathUtil.LdapSearchEncodeString(this._data, this._encodeAsteriskChar));
 }