Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2009-02-23
7
Medium Priority
?
680 Views
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.
0
Comment
Question by:mirabai23
3 Comments
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 252 total points
ID: 23718982
i can get the below for you from oracle documentation...

http://download-west.oracle.com/docs/cd/B10464_05/manage.904/b10461/concepts.htm#728681

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:

FUNCTION unbind_s (ld IN SESSION )  RETURN PLS_INTEGER;

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.

0
 
LVL 3

Assisted Solution

by:garysadler
garysadler earned 252 total points
ID: 23723107
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)
  RETURN     PLS_INTEGER
AS
  g_session dbms_ldap.session;
  v_ret_val PLS_INTEGER;
  v_result  PLS_INTEGER;
BEGIN
  g_session := dbms_ldap.init(C_LDAP_HOST,C_LDAP_PORT);
  v_ret_val := dbms_ldap.simple_bind_s  
     (g_session,'uid='||p_uid||','||C_LDAP_ORG||','||C_LDAP_BASE,p_password);
  v_result := v_ret_val;
  v_ret_val := dbms_ldap.unbind_s(g_session);
  RETURN(v_result);
EXCEPTION
  WHEN OTHERS THEN
    v_ret_val := dbms_ldap.unbind_s(g_session);
    RETURN(v_result);
END authenticate;

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

Author Comment

by:mirabai23
ID: 23808062
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'!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Via a live example, show how to take different types of Oracle backups using RMAN.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

580 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