示例#1
0
        public void TestComplexFilter()
        {
            // 1. CN end with "liu", Mail conatains "live" (Eg: [email protected]), job title is "Dev" and AD object type is user.
            // 2. CN start with "pang", Mail conatains "live" (Eg: [email protected]), job title is "Dev" and AD object type is user.
            IFilter filter =
                new And(
                    new IsUser(),
                    new Contains(PersonAttributeNames.Mail, "live"),
                    new Is(PersonAttributeNames.Title, "Dev"),
                    new Or(
                        new StartWith(AttributeNames.CN, "pang"),
                        new EndWith(AttributeNames.CN, "liu")
                        )
                    );

            Assert.AreEqual(this.ComplexFilterString, filter.BuildFilter());
            // Output the user object display name.
            foreach (var userObject in UserObject.FindAll(this.ADOperator, filter))
            {
                using (userObject)
                {
                    Console.WriteLine(@"{0}-{1}", userObject.DisplayName, userObject.Email);
                }
            }
        }
示例#2
0
        public void TestSimpleAndFilter()
        {
            IFilter filter = new And(new IsOU(), new IsUser());

            Assert.AreEqual(this.AndFilterString, filter.BuildFilter());
        }