------- cut here -------
DECLARE
 retval       PLS_INTEGER;
 my_session   DBMS_LDAP.session;
 ldap_host    VARCHAR2(256);
 ldap_port    VARCHAR2(256);
 ldap_user    VARCHAR2(256);
 ldap_passwd  VARCHAR2(256);
 userDN       VARCHAR2(256);
 newpwd       VARCHAR2(256);
 newmail      VARCHAR2(256);
 my_mod       DBMS_LDAP.MOD_ARRAY;
 my_values    DBMS_LDAP.STRING_COLLECTION;
BEGIN retval     := -1;
 ldap_host  := 'mlc2.acme.org';
 ldap_port  := '3060';
 ldap_user  := 'cn=orcladmin';
 ldap_passwd:= 'welcome1';
 userDN     := 'cn=tigger,cn=users,dc=acme,dc=org';
 newpwd     := 'welcome1';
 newmail    := '[email protected]'; DBMS_OUTPUT.PUT_LINE(RPAD('LDAP Host ',25,' ') || ': ' || ldap_host);
 DBMS_OUTPUT.PUT_LINE(RPAD('LDAP Port ',25,' ') || ': ' || ldap_port); DBMS_LDAP.USE_EXCEPTION := TRUE; my_session := DBMS_LDAP.init(ldap_host,ldap_port);
 DBMS_OUTPUT.PUT_LINE (RPAD('Ldap session ',25,' ')  || ': ' ||
     RAWTOHEX(SUBSTR(my_session,1,8)) || '(returned from init)'); retval := DBMS_LDAP.simple_bind_s(my_session, ldap_user,ldap_passwd);
 DBMS_OUTPUT.PUT_LINE(RPAD('simple_bind_s Returns ',25,' ') || ': ' || TO_CHAR(retval)); my_mod := DBMS_LDAP.create_mod_array(2);
 my_values(1) := newpwd;
 DBMS_LDAP.populate_mod_array(my_mod, DBMS_LDAP.MOD_REPLACE, 'userpassword', my_values);-- Repeat the below lines multiple times to modify several attributes
-- at the same time. Just set the my_values(1) to the new value and change the 3rd
-- parameter of the populate_mod_array to the name of the attribute to modify.
 my_values(1) := newmail;
 DBMS_LDAP.populate_mod_array(my_mod, DBMS_LDAP.MOD_REPLACE, 'mail', my_values); retval := DBMS_LDAP.modify_s(my_session, userDN, my_mod);
 DBMS_OUTPUT.PUT_LINE(RPAD('modify_s Returns ',25,' ') || ': ' || TO_CHAR(retval)); DBMS_LDAP.free_mod_array(my_mod); retval := DBMS_LDAP.unbind_s(my_session);
 DBMS_OUTPUT.PUT_LINE(RPAD('unbind_res Returns ',25,' ') ||  ': ' || TO_CHAR(retval)); DBMS_OUTPUT.PUT_LINE('Directory operation Successful .. exiting'); -- Handle Exceptions
 EXCEPTION
  WHEN OTHERS THEN   DBMS_OUTPUT.PUT_LINE(' Error code    : ' || TO_CHAR(SQLCODE));
   DBMS_OUTPUT.PUT_LINE(' Error Message : ' || SQLERRM);
   DBMS_OUTPUT.PUT_LINE(' Exception encountered .. exiting');END;
/

解决方案 »

  1.   

    你可以找一些ldap的相关资料来学习一下
      

  2.   

    有没有谁会的给我解释一下 啊!特别是  populate_mod_array  这个过程怎么用啊 
      

  3.   

    http://www.lc.leidenuniv.nl/awcourse/oracle/network.920/a96577/dbmsldap.htm#1012112
      

  4.   

    PROCEDURE populate_mod_array
    (
    modptr   IN DBMS_LDAP.MOD_ARRAY,
    mod_op   IN PLS_INTEGER,
    mod_type IN VARCHAR2,
    modval   IN DBMS_LDAP.STRING_COLLECTION);
    //
    modptr    The data structure holds a pointer to an LDAP mod array.mod_op    This field specifies the type of modification to perform.mod_type  This field indicates the name of the attribute type to which the modification applies.modval    This field specifies the attribute values to add, delete, or replace. It is for the string values only.
      

  5.   

    修改节点"cn=tigger,cn=users,dc=acme,dc=o"的userpassword和newmail属性.
    DBMS_LDAP.populate_mod_array(my_mod, DBMS_LDAP.MOD_REPLACE, 'mail', my_values);
    my_mod存储的对ldap的操作,如上面这句话的意思是"对mail属性使用my_values的值做替换操作",因为ldap的属性值可以是数组,所以是DBMS_LDAP.STRING_COLLECTION类型,然后同样对userpassword属性也是类似操作,最后
    retval := DBMS_LDAP.modify_s(my_session, userDN, my_mod);
    在节点userDN上执行my_mod中的操作
      

  6.   

    高手,不过我还是不怎么明白   下面几个问题帮我解释下好吗
    'cn=tigger,cn=users,dc=acme,dc=org'   什么意思
     retval := DBMS_LDAP.modify_s(my_session, userDN, my_mod);  什么意思
    my_mod := DBMS_LDAP.create_mod_array(2);   什么意思
      

  7.   

    整段程序的意思是不是就是对用户的密码和EMAIL 做一个修改啊!