Шустрый

Профиль
Группа: Участник
Сообщений: 131
Регистрация: 26.10.2005
Репутация: нет Всего: 2
|
Привет всем. При работе с LDAP получаю такую ошибку Код | ORA-03113: end-of-file on communication channel
|
Фильтр поиска в LDAP такой: Код | search_filter := '(&(objectclass=person)(uid=*)(mail=*))';
|
Самое смешное что раньше все работало и хорошо все считывалось. Есть подозрение что у некоторых людей отсутсвует мыло. Хотя эта ошибка может означать все что угодно. Привожу код процедуры: Код | PROCEDURE testing_ldap(pm_val IN INTEGER) IS ldap_host VARCHAR2(512); -- The LDAP Directory Host ldap_port VARCHAR2(512); -- The LDAP Directory Port ldap_user VARCHAR2(512); -- The LDAP Directory User ldap_passwd VARCHAR2(512); -- The LDAP Directory Password ldap_basedn VARCHAR2(512); -- The starting (base) DN retval PLS_INTEGER; -- Used for all API return values. my_session dbms_ldap.session; -- Used to store our LDAP Session res_attrs dbms_ldap.string_collection; -- A String Collection used -- to specify which -- attributes to return -- from the search. search_filter VARCHAR2(512); -- A simple character string used to -- store the filter (criteria) for -- the search. res_message dbms_ldap.message; -- Used to store the message -- (results) of the search. temp_entry dbms_ldap.message; -- Used to store entries retrieved -- from the LDAP search to print -- out at a later time. entry_index PLS_INTEGER; -- Used as a counter while looping -- through each entry. As we -- retrieve an entry from the LDAP -- directory, we increase the -- counter by one. temp_dn VARCHAR2(512); -- After each entry is retrieved -- from the LDAP directory (from -- the search), we want to use -- this variable to extract, store -- and print out the DN for each -- entry. temp_attr_name VARCHAR2(512); -- After retrieving an entry from -- LDAP directory, we will want to -- walk through all of the -- returned attributes. This -- variable will be used to store -- each attribute name as we loop -- through them. temp_ber_elmt dbms_ldap.ber_element; attr_index PLS_INTEGER; -- Used as a counter variable for -- each entry returned for each -- entry. temp_vals dbms_ldap.string_collection; -- Used to extract, store, -- and print each of the -- values from each -- attribute. temp_var VARCHAR2(10); count_val NUMBER; p_uid VARCHAR2(50); p_mail VARCHAR2(50); p_all_symbol VARCHAR2(28); BEGIN dbms_output.enable(1000000); retval := -1; DELETE FROM test_ldaps@csd_meeting; COMMIT; -- p_all_symbol := 'abcdefghijklmnopqrstuvwxyz'; --p_all_symbol := 'abcdefghijklmnopqrstuvwxy'; -- ------------------------------------------------------------------------- -- Customize the following variables as needed. -- ------------------------------------------------------------------------- ldap_host := 'ldap-ro.kv.aval'; ldap_port := '389'; ldap_user := ''; ldap_passwd := ''; ldap_basedn := 'ou=people,o=avalbank.com'; -- ------------------------------------------------------------------------- -- Print out variables. -- ------------------------------------------------------------------------- dbms_output.put_line('DBMS_LDAP Search Example'); dbms_output.put_line('---------------------------------------------------'); dbms_output.put_line(rpad('LDAP Host ', 25, ' ') || ': ' || ldap_host); dbms_output.put_line(rpad('LDAP Port ', 25, ' ') || ': ' || ldap_port); dbms_output.put_line(rpad('LDAP User ', 25, ' ') || ': ' || ldap_user); dbms_output.put_line(rpad('LDAP Base ', 25, ' ') || ': ' || ldap_basedn); -- ------------------------------------------------------------------------- -- We want all exceptions from DBMS_LDAP to be raised. -- ------------------------------------------------------------------------- dbms_ldap.use_exception := TRUE; -- ------------------------------------------------------------------------- -- Obtain an LDAP session. The init() function initializes a session with an -- LDAP server. This actually establishes a connection with the LDAP server -- and returns a handle to the session which can be used for further -- calls into the API. -- ------------------------------------------------------------------------- my_session := dbms_ldap.init(ldap_host, ldap_port); dbms_output.put_line(rpad('LDAP Session ', 25, ' ') || ': ' || rawtohex(substr(my_session, 1, 16)) || ' - (returned from init)'); -- ------------------------------------------------------------------------- -- Bind to the directory. The function simple_bind_s can be used to perform -- simple username/password based authentication to the directory server. -- The username is a directory distinguished name. This function can be -- called only after a valid LDAP session handle is obtained from a call to -- DBMS_LDAP.init(). If the connection was successful, it will return: -- DBMS_LDAP.SUCCESS. This function can raise the following exceptions: -- invalid_session : Raised if the session handle ld is invalid. -- general_error : For all other errors. The error string associated -- with this exception will explain the error in -- detail. -- ------------------------------------------------------------------------- retval := dbms_ldap.simple_bind_s(my_session, ldap_user, ldap_passwd); --DBMS_OUTPUT.PUT_LINE(RPAD('simple_bind_s Returned ', 25, ' ') || ': ' || -- TO_CHAR(retval)); -- ------------------------------------------------------------------------- -- Before actually performing the sort, I want to setup the attributes I -- would like returned. To do this, I declared a "String Collection" that -- will be used to store all of the attributes I would like returned. -- -- If I wanted to return all attributes, I would specify: -- res_attrs(1) := '*'; -- -- If I wanted multiple (specified) attributes, I would specify: -- res_attrs(1) := 'cn'; -- res_attrs(2) := 'telephoneNumber'; -- ------------------------------------------------------------------------- res_attrs(1) := 'uid'; res_attrs(2) := 'mail'; -- ------------------------------------------------------------------------- -- Finally, before performing the actual search, I want to specify the -- criteria I want to search on. This will be passed as the "filter" -- parameter to the actual search. -- -- If you wanted all of the entries in the directory to be returned, -- you could simply specify: -- search_filter := 'objectclass=*'; -- -- You could also refine your search my specify a criteria like the -- following: -- search_filter := 'cn=Jeff*'; -- ------------------------------------------------------------------------- search_filter := '(&(objectclass=person)(uid=*)(mail=*))'; -- ------------------------------------------------------------------------- -- Finally, let's issue the search. The function search_s performs a -- synchronous search in the LDAP server. It returns control to the PL/SQL -- environment only after all of the search results have been sent by the -- server or if the search request is 'timed-out' by the server. -- -- Let's first explain some of the incoming parameters: -- ld : A valid LDAP session handle. -- base : The dn of the entry at which to start the search. -- scope : One of SCOPE_BASE (0x00) -- SCOPE_ONELEVEL (0x01) -- SCOPE_SUBTREE (0x02) -- indicating the scope of the search. -- filter : A character string representing the search filter. The -- value NULL can be passed to indicate that the filter -- "(objectclass=*)" which matches all entries is to be -- used. -- attrs : A collection of strings indicating which attributes to -- return for each matching entry. Passing NULL for this -- parameter causes all available user attributes to be -- retrieved. The special constant string NO_ATTRS ("1.1") -- MAY be used as the only string in the array to indicate -- that no attribute types are to be returned by the server. -- The special constant string ALL_USER_ATTRS ("*") can be -- used in the attrs array along with the names of some -- operational attributes to indicate that all user -- attributes plus the listed operational attributes are to -- be returned. -- attronly : A boolean value that MUST be zero if both attribute types -- and values are to be returned, and non-zero if only types -- are wanted. -- res : This is a result parameter which will contain the results -- of the search upon completion of the call. If no results -- are returned, res is set to NULL. -- -- Now let's look at the two output parameters: -- PLS_INTEGER -- (function return) : DBMS_LDAP.SUCCESS if the search operation -- succeeded. An exception is raised in all other -- cases. -- res (OUT parameter) : If the search succeeded and there are entries, -- this parameter is set to a NON-NULL value -- which can be used to iterate through the -- result set. -- ------------------------------------------------------------------------- retval := dbms_ldap.search_s(ld => my_session, base => ldap_basedn, scope => dbms_ldap.scope_subtree, filter => search_filter, attrs => res_attrs, attronly => 0, res => res_message); -- ------------------------------------------------------------------------- -- After the search is performed, the API stores the count of the number of -- entries returned. -- ------------------------------------------------------------------------- retval := dbms_ldap.count_entries(my_session, res_message); dbms_output.put_line(rpad('Number of Entries ', 25, ' ') || ': ' || to_char(retval)); dbms_output.put_line('---------------------------------------------------'); -- ------------------------------------------------------------------------- -- Retrieve the first entry. -- ------------------------------------------------------------------------- temp_entry := dbms_ldap.first_entry(my_session, res_message); entry_index := 1; -- ------------------------------------------------------------------------- -- Loop through each of the entries one by one. -- ------------------------------------------------------------------------- count_val := 0; WHILE temp_entry IS NOT NULL LOOP -- --------------------------------------------------------------------- -- Print out the current entry. -- --------------------------------------------------------------------- temp_dn := dbms_ldap.get_dn(my_session, temp_entry); temp_attr_name := dbms_ldap.first_attribute(my_session, temp_entry, temp_ber_elmt); attr_index := 1; WHILE temp_attr_name IS NOT NULL LOOP temp_vals := dbms_ldap.get_values(my_session, temp_entry, temp_attr_name); -- IF temp_vals.COUNT > 0 AND temp_attr_name = 'mail' THEN p_mail := substr(temp_vals(0), 1, 50); END IF; -- IF temp_vals.COUNT > 0 AND temp_attr_name = 'uid' THEN p_uid := substr(temp_vals(0), 1, 50); END IF; temp_attr_name := dbms_ldap.next_attribute(my_session, temp_entry, temp_ber_elmt); attr_index := attr_index + 1; END LOOP; INSERT INTO test_ldaps@csd_meeting (id, mail) VALUES (p_uid, p_mail); IF (count_val = 50) THEN COMMIT; count_val := 0; END IF; temp_entry := dbms_ldap.next_entry(my_session, temp_entry); entry_index := entry_index + 1; count_val := count_val + 1; END LOOP; COMMIT; -- ------------------------------------------------------------------------- -- Unbind from the directory -- ------------------------------------------------------------------------- retval := dbms_ldap.unbind_s(my_session); dbms_output.put_line(rpad('unbind_res Returned ', 25, ' ') || ': ' || to_char(retval)); -- ------------------------------------------------------------------------- -- Handle Exceptions -- ------------------------------------------------------------------------- EXCEPTION WHEN OTHERS THEN dbms_output.put_line(' Error code : ' || to_char(SQLCODE)); dbms_output.put_line(' Error Message : ' || SQLERRM); dbms_output.put_line(' Exception encountered .. exiting'); END;
|
Спасибо. Это сообщение отредактировал(а) Sherst - 19.7.2007, 12:42
|