Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

APEX 4.0, integration with LDAP using SamAccountname

Posted on 2011-02-15
3
Medium Priority
?
2,096 Views
Last Modified: 2013-12-24
I'm not able to easily use LDAP because our SAMAccountnames are our login id's and "CU=first last".  We wrote the following procedure in Oracle 11g, and called it within LDAP UserName edit function (return ldap_test_wayne).  

create or replace
FUNCTION LDAP_TEST_WAYNE ( p_username IN VARCHAR2)
RETURN varchar2 IS
   --p_username     VARCHAR2(256) := 'samAccountname=WAYNEL';
   l_ldap_host    VARCHAR2(256) := 'hnadm.housing.ufl.edu';
   l_ldap_port    VARCHAR2(256) := '389';
   l_ldap_user    VARCHAR2(256) := '';
   l_ldap_passwd  VARCHAR2(256) := 'uvNtVT1mJq';
   l_ldap_base    VARCHAR2(256) := 'OU=Housing,DC=housing,DC=ufl,DC=edu';
   l_dn           VARCHAR2(256) := 'CN=RadiusUser LDAP,OU=Service Accounts,OU=Housing,DC=housing,DC=ufl,DC=edu';
 
   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
   l_attrs(1) := 'cn';
 -- 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_dn,
                                      passwd => l_ldap_passwd);

  -- Get all attributes
  -- retrieve all attributes
  l_retval := DBMS_LDAP.search_s(ld       => l_session,
                                 base     => l_ldap_base,
                                 scope    => DBMS_LDAP.SCOPE_SUBTREE,
                                 filter   => p_username,
                                 attrs    => l_attrs,
                                 attronly => 0,
                                 res      => l_message);
                                 
                                 
                                 
  IF DBMS_LDAP.count_entries(ld => l_session, msg => l_message) > 0 THEN
    -- Get all the entries returned by our search.
    l_entry := DBMS_LDAP.first_entry(ld  => l_session,
                                     msg => l_message);

    << entry_loop >>
    WHILE l_entry IS NOT NULL LOOP
      -- Get all the attributes for this entry.
      DBMS_OUTPUT.PUT_LINE('---------------------------------------');
      l_attr_name := DBMS_LDAP.first_attribute(ld        => l_session,
                                               ldapentry => l_entry,
                                               ber_elem  => l_ber_element);
      << attributes_loop >>
      WHILE l_attr_name IS NOT NULL LOOP
        -- Get all the values for this attribute.
        l_vals := DBMS_LDAP.get_values (ld        => l_session,
                                        ldapentry => l_entry,
                                        attr      => l_attr_name);
        << values_loop >>
        FOR i IN l_vals.FIRST .. l_vals.LAST LOOP
          DBMS_OUTPUT.PUT_LINE('ATTIBUTE_NAME: ' || l_attr_name || ' = ' || SUBSTR(l_vals(i),1,200));
          IF l_attr_name = 'cn' then
            l_ldap_user := SUBSTR(l_vals(i),1,200);
          END IF;
        END LOOP values_loop;
        l_attr_name := DBMS_LDAP.next_attribute(ld        => l_session,
                                                ldapentry => l_entry,
                                                ber_elem  => l_ber_element);
      END LOOP attibutes_loop;
      l_entry := DBMS_LDAP.next_entry(ld  => l_session,
                                      msg => l_entry);
    END LOOP entry_loop;
  END IF;
 
  -- Disconnect from the LDAP server.
  l_retval := DBMS_LDAP.unbind_s(ld => l_session);
  DBMS_OUTPUT.PUT_LINE('Unbind return value : ' || l_retval);
--  l_attrs(1) := '*';
 DBMS_OUTPUT.PUT_LINE('Using username : ' || l_ldap_user);
 
 return l_ldap_user;
END LDAP_TEST_WAYNE;

There must be an easier way... and we haven't gotten it to work at this point.

-HELP
0
Comment
Question by:WayneGro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
WayneGro earned 0 total points
ID: 34906397
New to forum, trying to learn system for asking questions, making point value 500.
0
 
LVL 3

Assisted Solution

by:gopisera
gopisera earned 80 total points
ID: 34933361
You want LDAP integration with the APEX...

Then very easy then connect to the application under the shared components select the authentication schema as ldap.

You have to provide the ldap sever and port number and dns string.  There is a test tool is also available which will help you in it.

if you require more on it contact me on ramesh.g2005@gmail.com

Will provide you more information
0
 

Author Closing Comment

by:WayneGro
ID: 34990889
this is the basic answer for connecting to LDAP but wont help when connecting with Samaccountname.  So this doesn't really answer anything.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 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