Example #1
0
        public void Compound_Element_And_Using_Individual_Strings()
        {
            // Arrange
            var expected = "(&(sn=Jensen)(cn=Babs J*))";

            // Act
            var filter = new LdapFilter("cn=Babs J*").And("sn", "=", "Jensen");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #2
0
        public void Single_Element_Filter_Using_Wildcard()
        {
            // Arrange
            var expected = "(cn=*)";

            // Act
            var filter = new LdapFilter("cn", "=", LdapFilter.Any);

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #3
0
        public void Compound_Element_And_Append_Using_Single_String()
        {
            // Arrange
            var expected = "(&(cn=Babs J*)(sn=Jensen))";

            // Act
            var filter = new LdapFilter("cn=Babs J*").And("sn=Jensen", true);

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #4
0
        public void Single_Element_Filter_With_Parenthesis()
        {
            // Arrange
            var expected = "(cn=Babs Jensen)";

            // Act
            var filter = new LdapFilter("(cn=Babs Jensen)");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #5
0
        public void Single_Element_Filter_Using_Individual_Strings()
        {
            // Arrange
            var expected = "(cn=Babs Jensen)";

            // Act
            var filter = new LdapFilter("cn", "=", "Babs Jensen");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #6
0
        public void Single_Element_Filter_Using_Less_Filter_Type()
        {
            // Arrange
            var expected = "(cn<=Babs Jensen)";

            // Act
            var filter = new LdapFilter("cn", LdapFilter.Less, "Babs Jensen");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #7
0
        public void Single_Element_Filter_Not()
        {
            // Arrange
            var expected = "(!samaccountname=*$)";

            // Act
            var filter = new LdapFilter("samaccountname=*$").Not();

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #8
0
        public void Compound_Element_Or_Using_Single_String()
        {
            // Arrange
            var expected = "(|(sn=Jensen)(cn=Babs J*))";

            // Act
            var filter = new LdapFilter("cn=Babs J*").Or("sn=Jensen");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #9
0
        public void Bitwise_Filter_Must_Be_A_Embedded_Filter_When_Not_Is_Used()
        {
            // Arrange
            var expected = "(!(UserAccountControl:1.2.840.113556.1.4.803:=65536))";

            // Act
            var filter = new LdapFilter("UserAccountControl:1.2.840.113556.1.4.803:=65536").Not();

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #10
0
        public void Z_Complex_3()
        {
            // Arrange
            var expected = "(&(objectClass=organizationalUnit)(|(ou:dn:=Domain Controllers)(ou:dn:=Computers)))";

            // Act
            var filter = new LdapFilter("ou:dn:=Computers")
                         .Or("ou:dn:=Domain Controllers")
                         .And("objectClass=organizationalUnit");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #11
0
        public void Complex_Filter_1()
        {
            // Arrange
            var expected = "(&(objectClass=Person)(|(sn=Jensen)(cn=Babs J*)))";

            // Act
            var filter = new LdapFilter("cn=Babs J*")
                         .Or("sn=Jensen")
                         .And("objectClass=Person");

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #12
0
        public void Compound_Element_Or_Append_Using_LdapFilter()
        {
            // Arrange
            var expected = "(|(cn=Babs J*)(sn=Jensen))";

            var filter1 = new LdapFilter("sn=Jensen");

            // Act
            var filter = new LdapFilter("cn=Babs J*").Or(filter1, true);

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #13
0
        public void Compound_Element_Not()
        {
            // Arrange
            var expected = "(!(|(cn=Tim Howes)(cn=Julian Easterling)))";

            // Act
            var filter = new LdapFilter("cn=Julian Easterling")
                         .Or("cn=Tim Howes")
                         .Not();

            // Assert
            Assert.Equal(expected, filter.ToString());
        }
Example #14
0
        public void Compound_Element_And_Using_Single_String()
        {
            // Arrange

            // Act

            // Assert
            var expected = "(&(sn=Jensen)(cn=Babs J*))";

            var filter = new LdapFilter("cn=Babs J*").And("sn=Jensen");

            Assert.Equal(expected, filter.ToString());
        }