{"id":708,"date":"2012-01-27T07:53:39","date_gmt":"2012-01-27T05:53:39","guid":{"rendered":"http:\/\/hen.co.za\/blog\/?p=708"},"modified":"2012-01-27T07:53:39","modified_gmt":"2012-01-27T05:53:39","slug":"directorysearcher-and-filters-to-search-ad","status":"publish","type":"post","link":"https:\/\/hen.co.za\/blog\/2012\/01\/directorysearcher-and-filters-to-search-ad\/","title":{"rendered":"DirectorySearcher and filters to search AD"},"content":{"rendered":"<p>If you want to do a query against AD (active directory) there are several ways to do it &#8211; but (only) one proper way like usual.<\/p>\n<p>The DirectorySearcher class has a &#8216;filter&#8217; property that allows you to filter the returned results &#8211; oppose to you having to test each property in code. The syntax of this filter is a bit tricky (ok a lot&#8230;)<\/p>\n<p>It took me a while to figure out how to properly set up a filter to do more complex queries &#8211; like when you have multiple things to filter by including &#8216;and&#8217;s and &#8216;or&#8217;s. Anyway, I found a good reference here: <a title=\"Search filter syntax\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa746475%28v=vs.85%29.aspx\" target=\"_blank\">Search Filter Syntax<\/a>.<\/p>\n<p>It explains the syntax plus give some examples. It also list some special characters plus explain how to use &#8216;wildcards&#8217;.<\/p>\n<p>Happy searching&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to do a query against AD (active directory) there are several ways to do it &#8211; but (only) one proper way like usual. The DirectorySearcher class has a &#8216;filter&#8217; property that allows you to filter the returned &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/hen.co.za\/blog\/2012\/01\/directorysearcher-and-filters-to-search-ad\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,16],"tags":[27,118,303,122,121,119,120],"class_list":["post-708","post","type-post","status-publish","format-standard","hentry","category-development","category-reference","tag-active-directory","tag-ad","tag-development","tag-directorysearcher","tag-filter","tag-ldap","tag-query"],"_links":{"self":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/comments?post=708"}],"version-history":[{"count":2,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/708\/revisions"}],"predecessor-version":[{"id":710,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/708\/revisions\/710"}],"wp:attachment":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/media?parent=708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/categories?post=708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/tags?post=708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}