Skip to content
Peter Pang edited this page Jul 18, 2017 · 14 revisions

About 7 years history start from 2010 (https://landpyactivedirectory.codeplex.com/), which will help you to manage Active Directory easily! This library has been used in Lenovo, Tempursealy, Sony, BoostSolutions and other corporations. Enjoy it!

I have started my biz! http://fewbox.com (I am the architect in Lenovo and BoostSolutions and was senior engineer, function reviewer, scrum master in previous corporation and have rich experience so I think I can provide the useful product to our clients) FewBox Any suggestion please feel free to let me know(marketing@fewbox.com)! And you can also donate me. Thx a lot!

You can manage the Active Directory object with Active Record pattern, forget hundreds of the AD attribute names and AD attribute const values, forget all the details of the Active Directory just need to manage the AD with Object. And you can also use the code to generate the filter to get the AD object search result, all the code is clear and simple.

Note: With the "using" you will dispose the no management resource easily.

E.G: Update a user AD object.

using (var userObject = UserObject.FindOneByCN(this.ADOperator, “pangxiaoliang”))``
{
     if(userObject.Email == "example@landpy.com")``
     {
          userObject.Email = "marketing@fewbox.com";``
          userObject.Save();``
     }
}

E.G: Query user AD objects.

// 1. CN end with "liu", Mail conatains "live" (Eg: marketing@fewbox.com), job title is "Dev" and AD object type is user.
// 2. CN start with "pang", Mail conatains "live" (Eg: marketing@fewbox.com), 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")
                        )
                    );
// Output the user object display name.
foreach (var userObject in UserObject.FindAll(this.ADOperator, filter))
{
    using (userObject)
    {
        Console.WriteLine(userObject.DisplayName);
    }
}

E.G: Custom query.

IFilter filter =
    new And(
        new IsUser(),
        new Custom("(!userAccountControl:1.2.840.113556.1.4.803:=2)")
        );
// Output the user object display name.
foreach (var userObject in UserObject.FindAll(this.ADOperator, filter))
{
    using (userObject)
    {
        Console.WriteLine(userObject.DisplayName);
    }
}

Native filter syntax please visit: http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx & http://msdn.microsoft.com/en-us/library/windows/desktop/aa746475(v=vs.85).aspx

Clone this wiki locally