How to end ldap session in pl/sql for users stored in a user table

Posted on 2009-02-23
Last Modified: 2013-12-24
Using dbms_ldap in pl/sql code, I would like to be able to loop through a user table, and for each user found, drop their session.  How can this be done? Very new to dbms_ldap package functions, so please be specific.
Question by:mirabai23
    LVL 28

    Accepted Solution

    i can get the below for you from oracle documentation...

    Terminating the Session by Using DBMS_LDAP
    Once an LDAP session handle is obtained and all of the desired LDAP-related work is complete, the LDAP session must be destroyed. This is accomplished through a call to DBMS_LDAP.unbind_s(). The function unbind_s has the following syntax:


    A successful call to unbind_s closes the TCP/IP connection to the LDAP server, de-allocates all system resources consumed by the LDAP session, and returns the integer DBMS_LDAP.SUCCESS to its callers. Once the unbind_s function is invoked on a particular session, no other LDAP operations on that session can succeed unless the session is re-initialized with a call to init.

    I guess you have to use that function basically to drop the ldap session found for those users. I mean open a cursor to loop through that table and call dbms_ldap.unbind_s(...) accordingly and test it out.

    LVL 3

    Assisted Solution

    You'll need to know what the original session id is and use that in the call.  For example, a typical function used to authenticate a user in LDAP would look like this:

    FUNCTION authenticate (
      p_uid VARCHAR2,
      p_password VARCHAR2)
      g_session dbms_ldap.session;
      v_ret_val PLS_INTEGER;
      v_result  PLS_INTEGER;
      g_session := dbms_ldap.init(C_LDAP_HOST,C_LDAP_PORT);
      v_ret_val := dbms_ldap.simple_bind_s  
      v_result := v_ret_val;
      v_ret_val := dbms_ldap.unbind_s(g_session);
        v_ret_val := dbms_ldap.unbind_s(g_session);
    END authenticate;

    So hopefully you have access to enough information to know which LDAP session to terminate.

    Author Comment

    garysadler - thanks for the detail - i am currently trying this out.  I will respond again when I have more info to share. but you're right, the issue I had was being able to pass in the session to 'unbind'!

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment is a cloud-based customer relationship management (CRM) system. In this article, you will learn how to add and map custom lead and contact fields to your Salesforce instance.
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
    This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now