日期:2014-05-17  浏览次数:20879 次

谁帮我解释下这段代码
-------   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         :=   'myaddr@oracle.com ';

  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, '   ')   ||   ':   '