DECLARE
  l_ldap_host    VARCHAR2(256) := ‘mail.emailserver.com’;
  l_ldap_port    VARCHAR2(256) := ‘389’;
  l_ldap_user    VARCHAR2(256) := ‘uid=user,ou=people,dc=domainname,dc=com’;
  l_ldap_passwd  VARCHAR2(256) := ‘password‘;
  l_retval       PLS_INTEGER;
  l_session      DBMS_LDAP.session;
  l_attrs        DBMS_LDAP.string_collection;
  l_message      DBMS_LDAP.message;
  l_entry        DBMS_LDAP.message;
  l_attr_name    VARCHAR2(256);
  l_ber_element  DBMS_LDAP.ber_element;
  l_vals         DBMS_LDAP.string_collection;
BEGIN
  — Choose to raise exceptions.
  DBMS_LDAP.USE_EXCEPTION := TRUE;
  — Connect to the LDAP server.
  l_session := DBMS_LDAP.init(hostname => l_ldap_host,
                              portnum  => l_ldap_port);
  l_retval := DBMS_LDAP.simple_bind_s(ld     => l_session,
                                      dn     => l_ldap_user,
                                      passwd => l_ldap_passwd);
  DBMS_OUTPUT.PUT_LINE(‘bind:L_RETVAL: ‘ || l_retval);
  l_retval := DBMS_LDAP.unbind_s(ld => l_session);
  DBMS_OUTPUT.PUT_LINE(‘unbind:L_RETVAL: ‘ || l_retval);
end;

— replace user with email id without domain name, password with email password