{"id":91648,"date":"2024-10-18T22:58:22","date_gmt":"2024-10-18T14:58:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/91648\/"},"modified":"2024-10-18T22:58:23","modified_gmt":"2024-10-18T14:58:23","slug":"ora-31225-dbms_ldap-%e7%84%a1%e6%95%88%e7%9a%84-ber_element-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/91648\/","title":{"rendered":"ORA-31225: DBMS_LDAP: \u7121\u6548\u7684 BER_ELEMENT ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"ora-31225-dbms_ldap-%e7%84%a1%e6%95%88%e7%9a%84-ber_element-oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86-TSqgoBnLUd\">ORA-31225: DBMS_LDAP: \u7121\u6548\u7684 BER_ELEMENT ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406<\/h1>\n<p>\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u9032\u884c LDAP\uff08\u8f15\u91cf\u7d1a\u76ee\u9304\u8a2a\u554f\u5354\u8b70\uff09\u64cd\u4f5c\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u932f\u8aa4\u4ee3\u78bc <code>ORA-31225<\/code>\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8868\u793a\u5728\u8655\u7406 LDAP \u8acb\u6c42\u6642\u51fa\u73fe\u4e86\u7121\u6548\u7684 BER\uff08\u57fa\u672c\u7de8\u78bc\u898f\u5247\uff09\u5143\u7d20\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u6b64\u932f\u8aa4\u7684\u539f\u56e0\u3001\u5f71\u97ff\u4ee5\u53ca\u5982\u4f55\u9032\u884c\u6545\u969c\u4fee\u5fa9\u3002<\/p>\n<h2 id=\"%e9%8c%af%e8%aa%a4%e5%8e%9f%e5%9b%a0%e5%88%86%e6%9e%90-TSqgoBnLUd\">\u932f\u8aa4\u539f\u56e0\u5206\u6790<\/h2>\n<p>\u932f\u8aa4 <code>ORA-31225<\/code> \u901a\u5e38\u51fa\u73fe\u5728\u4ee5\u4e0b\u5e7e\u7a2e\u60c5\u6cc1\u4e0b\uff1a<\/p>\n<ul>\n<li><strong>LDAP \u9023\u63a5\u554f\u984c\uff1a<\/strong>\u5982\u679c LDAP \u670d\u52d9\u5668\u7121\u6cd5\u6b63\u78ba\u9023\u63a5\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u7121\u6548\u7684 BER \u5143\u7d20\u932f\u8aa4\u3002<\/li>\n<li><strong>\u6578\u64da\u683c\u5f0f\u932f\u8aa4\uff1a<\/strong>\u7576\u50b3\u905e\u7d66 DBMS_LDAP \u7684\u6578\u64da\u683c\u5f0f\u4e0d\u6b63\u78ba\u6642\uff0c\u6703\u5f15\u767c\u6b64\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u50b3\u905e\u7684 DN\uff08\u5340\u5206\u540d\u7a31\uff09\u683c\u5f0f\u4e0d\u6b63\u78ba\u3002<\/li>\n<li><strong>LDAP \u670d\u52d9\u5668\u914d\u7f6e\u554f\u984c\uff1a<\/strong>\u5982\u679c LDAP \u670d\u52d9\u5668\u7684\u914d\u7f6e\u4e0d\u6b63\u78ba\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4 Oracle \u7121\u6cd5\u6b63\u78ba\u89e3\u6790\u8fd4\u56de\u7684\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%85%e9%9a%9c%e6%8e%92%e9%99%a4%e6%ad%a5%e9%a9%9f-TSqgoBnLUd\">\u6545\u969c\u6392\u9664\u6b65\u9a5f<\/h2>\n<p>\u70ba\u4e86\u4fee\u5fa9 <code>ORA-31225<\/code> \u932f\u8aa4\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\u6545\u969c\u6392\u9664\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5-ldap-%e9%80%a3%e6%8e%a5-TSqgoBnLUd\">1. \u6aa2\u67e5 LDAP \u9023\u63a5<\/h3>\n<p>\u9996\u5148\uff0c\u78ba\u4fdd Oracle \u6578\u64da\u5eab\u80fd\u5920\u6210\u529f\u9023\u63a5\u5230 LDAP \u670d\u52d9\u5668\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u78bc\u6aa2\u67e5\u9023\u63a5\uff1a<\/p>\n<pre><code>DECLARE\n    l_ldap_handle DBMS_LDAP.LDAP_HANDLE;\nBEGIN\n    l_ldap_handle := DBMS_LDAP.init('ldap.example.com', 389);\n    DBMS_OUTPUT.put_line('LDAP \u9023\u63a5\u6210\u529f');\n    DBMS_LDAP.unbind(l_ldap_handle);\nEXCEPTION\n    WHEN OTHERS THEN\n        DBMS_OUTPUT.put_line('LDAP \u9023\u63a5\u5931\u6557: ' || SQLERRM);\nEND;<\/code><\/pre>\n<h3 id=\"2-%e9%a9%97%e8%ad%89-dn-%e6%a0%bc%e5%bc%8f-TSqgoBnLUd\">2. \u9a57\u8b49 DN \u683c\u5f0f<\/h3>\n<p>\u78ba\u4fdd\u50b3\u905e\u7684 DN \u683c\u5f0f\u6b63\u78ba\u3002\u6b63\u78ba\u7684 DN \u61c9\u8a72\u9075\u5faa LDAP \u7684\u6a19\u6e96\u683c\u5f0f\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code>cn=John Doe,ou=users,dc=example,dc=com<\/code><\/pre>\n<p>\u5982\u679c DN \u683c\u5f0f\u4e0d\u6b63\u78ba\uff0c\u8acb\u9032\u884c\u76f8\u61c9\u7684\u4fee\u6b63\u3002<\/p>\n<h3 id=\"3-%e6%aa%a2%e6%9f%a5-ldap-%e6%9c%8d%e5%8b%99%e5%99%a8%e9%85%8d%e7%bd%ae-TSqgoBnLUd\">3. \u6aa2\u67e5 LDAP \u670d\u52d9\u5668\u914d\u7f6e<\/h3>\n<p>\u6aa2\u67e5 LDAP \u670d\u52d9\u5668\u7684\u914d\u7f6e\uff0c\u78ba\u4fdd\u5176\u80fd\u5920\u6b63\u78ba\u8655\u7406\u4f86\u81ea Oracle \u7684\u8acb\u6c42\u3002\u9019\u5305\u62ec\u6aa2\u67e5\u7528\u6236\u6b0a\u9650\u3001LDAP \u670d\u52d9\u5668\u7684\u65e5\u8a8c\u4ee5\u53ca\u4efb\u4f55\u53ef\u80fd\u7684\u9632\u706b\u7246\u8a2d\u7f6e\u3002<\/p>\n<h2 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a2%bc-TSqgoBnLUd\">\u793a\u4f8b\u4ee3\u78bc<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528 DBMS_LDAP \u9032\u884c LDAP \u67e5\u8a62\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>DECLARE\n    l_ldap_handle DBMS_LDAP.LDAP_HANDLE;\n    l_result      DBMS_LDAP.LDAP_MESSAGE;\n    l_dn          VARCHAR2(256) := 'cn=John Doe,ou=users,dc=example,dc=com';\nBEGIN\n    l_ldap_handle := DBMS_LDAP.init('ldap.example.com', 389);\n    DBMS_LDAP.simple_bind_s(l_ldap_handle, 'cn=admin,dc=example,dc=com', 'password');\n    l_result := DBMS_LDAP.search_s(l_ldap_handle, l_dn, DBMS_LDAP.SCOPE_SUBTREE, NULL, NULL, 0);\n    DBMS_OUTPUT.put_line('\u67e5\u8a62\u6210\u529f');\n    DBMS_LDAP.unbind(l_ldap_handle);\nEXCEPTION\n    WHEN OTHERS THEN\n        DBMS_OUTPUT.put_line('\u67e5\u8a62\u5931\u6557: ' || SQLERRM);\nEND;<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-TSqgoBnLUd\">\u7e3d\u7d50<\/h2>\n<p>\u932f\u8aa4 <code>ORA-31225<\/code> \u662f\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u9032\u884c LDAP \u64cd\u4f5c\u6642\u5e38\u898b\u7684\u554f\u984c\u3002\u901a\u904e\u6aa2\u67e5 LDAP \u9023\u63a5\u3001\u9a57\u8b49 DN \u683c\u5f0f\u4ee5\u53ca\u6aa2\u67e5 LDAP \u670d\u52d9\u5668\u914d\u7f6e\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u6392\u9664\u6545\u969c\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\u7684\u7528\u6236\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u96f2\u4f3a\u670d\u5668<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a ORA-31225 \u932f\u8aa4\uff0cDBMS_LDAP \u7121\u6548\u7684 BER_ELEMENT \u554f\u984c\uff0c\u63d0\u4f9b\u6545\u969c\u4fee\u5fa9\u548c\u9060\u7a0b\u8655\u7406\u6307\u5357\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-91648","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=91648"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91648\/revisions"}],"predecessor-version":[{"id":91649,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/91648\/revisions\/91649"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=91648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=91648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=91648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}