View Single Post
  #4 (permalink)  
Old November 5th, 2004, 05:02 AM
chensoft chensoft is offline
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chensoft
Default

Hello,I can use LDAP control user account log on,

CREATE OR REPLACE FUNCTION Checkcred (username VARCHAR2, passwd VARCHAR2)
RETURN PLS_INTEGER
AS
  hr_session dbms_ldap.SESSION;
  retval PLS_INTEGER;
  unbind PLS_INTEGER;
  userdn VARCHAR2(256);
  userpasswd VARCHAR2(256);

BEGIN

  IF passwd IS NULL THEN
    RETURN 1;
  END IF;

  retval := 10;
  DBMS_LDAP.USE_EXCEPTION := TRUE;
----LDAP Server IP,Port
  hr_session := dbms_ldap.init('10.1.6.20','389');

  userdn := 'uid=' || username || ',ou=sinomosaccounts,ou=people,dc=sinomos,dc=com';

  retval := DBMS_LDAP.simple_bind_s(hr_session,userdn,passwd);
  unbind := dbms_ldap.unbind_s(hr_session);
  RETURN retval;
EXCEPTION
  WHEN OTHERS THEN

   DBMS_OUTPUT.PUT_LINE(' Error code : ' || TO_CHAR(SQLCODE));
   DBMS_OUTPUT.PUT_LINE(' Error Message : ' || SQLERRM);
   RETURN 1;
END Checkcred;
/