{"id":212,"date":"2007-06-22T15:46:15","date_gmt":"2007-06-22T07:46:15","guid":{"rendered":"http:\/\/j178.mtgbb.com\/125"},"modified":"2007-06-22T15:46:15","modified_gmt":"2007-06-22T07:46:15","slug":"ldap-%e9%80%a3%e7%b7%9a%e7%af%84%e4%be%8b","status":"publish","type":"post","link":"https:\/\/j178.mtgbb.com\/?p=212","title":{"rendered":"LDAP \u9023\u7dda\u7bc4\u4f8b"},"content":{"rendered":"<p>\u5728 linux \u4e0a\u7528 LDAP \u9023\u63a5 Windows 2003 \u7684 AD \u7684\u7bc4\u4f8b\u7a0b\u5f0f<br \/>\n\u91cd\u9ede 1. \u6ce8\u610f\u9023\u63a5\u7684 Port, Windows \u7684 LDAP \u8acb\u8d70 port 3268<br \/>\n\u91cd\u9ede 2. \u9023\u7dda\u767b\u5165\u6642\u8acb\u8f38\u5165\u5b8c\u6574\u7684 filter string \u4f5c\u70ba\u5e33\u865f,<br \/>\nex. ad_access_account@your_org<br \/>\nor<br \/>\nCN=Guest,OU=IT-Test,OU=CompanyMember,DC=Company,DC=local<\/p>\n<pre lang=\"php\" line=\"1\"> \n< ?php\n\/\/ \u672c\u4f8b\u4f7f\u7528\u5230 connect, bind, search, interpret search\n\/\/ result, close connection \u7b49\u7b49 LDAP \u7684\u529f\u80fd\u3002\n\necho \"<h3>LDAP \u641c\u5c0b\u6e2c\u8a66\";\necho \"\u9023\u7dda\u4e2d ...\";\n\n\/\/ \u5148\u9023\u4e0a\u6709\u6548\u7684 LDAP \u4f3a\u670d\u5668\n$ds=ldap_connect(\"192.168.xxx.xxx\",3268)or die(\"Could not connect\");\n\necho \"\u9023\u4e0a \".$ds.\"<p>\";\n\nif ($ds) {\necho \"Binding ... \";\n$r=ldap_bind($ds,\"ad_access_account@your_org\",\"your_password\");\n\nif ($r) { echo \"Bind Successful!\";\necho \"Bind result is \" . $r . \"<br \/>\";\n}\n\nelse echo \"Bind Failure!\";\n\necho \"Searching for (OU=2140-IT) ...\";\n\n\/\/ Search surname entry\n$sr=ldap_search($ds, \"DC=company,DC=local\", \"CN=search_someone_account\");\n\nif ($sr)\n{ echo \"Search result is \" . $sr . \"<br \/>\";\necho \"Number of entires returned is \" . ldap_count_entries($ds, $sr) . \"<br \/>\";\n}\n\nelse echo \"Search fail <br \/>\";\necho \"Getting entries ...<\/p><p>\";\n$info = ldap_get_entries($ds, $sr);\necho \"Data for \" . $info[\"count\"] . \" items returned:<\/p><p>\";\n\nfor ($i=0; $i< $info[\"count\"]; $i++) {\necho \"dn is: \" . $info[$i][\"dn\"] . \"<br \/>\";\necho \"first cn entry is: \" . $info[$i][\"cn\"][0] . \"<br \/>\";\necho \"first email entry is: \" . $info[$i][\"mail\"][0] . \"<br \/><hr \/>\";\n}\n\necho \"Closing connection\";\nldap_close($ds);\n} else {\necho \"<h4>\u7121\u6cd5\u9023\u63a5\u5230 LDAP \u4f3a\u670d\u5668<\/h4>\";\n}\n?>\n<\/p><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 linux \u4e0a\u7528 LDAP \u9023\u63a5 Windows 2003 \u7684 AD \u7684\u7bc4\u4f8b\u7a0b\u5f0f \u91cd\u9ede 1. \u6ce8\u610f\u9023\u63a5\u7684  &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":0,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"wp:attachment":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}