{"id":389,"date":"2009-08-05T11:28:58","date_gmt":"2009-08-05T03:28:58","guid":{"rendered":"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/?p=389"},"modified":"2009-08-06T15:15:05","modified_gmt":"2009-08-06T07:15:05","slug":"writing-ldap-search-filter","status":"publish","type":"post","link":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/?p=389","title":{"rendered":"Writing LDAP search filter"},"content":{"rendered":"<p>LDAP search filter is useful in Apache LDAP authentication and Ironport.<\/p>\n<p>Under Ironport, I use the below filter to search for valid user with his aliase :<\/p>\n<p>(|(uid={u})(cn={u}))<\/p>\n<p>I use the below to search if an user\/alias is in a specific posix group :<\/p>\n<p>(&amp;(cn={g})(memberUid={u}))<\/p>\n<p>Under OpenLDAP, to search a user :<\/p>\n<p>ldapsearch -x -b &#8216;dc=xxx,dc=yyy,dc=edu,dc=hk&#8217; &#8216;(&amp;(objectClass=*)(uid=test))&#8217;<\/p>\n<p>A bit of search filter syntax :<\/p>\n<h4>match more than one attribute?<\/h4>\n<pre>(&amp;(objectClass=person)(objectClass=user))\r\n<pre>\r\n<pre>(|(objectClass=person)(objectClass=user))<\/pre>\n<p>(&amp;(objectClass=user)(cn=*Marketing*))<br \/>\nHow do I match 3 attributes?<\/p>\n<pre>\r\n<strong>(&amp;(<\/strong><em>&amp;(objectClass=user)(objectClass=top)<\/em><strong>)(objectClass=person))<\/strong>\r\n\r\nNotice how we weave one query into another. For 4 attributes, this would be:\r\n\r\n<span style=\"color: red;\">&amp;(<\/span><span style=\"color: blue;\">&amp;(<\/span><span style=\"color: green;\">&amp;(objectClass=top)(objectClass=person)<\/span><span style=\"color: blue;\">)(objectClass=organizationalPerson)<\/span><span style=\"color: red;\">)(objectClass=user)<\/span>)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>LDAP search filter is useful in Apache LDAP authentication and Ironport.<\/p>\n<p>Under Ironport, I use the below filter to search for valid user with his aliase :<\/p>\n<p>(|(uid={u})(cn={u}))<\/p>\n<p>I use the below to search if an user\/alias is in a specific posix group :<\/p>\n<p>(&amp;(cn={g})(memberUid={u}))<\/p>\n<p>Under OpenLDAP, to search a user :<\/p>\n<p>ldapsearch -x -b [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[3],"tags":[12,19,112],"class_list":["post-389","post","type-post","status-publish","format-standard","hentry","category-computer","tag-ironport","tag-ldap","tag-computer","odd"],"_links":{"self":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=389"}],"version-history":[{"count":9,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/389\/revisions"}],"predecessor-version":[{"id":391,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/389\/revisions\/391"}],"wp:attachment":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}