protected override Expression VisitBinary(BinaryExpression node)
        {
            Expression result = base.VisitBinary(node);

            node = result as BinaryExpression;
            if (node == null)
            {
                return(result);
            }

            switch (node.NodeType)
            {
            case ExpressionType.Equal:
                if (node.Right.IsConstantNullOrEmpty())
                {
                    return(Expression.Not(LdapExpressionFactory.Present(node.Left)));
                }
                if (node.Right.NodeType == (ExpressionType)LdapExpressionType.Substring)
                {
                    SubstringExpression substring = node.Right as SubstringExpression;

                    /* If it's a substring expression with no parts to it, it's of one of the following forms:
                     * X=*.  X=*.*  X=.*  X=.
                     * (where the dot represents the empty parts list).
                     * In the first three cases, this translates to Present(X) expression;
                     * in the last one, to Not(Present(X)).  */
                    if (substring.Parts.Count == 0)
                    {
                        if (substring.WildcardAtStart || substring.WildcardAtEnd)
                        {
                            return(LdapExpressionFactory.Present(node.Left));
                        }
                        else
                        {
                            return(Expression.Not(LdapExpressionFactory.Present(node.Left)));
                        }
                    }
                }
                break;
            }

            return(node);
        }
        protected override Expression VisitBinary(BinaryExpression node)
        {
            Expression left  = this.Visit(node.Left);
            Expression right = this.Visit(node.Right);

            if (node.NodeType == ExpressionType.Equal &&
                left.NodeType == (ExpressionType)LdapExpressionType.Attribute &&
                right.NodeType == ExpressionType.Constant
                )
            {
                ConstantExpression constant = (ConstantExpression)right;
                if (constant.Value == null)
                {
                    return(Expression.Not(LdapExpressionFactory.Present(left)));
                }
            }

            return(node.Update(left, node.Conversion, right));
        }