[Home] [Help]
PACKAGE BODY: APPS.FND_LDAP_UTIL
Source
1 package body fnd_ldap_util as
2 /* $Header: AFSCOLTB.pls 120.16.12010000.7 2009/04/24 18:36:48 rsantis ship $ */
3 --
4 -- Start of Package Globals
5
6 G_MODULE_SOURCE constant varchar2(80) := 'fnd.plsql.oid.fnd_ldap_util.';
7 G_TRACK_LDAP_STACK constant boolean:= false;
8
9 ldap_session_stack varchar2(4096):= null;
10
11 g_das_product_base varchar2(1000) := NULL;
12 g_das_base_url varchar2(1000) := NULL;
13 g_das_relative_base constant varchar2(100) := 'cn=OperationUrls,cn=DAS,cn=Products,cn=OracleContext';
14
15
16 g_common_ldap dbms_ldap.session;
17 g_common_counter pls_integer :=0;
18
19
20 -- End of Package Globals
21 --
22 -------------------------------------------------------------------------------
23 init boolean := false;
24 nickname varchar2(256) := null;
25 r_init boolean := false;
26 d_realm varchar2(4000) := null;
27 --
28 -------------------------------------------------------------------------------
29 function get_oid_session return dbms_ldap.session is
30
31 l_module_source varchar2(256);
32 l_retval pls_integer;
33 l_host varchar2(256);
34 l_port varchar2(256);
35 l_user varchar2(256);
36 l_pwd varchar2(256);
37 l_ldap_auth varchar2(256);
38 l_db_wlt_url varchar2(256);
39 l_db_wlt_pwd varchar2(256);
40 l_session dbms_ldap.session;
41
42 begin
43 l_module_source := G_MODULE_SOURCE || 'get_oid_session: ';
44 -- change it to FAILURE if open_ssl fails, else let the simple_bind_s
45 -- go through
46 l_retval := dbms_ldap.SUCCESS;
47
48 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
49 then
50 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
51 end if;
52
53 dbms_ldap.use_exception := TRUE;
54
55 l_host := fnd_preference.get(G_INTERNAL, G_LDAP_SYNCH, G_HOST);
56 l_port := fnd_preference.get(G_INTERNAL, G_LDAP_SYNCH, G_PORT);
57 l_user := fnd_preference.get(G_INTERNAL, G_LDAP_SYNCH, G_USERNAME);
58 l_pwd := fnd_preference.eget(G_INTERNAL, G_LDAP_SYNCH, G_EPWD, G_LDAP_PWD);
59 l_ldap_auth := fnd_preference.get(G_INTERNAL, G_LDAP_SYNCH, G_DBLDAPAUTHLEVEL);
60 l_db_wlt_url := fnd_preference.get(G_INTERNAL, G_LDAP_SYNCH, G_DBWALLETDIR);
61 l_db_wlt_pwd := fnd_preference.eget(G_INTERNAL, G_LDAP_SYNCH, G_DBWALLETPASS, G_LDAP_PWD);
62
63 l_session := DBMS_LDAP.init(l_host, l_port);
64
65 -- Elan, 04/27/2004, Not disclosing the password - gets saved to the database
66 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
67 then
68 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
69 , 'l_host = ' || l_host || ', l_port = ' || l_port ||
70 ', l_ldap_auth = ' || l_ldap_auth || ', l_db_wlt_url = ' ||
71 l_db_wlt_url ||
72 ', l_user = ' || l_user || ', l_pwd = ****');
73 end if;
74
75 if ( l_ldap_auth > 0 )
76 then
77 l_retval := dbms_ldap.open_ssl
78 (l_session, 'file:'||l_db_wlt_url, l_db_wlt_pwd, l_ldap_auth);
79 end if;
80
81 --dbms_ldap.use_exception := false;
82 --retval := dbms_ldap.open_ssl(my_session, ' ', ' ', 1);
83
84 if (l_retval = dbms_ldap.SUCCESS) then
85 l_retval := dbms_ldap.simple_bind_s(l_session, l_user, l_pwd);
86 else
87 fnd_message.set_name ('FND', 'FND_SSO_SSL_ERROR');
88 raise_application_error(-20002, 'FND_SSO_SSL_ERROR');
89 end if;
90
91 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
92 then
93 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
94 end if;
95
96 return l_session;
97
98 exception
99 when dbms_ldap.invalid_session then
100 fnd_message.set_name ('FND', 'FND_SSO_INV_SESSION');
101 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
102 then
103 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
104 end if;
105 raise;
106 when dbms_ldap.invalid_ssl_wallet_loc then
107 fnd_message.set_name ('FND', 'FND_SSO_WALLET_LOC');
108 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
109 then
110 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
111 end if;
112 raise;
113 when dbms_ldap.invalid_ssl_wallet_passwd then
114 fnd_message.set_name ('FND', 'FND_SSO_WALLET_PWD');
115 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
116 then
117 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
118 end if;
119 raise;
120 when dbms_ldap.invalid_ssl_auth_mode then
121 fnd_message.set_name ('FND', 'FND_SSO_INV_AUTH_MODE');
122 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
123 then
124 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
125 end if;
126 raise;
127 when others then
128 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
129 then
130 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
131 end if;
132 raise;
133
134 end get_oid_session;
135 --
136 -------------------------------------------------------------------------------
137 function unbind(p_session in out nocopy dbms_ldap.session) return pls_integer
138 is
139 retval pls_integer;
140 l_module_source varchar2(256);
141 begin
142
143 l_module_source := G_MODULE_SOURCE || 'unbind: ';
144
145 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
146 then
147 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
148 end if;
149
150 retval := dbms_ldap.unbind_s(p_session);
151
152 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
153 then
154 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
155 end if;
156
157 return retval;
158
159 exception
160 when others then
161 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
162 then
163 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
164 end if;
165 raise;
166
167 end unbind;
168 --
169 -------------------------------------------------------------------------------
170 /* this procedure removes any " in the appName. Some deployments have this special character */
171 procedure removeExtraQuotes(p_app in out nocopy varchar2) is
172
173 quotesIndex pls_integer;
174 strLength pls_integer;
175 l_module_source varchar2(256);
176
177 begin
178
179 l_module_source := G_MODULE_SOURCE || 'removeExtraQuotes: ';
180
181 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
182 then
183 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
184 end if;
185
186 strLength := length(p_app);
187
188 while instr(p_app, '"') <> 0 loop
189 quotesIndex := instr(p_app, '"');
190 p_app := Substr(p_app, 0, quotesIndex-1) || Substr(p_app, quotesIndex+1, strLength);
191 end loop;
192
193 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
194 then
195 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
196 end if;
197
198 exception
199 when others then
200 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
201 then
202 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
203 end if;
204 raise;
205
206 end removeExtraQuotes;
207 ---------------------------------------------------------------
208 -- The username to connecto oid
209 function get_orclappname return varchar2 is
210
211 l_module_source varchar2(256);
212 orclAppName varchar2(256);
213
214 begin
215
216 l_module_source := G_MODULE_SOURCE || 'get_orclappname: ';
217
218 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
219 then
220 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
221 end if;
222
223 -- Bug 5001849 use FND API instead of directly doing a select against
224 -- fnd_user_preferences
225
226 orclAppName := fnd_preference.get(p_user_name => '#INTERNAL',
227 p_module_name => 'LDAP_SYNCH',
228 p_pref_name => 'USERNAME');
229
230 removeExtraQuotes(orclAppName);
231
232 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
233 then
234 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
235 end if;
236
237 return orclAppName;
238
239 exception
240 when others then
241 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
242 then
243 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
244 end if;
245 raise;
246
247 end get_orclappname;
248 --
249 -------------------------------------------------------------------------------
250 -- DELETED
251 -- function get_users_nodes return dbms_ldap.string_collection
252 --
253 -------------------------------------------------------------------------------
254 function get_dn_for_guid(p_orclguid in fnd_user.user_guid%type) return varchar2 is
255
256 l_module_source varchar2(256);
257 result pls_integer;
258 l_dn varchar2(1000);
259 l_base varchar2(1000);
260 l_message dbms_ldap.message := NULL;
261 l_entry dbms_ldap.message := NULL;
262 l_attrs dbms_ldap.string_collection;
263 l_ldap_session dbms_ldap.session;
264
265 begin
266
267 l_module_source := G_MODULE_SOURCE || 'get_dn_for_GUID: ';
268
269 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
270 then
271 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
272 end if;
273
274 l_base := '';
275 l_ldap_session := get_oid_session;
276
277 result := dbms_ldap.search_s(ld => l_ldap_session
278 , base => l_base
279 , scope => dbms_ldap.SCOPE_SUBTREE
280 , filter => 'orclguid='||p_orclguid
281 , attrs => l_attrs
282 , attronly => 0
283 , res => l_message);
284 l_entry := dbms_ldap.first_entry(l_ldap_session, l_message);
285
286 if (l_entry is null) then
287 l_dn := null;
288 else
289 l_dn := dbms_ldap.get_dn(l_ldap_session, l_entry);
290 end if;
291
292 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
293 then
294 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'GUID::'||p_orclguid||' DN::'||l_dn);
295 end if;
296
297 result := unbind(l_ldap_session);
298
299 if (l_dn is null) then
300 raise no_data_found;
301 end if;
302
303 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
304 then
305 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
306 end if;
307
308 return l_dn;
309
310 exception
311 when no_data_found then
312 fnd_message.set_name ('FND', 'FND_SSO_USER_NOT_FOUND');
313 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
314 then
315 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, 'No user found with the given GUID');
316 end if;
317 raise;
318 when others then
319 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
320 then
321 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
322 end if;
323 raise;
324
325 end get_dn_for_GUID;
326 --
327 -------------------------------------------------------------------------------
328 function get_dn_for_guid(p_orclguid in fnd_user.user_guid%type,
329 p_ldap_session in dbms_ldap.session) return varchar2 is
330
331 l_module_source varchar2(256);
332 result pls_integer;
333 l_dn varchar2(1000);
334 l_base varchar2(1000);
335 l_message dbms_ldap.message := NULL;
336 l_entry dbms_ldap.message := NULL;
337 l_attrs dbms_ldap.string_collection;
338
339 begin
340
341 l_module_source := G_MODULE_SOURCE || 'get_dn_for_GUID: ';
342
343 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
344 then
345 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
346 end if;
347
348 l_base := '';
349
350 result := dbms_ldap.search_s(ld => p_ldap_session
351 , base => l_base
352 , scope => dbms_ldap.SCOPE_SUBTREE
353 , filter => 'orclguid='||p_orclguid
354 , attrs => l_attrs
355 , attronly => 0
356 , res => l_message);
357 l_entry := dbms_ldap.first_entry(p_ldap_session, l_message);
358
359 if (l_entry is null) then
360 l_dn := null;
361 else
362 l_dn := dbms_ldap.get_dn(p_ldap_session, l_entry);
363 end if;
364
365 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
366 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'GUID::'||p_orclguid||' DN::'||l_dn);
367 end if;
368
369 if (l_dn is null) then
370 raise no_data_found;
371 end if;
372
373 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
374 then
375 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
376 end if;
377
378 return l_dn;
379
380 exception
381 when no_data_found then
382 fnd_message.set_name ('FND', 'FND_SSO_USER_NOT_FOUND');
383 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
384 then
385 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, 'No user found with the given GUID');
386 end if;
387 raise;
388 when others then
389 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
390 then
391 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
392 end if;
393 raise;
394
395 end get_dn_for_GUID;
396 --
397 -------------------------------------------------------------------------------
398 /*
399 ** Name : get_guid_for_dn
400 ** Type : Private (? , probably others will need this ,
401 ** is it a candidate for the API ?
402 ** Desc : Given and DN return its orclguid
403 ** if DN is not found, the raise "NO_DATA_FOUND'
404
405 ** Parameters :
406 ** aDN: the application DN, for example
407 ** orclApplicationCommonName=PROD1,cn=EBusiness,cn=Products,cn=OracleContext,dc=us,dc=oracle,dc=com
408 ** Returns :
409 ** Its orclguid
410 ** If it is NULL then the DN does not have a orcGuild attribute
411 ** Exceptions:
412 ** DATA_NOT_FOUND if search_s raise DBMS_LDAP.GENERAL_EXCEPTION
413 ** NOte that this DBMS_LDAP exception maybe risen by other reasons
414 **
415 */
416 function get_guid_for_dn(ldapSession in dbms_ldap.session,p_dn in varchar2) return varchar2
417 is
418
419 result pls_integer;
420 l_message dbms_ldap.message := null; -- the query result set
421 l_entry dbms_ldap.message := null; -- the entry
422 l_attrs dbms_ldap.string_collection; -- lookup attributes
423 l_guid varchar2(100); -- returning guid
424 err varchar2(1000);
425 l_module_source varchar2(256);
426 begin
427 l_module_source := G_MODULE_SOURCE || 'get_guid_for_dn:';
428
429 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
430 then
431 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
432 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'DN='||p_dn);
433 end if;
434
435 l_attrs(0) := 'orclGuid';
436 begin
437 result := dbms_ldap.search_s(ld => ldapSession,
438 base => p_dn,
439 scope => dbms_ldap.SCOPE_BASE,
440 filter => 'objectclass=*',
441 attrs => l_attrs,
442 attronly => 0,
443 res => l_message);
444 exception
445 when dbms_ldap.general_error then
446 -- asume that DN not found
450 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
447 -- is not accurate, but better that nothing
448 err := SQLERRM;
449 if (instr(err,'No such object')>1) then
451 then
452 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source,
453 ' DN not found : raise NO_DATA_FOUND');
454 end if;
455 raise NO_DATA_FOUND;
456 else
457 if (fnd_log.LEVEL_EXCEPTION>= fnd_log.G_CURRENT_RUNTIME_LEVEL)
458 then
459 fnd_log.string(fnd_log.LEVEL_EXCEPTION, l_module_source, SQLERRM);
460 fnd_log.string(fnd_log.LEVEL_EXCEPTION, l_module_source, ' from dbms_ldap.search_s, dn='||p_dn);
461 end if;
462 raise;
463 end if;
464 end;
465 l_entry := dbms_ldap.first_entry(ldapSession, l_message);
466 l_attrs := dbms_ldap.get_values(ldapSession, l_entry, 'orclGuid');
467 begin
468 l_guid := l_attrs(0);
469 exception
470 when NO_DATA_FOUND then
471 -- this entry does not have orclguid
472 l_guid := null;
473 end;
474
475
476 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
477 then
478 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, ' END : guid='||l_guid);
479 end if;
480 return l_guid;
481
482 exception
483 when others then
484 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
485 then
486 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, ' for DN='||p_dn);
487 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
488 end if;
489 raise;
490 end get_guid_for_dn;
491 --
492 -------------------------------------------------------------------------------
493 function get_default_realm(username in out nocopy varchar2) return varchar2 is
494
495 l_module_source varchar2(256);
496 result pls_integer;
497 l_result varchar2(4000);
498 l_base varchar2(100);
499 l_message dbms_ldap.message := NULL;
500 l_entry dbms_ldap.message := NULL;
501 l_attrs dbms_ldap.string_collection;
502 l_ldap_session dbms_ldap.session;
503
504 begin
505
506 l_module_source := G_MODULE_SOURCE || 'get_default_realm ';
507
508 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
509 then
510 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
511 end if;
512 l_result := FND_OID_PLUG.getRealmDN(username);
513 if (fnd_log.LEVEL_STATEMENT>= fnd_log.G_CURRENT_RUNTIME_LEVEL)
514 then
515 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'realm: '||l_result);
516 end if;
517
518 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
519 then
520 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'End');
521 end if;
522
523 return l_result;
524
525 exception
526 when others then
527 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
528 then
529 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
530 end if;
531 raise;
532
533 end get_default_realm;
534 --
535 -------------------------------------------------------------------------------
536 -- DELETED
537 -- function get_search_nodes return dbms_ldap.string_collection is
538
539 --
540 -------------------------------------------------------------------------------
541 --
542 -------------------------------------------------------------------------------
543 procedure proxy_as_user(p_orclguid in fnd_user.user_guid%type, x_ldap_session out nocopy dbms_ldap.session) is
544
545 l_module_source varchar2(256);
546 l_retval pls_integer;
547 l_dn varchar2(512);
548
549 proxy_failed_exp exception;
550
551 PRAGMA EXCEPTION_INIT (proxy_failed_exp, -20002);
552
553 begin
554 l_module_source := G_MODULE_SOURCE || 'proxy_as_user: ';
555
556 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
557 then
558 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
559 end if;
560
561 x_ldap_session := fnd_ldap_util.get_oid_session;
562 l_dn := get_dn_for_guid(p_orclguid => p_orclguid, p_ldap_session => x_ldap_session);
563
564 dbms_ldap.use_exception := true;
565
566 l_retval := dbms_ldap.simple_bind_s(x_ldap_session, l_dn, null);
567
568 if (l_retval = dbms_ldap.SUCCESS) then
569 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
570 then
571 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Proxied Successfully for User DN:' ||
572 l_dn);
573 end if;
574 else
575 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
576 then
577 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Proxy Failed for User DN: ' ||
578 l_dn);
579 end if;
580 raise proxy_failed_exp;
581 end if;
582
583 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
584 then
585 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
586 end if;
587
588 --return l_session;
589
590 exception
591 when dbms_ldap.invalid_session then
592 fnd_message.set_name ('FND', 'FND_SSO_INV_SESSION');
593 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
594 then
595 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
596 end if;
597 raise;
598 when others then
599 if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
600 then
604
601 fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
602 end if;
603 raise;
605 end proxy_as_user;
606 --
607 -------------------------------------------------------------------------------
608 /*
609 ** Name : get_attribute
610 ** Type : Private
611 ** is it a candidate for the API ?
612 ** Desc : Given a DN and an attribut rename returns the value for that entry.
613 ** if DN is not found, the raise "NO_DATA_FOUND'
614
615 ** Parameters :
616 ** p_ldap_session: a valid connection
617 ** p_dn: DN
618 ** p_attr_name: Attribute name
619 **
620 **
621 ** Returns :
622 ** The value.
623 ** Returns NULL in the cases that attribute is not present in the entry, or the DN does not exists
624 ** Exceptions: NONE (? maybe change it to NODATAFOUND for the DN missing case)
625 **
626 */
627
628
629 FUNCTION get_attribute(p_ldap_session IN dbms_ldap.SESSION, p_dn IN VARCHAR2, p_attr_name IN VARCHAR2) RETURN VARCHAR2 IS l_module_source VARCHAR2(256);
630 l_attrs dbms_ldap.string_collection;
631 l_result VARCHAR2(1000);
632 result pls_integer;
633 l_entry dbms_ldap.message := NULL;
634 l_message dbms_ldap.message := NULL;
635 BEGIN
636 l_module_source := g_module_source || 'get_Attribute ';
637
638 IF(fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
639 fnd_log.string(fnd_log.level_procedure, l_module_source, 'Begin ');
640 END IF;
641 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
642 fnd_log.string(fnd_log.level_statement, l_module_source, ' dn:' || p_dn || ' attr:' || p_attr_name);
643 END IF;
644
645 l_attrs(0) := p_attr_name;
646 result := dbms_ldap.search_s(ld => p_ldap_session, base => p_dn,
647 scope => dbms_ldap.scope_base, filter => '(objectclass=*)',
648 attrs => l_attrs, attronly => 0, res => l_message);
649 l_entry := dbms_ldap.first_entry(p_ldap_session, l_message);
650 l_attrs := dbms_ldap.get_values(p_ldap_session, l_entry, p_attr_name);
651 BEGIN
652 l_result := l_attrs(0);
653 EXCEPTION WHEN NO_DATA_FOUND THEN
654 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
655 fnd_log.string(fnd_log.level_statement, l_module_source, 'attribute '||p_attr_name||' not present at '||p_dn);
656 END IF;
657 l_result := null; -- DN found, but does not contain the attribute
658 END;
659
660 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
661 fnd_log.string(fnd_log.level_statement, l_module_source, 'END-> ' || l_result);
662 END IF;
663 return l_result;
664
665 EXCEPTION
666 WHEN dbms_ldap.general_error THEN
667 BEGIN
668
669 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
670 fnd_log.string(fnd_log.level_statement, l_module_source, 'END-> not found '||sqlerrm);
671 END IF;
672 return null; -- DN NOT FOUND
673 END;
674 WHEN OTHERS THEN
675
676 IF(fnd_log.level_error >= fnd_log.g_current_runtime_level) THEN
677 fnd_log.string(fnd_log.level_error, l_module_source, sqlerrm);
678
679 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
680 fnd_log.string(fnd_log.level_statement, l_module_source, 'END-> RAISE');
681 END IF;
682
683 END IF;
684
685 RAISE;
686 END get_attribute;
687
688 --
689 -------------------------------------------------------------------------------
690 /*
691 ** Name : get_das_base_url
692 ** Type : Private
693 ** Desc : Returns the DAS url like 'http://xxx:123/oiddas/'
694 ** All the operations URL are relative to this.
695 ** Parameters :
696 ** p_ldap_session: a valid connection
697 ** p_realm_dn: The realm
698 **
699 **
700 ** Returns : and Url string
701 ** Exceptions: NONE (? maybe change it to NODATAFOUND for the DN missing case)
702 **
703 ** Note:
704 ** Although it may seems it support multiple realms it does not.
705 ** Since the value is cached, only the first value will be returned after that, even for other realms.
706 ** THIS NEEDS TO BE FIXED for multiple realm support
707 */
708
709
710 FUNCTION get_das_base_url(p_ldap_session IN dbms_ldap.SESSION, p_realm_dn IN VARCHAR2) RETURN VARCHAR2 IS
711
712 l_module_source VARCHAR2(256);
713 l_url VARCHAR2(2000);
714 l_attrs dbms_ldap.string_collection;
715 l_result VARCHAR2(1000);
716 l_try VARCHAR2(1000);
717
718 BEGIN
719 l_module_source := g_module_source || 'get_DAS_BASE_URL ';
720
721 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
722 fnd_log.string(fnd_log.level_statement, l_module_source, 'Begin ');
723 END IF;
724
725 IF(g_das_base_url is not NULL) THEN
726
727 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
728 fnd_log.string(fnd_log.level_statement, l_module_source, 'END (cached)-> ' || g_das_base_url);
729 END IF;
730
731 RETURN g_das_base_url;
732 END IF;
733 l_try := g_das_relative_base||','||p_realm_dn;
734 l_result := get_attribute(p_ldap_session,l_try, 'orcldasurlbase' );
735 if (l_result is not null)
736 THEN
737 g_das_product_base := l_try;
738 g_das_base_url := l_result;
739 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
740 fnd_log.string(fnd_log.level_statement, l_module_source, ' DAS_BASE_DN ' || g_das_product_base);
744
741 fnd_log.string(fnd_log.level_statement, l_module_source, ' DAS_URL-> ' || g_das_base_url);
742 fnd_log.string(fnd_log.level_statement, l_module_source, 'END -> ' || g_das_base_url);
743 END IF;
745 return g_das_base_url;
746 END IF;
747 l_try := g_das_relative_base;
748 l_result := get_attribute(p_ldap_session,l_try, 'orcldasurlbase' );
749 if (l_result is not null)
750 THEN
751 g_das_product_base :=l_try;
752 g_das_base_url := l_result;
753 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
754 fnd_log.string(fnd_log.level_statement, l_module_source, ' DAS_BASE_DN ' || g_das_product_base);
755 fnd_log.string(fnd_log.level_statement, l_module_source, ' DAS_URL-> ' || g_das_base_url);
756 fnd_log.string(fnd_log.level_statement, l_module_source, 'END -> ' || g_das_base_url);
757 END IF;
758 return g_das_base_url;
759 END IF;
760 /*
761 * Incorrect settings or something
762 */
763 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level)
764 THEN
765 fnd_log.string(fnd_log.level_statement, l_module_source, 'END-> FAILED ' );
766 END IF;
767 G_DAS_PRODUCT_BASE:=NULL;
768 G_DAS_BASE_URL := NULL;
769 return NULL;
770
771 EXCEPTION WHEN others THEN
772
773 IF(fnd_log.level_error >= fnd_log.g_current_runtime_level)
774 THEN
775 fnd_log.string(fnd_log.level_error, l_module_source, sqlerrm);
776 END IF;
777
778 fnd_message.set_name('FND', 'get_DAS_BASE_URL'); RETURN NULL;
779 END get_das_base_url;
780 --
781 -------------------------------------------------------------------------------
782 --
783 -------------------------------------------------------------------------------
784 /*
785 ** Name : get_das_operationurl
786 ** Type : Private (FND Internal)
787 ** Desc : Return URL for operation (For exmaple 'Password Change' at DAS.
788
789 ** Parameters :
790 ** p_realm: The realm , NULL for request default value.
791 ** p_operation: operation (see package schema for examples )
792 ** Returns :
793 ** A URL string
794 ** Exceptions: NONE
795 **
796 ** Note: This function can be tested from SQL*Plus , for example
797 ** select fnd_ldap_util.get_das_operationurl(null,'Password Change') from dual;
798 **
799 ** http://rslnz.us.oracle.com:7777/oiddas/ui/oracle/ldap/das/mypage/AppChgPwdMyPage
800 */
801
802 FUNCTION get_das_operationurl(p_realm IN VARCHAR2, p_operation IN VARCHAR2) RETURN VARCHAR2 IS
803
804
805 l_result VARCHAR2(4000) := NULL;
806 l_base VARCHAR2(4000) := NULL;
807 l_ldap_session dbms_ldap.SESSION;
808 l_module_source varchar2(2000);
809 result pls_integer;
810 BEGIN
811 l_module_source := g_module_source || 'get_das_operationurl ';
812
813 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
814 fnd_log.string(fnd_log.level_statement, l_module_source, 'Begin ');
815 fnd_log.string(fnd_log.level_statement, l_module_source, ' realm:' || p_realm || ' op:"' || p_operation||'"');
816 END IF;
817
818 l_ldap_session := fnd_ldap_util.get_oid_session;
819 IF (p_realm is NOT null)
820 THEN
821
822 l_result := get_attribute(l_ldap_session, 'cn='|| p_operation||','|| g_das_relative_base||','||p_realm, 'orcldasurl' );
823 l_base := get_das_base_url(l_ldap_session,p_realm);
824 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
825
826 fnd_log.string(fnd_log.level_statement, l_module_source, ' op_url:' || l_result);
827 fnd_log.string(fnd_log.level_statement, l_module_source, ' base:' || l_base);
828
829 END IF;
830 END IF;
831 -- For no realm returned the default data (which is not the same
832 -- as data for the default realm )
833 if (p_realm is NULL or l_result is null)
834 THEN
835 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
836 fnd_log.string(fnd_log.level_statement, l_module_source, ' get default Urls');
837 END IF;
838
839 l_result := get_attribute(l_ldap_session, 'cn='||p_operation||','||g_das_relative_base, 'orcldasurl' );
840 l_base := get_das_base_url(l_ldap_session,null);
841 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
842 fnd_log.string(fnd_log.level_statement, l_module_source, ' op_url:' || l_result);
843 fnd_log.string(fnd_log.level_statement, l_module_source, ' base:' || l_base);
844 END IF;
845 END IF;
846
847 result := fnd_ldap_util.unbind(l_ldap_session);
848 if (l_result is null or l_base is null)
849 then
850 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
851 fnd_log.string(fnd_log.level_statement, l_module_source, 'END->NULLl:');
852 END IF;
853 return NULL;
854 end if;
855 IF(fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
856 fnd_log.string(fnd_log.level_statement, l_module_source, 'END-> ' || l_base||l_result);
857 END IF;
858 return l_base||l_result;
859
860 EXCEPTION WHEN OTHERS THEN
861 IF(fnd_log.level_error >= fnd_log.g_current_runtime_level)
862 THEN
863 fnd_log.string(fnd_log.level_error, l_module_source, sqlerrm);
864 END IF;
865
866 fnd_message.set_name('FND', 'get_DAS_BASE_URL');
867 return null;
868 END get_das_operationurl;
869
870
871 -------------------------------------------------------------------------------------------------
872 ---
876 vals dbms_ldap.string_collection;
873 procedure add_attribute_M(x_ldap in dbms_ldap.session, dn in varchar2, name in varchar2, value in varchar2 )
874 IS
875 modArray dbms_ldap.mod_array;
877 ret pls_integer;
878 l_module_source varchar2(256):= G_MODULE_SOURCE || 'add_attribute_M: ';
879
880 BEGIN
881 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
882 then
883 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
884 end if;
885 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
886 then
887 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'dn='||dn);
888 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'attribute='||name||' value='||value);
889 end if;
890
891 modArray := dbms_ldap.create_mod_array(num => 1);
892 vals(0) := value;
893 dbms_ldap.populate_mod_array(modptr=>modArray,mod_op=>dbms_ldap.mod_add,mod_type=>name,modval=>vals);
894 ret := dbms_ldap.modify_s(ld=>x_ldap,entrydn=>dn,modptr=>modArray);
895 dbms_ldap.free_mod_array(modptr => modArray);
896 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
897 then
898 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'END');
899 end if;
900
901 exception when others then
902 if (fnd_log.LEVEL_UNEXPECTED >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
903 then
904 fnd_log.string(fnd_log.LEVEL_UNEXPECTED, l_module_source, sqlerrm);
905 end if;
906 raise;
907
908 END add_attribute_M;
909
910
911 function c_get_oid_session(flag in out nocopy pls_integer) return dbms_ldap.session
912 is
913 l_module_source varchar2(256):= G_MODULE_SOURCE || 'c_get_oid_session: ';
914 BEGIN
915 /*
916 * flag=-99 just to print the stack on the log
917 */
918 IF (flag=-99) THEN
919 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
920 then
921 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'DUMP ldap status for FND_LDAP_UTIL='||g_common_counter);
922 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'g_common_counter='||g_common_counter);
923 IF (G_TRACK_LDAP_STACK) THEN
924 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, ldap_session_stack);
925 END IF;
926 end if;
927 return null;
928 END IF;
929
930
931
932 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
933 then
934 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
935 end if;
936 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
937 then
938 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'initialy g_common_counter='||g_common_counter);
939 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'initialy flag='||flag);
940 end if;
941
942 if (g_common_counter=0) then
943 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
944 then
945 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'creating a new connection');
946 IF (G_TRACK_LDAP_STACK) THEN
947 ldap_session_stack := dbms_utility.FORMAT_CALL_STACK;
948 END IF;
949 end if;
950 g_common_ldap := get_oid_session;
951 end if;
952 flag := g_common_counter;
953 g_common_counter := g_common_counter + 1;
954
955 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
956 then
957 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'finally g_common_counter='||g_common_counter);
958 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'finally flag='||flag);
959 end if;
960 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
961 then
962 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'END');
963 end if;
964 return g_common_ldap;
965
966 exception when others then
967 if (fnd_log.LEVEL_UNEXPECTED >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
968 then
969 fnd_log.string(fnd_log.LEVEL_UNEXPECTED, l_module_source, sqlerrm);
970 end if;
971 raise;
972 END c_get_oid_session;
973
974 procedure c_unbind(ldap in out nocopy dbms_ldap.session , flag in out nocopy pls_integer)
975 is
976 l_module_source varchar2(256):= G_MODULE_SOURCE || 'c_unbind: ';
977 ret pls_integer;
978 begin
979 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
980 then
981 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
982 end if;
983
984 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
985 then
986 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, ' incomming g_common_counter='||g_common_counter);
987 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, ' incomming flag='||flag);
988 end if;
989
990 if (flag=0)then
991 ret := unbind(g_common_ldap);
992 g_common_counter := 0;
993 elsif (g_common_counter>1) then
994 g_common_counter := g_common_counter - 1;
995 -- we don't wont to reach 0, because we will lose control.
996 else
997 if (fnd_log.LEVEL_UNEXPECTED >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
998 then
999 fnd_log.string(fnd_log.LEVEL_UNEXPECTED, l_module_source, 'g_common_counter reached invalid value='||g_common_counter);
1000 end if;
1001
1002 end if;
1003 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1004 then
1005 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, ' final g_common_counter='||g_common_counter);
1006 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, ' final flag='||flag);
1007 end if;
1008 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1009 then
1013 if (fnd_log.LEVEL_UNEXPECTED >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1010 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'END');
1011 end if;
1012 exception when others then
1014 then
1015 fnd_log.string(fnd_log.LEVEL_UNEXPECTED, l_module_source, sqlerrm);
1016 end if;
1017 raise;
1018 end c_unbind;
1019
1020
1021 function getLDAPAttribute(ldap in out nocopy dbms_ldap.session,dn in varchar2, attrName in varchar2, filterExp in varchar2 default 'objectclass=*')
1022 return varchar2
1023 is
1024 result pls_integer;
1025 l_attrs dbms_ldap.string_collection;
1026 l_message dbms_ldap.message := NULL;
1027 l_entry dbms_ldap.message := NULL;
1028 l_result varchar2(4000);
1029 l_module_source varchar2(1000) ;
1030 BEGIN
1031 l_module_source := G_MODULE_SOURCE || 'getAttribute: ';
1032
1033 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1034 then
1035 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
1036 end if;
1037
1038 l_attrs(0):= attrName;
1039 result := dbms_ldap.search_s(ld => ldap
1040 , base => dn
1041 , scope => dbms_ldap.SCOPE_BASE
1042 , filter => filterExp
1043 , attrs => l_attrs
1044 , attronly => 0
1045 , res => l_message);
1046 l_entry := dbms_ldap.first_entry(ldap, l_message);
1047 if (l_entry is null ) then return null; end if;
1048 l_attrs := dbms_ldap.get_values(ldap, l_entry, attrName);
1049 l_result := l_attrs(0);
1050 if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1051 then
1052 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'ldapsearch -b "'||dn||'" -s base "'||filterExp||'" '||attrName);
1053 fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'result:'||l_result);
1054 end if;
1055
1056 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1057 then
1058 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'END ');
1059 end if;
1060 return l_result;
1061
1062
1063 exception when NO_DATA_FOUND then
1064 if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1065 then
1066 fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'END -> NULL');
1067 end if;
1068 return null;
1069 END getLDAPAttribute;
1070
1071
1072 function loadLdapRecord( ldapSession in out nocopy dbms_ldap.session, rec in out nocopy ldap_record_values, dn out nocopy varchar2,
1073 key in varchar2, key_type in pls_integer default G_DN_KEY ) return boolean
1074 is
1075 result pls_integer;
1076 attrs DBMS_LDAP.string_collection;
1077 l_message DBMS_LDAP.message;
1078 l_entry DBMS_LDAP.message;
1079 atName varchar2(300);
1080 l_ber_elmt DBMS_LDAP.ber_element;
1081
1082 BEGIN
1083 attrs(0):='*';
1084 attrs(1):='orclguid';
1085
1086 if (key_type=G_GUID_KEY) THEN
1087
1088 result := dbms_ldap.search_s(ld => ldapSession,
1089 base => '',
1090 scope => dbms_ldap.SCOPE_SUBTREE,
1091 filter => 'orclguid='||key,
1092 attrs => attrs,
1093 attronly => 0,
1094 res => l_message);
1095 ELSE -- default action
1096 BEGIN
1097 result:= dbms_ldap.search_s(ld => ldapSession,
1098 base => key,
1099 scope => dbms_ldap.SCOPE_BASE,
1100 filter => 'objectclass=*',
1101 attrs => attrs,
1102 attronly => 0,
1103 res => l_message);
1104 EXCEPTION WHEN dbms_ldap.general_error THEN
1105 result := dbms_ldap.NO_SUCH_OBJECT;
1106 END;
1107 END IF;
1108 if (result=DBMS_LDAP.SUCCESS) THEN
1109 l_entry := DBMS_LDAP.first_entry(ldapSession, l_message );
1110 if l_entry is not null then
1111 dn := DBMS_LDAP.get_dn(ldapSession,l_entry);
1112 atName := DBMS_LDAP.first_attribute(ldapSession,l_entry, l_ber_elmt);
1113 while atName is not null loop
1114 rec(atName):= DBMS_LDAP.get_values (ldapSession, l_entry,atName);
1115 atName := DBMS_LDAP.next_attribute(ldapSession,l_entry,l_ber_elmt);
1116 end loop;
1117 end if;
1118 return true;
1119 ELSE
1120 dn:=null;
1121 return false;
1122 END IF;
1123
1124
1125
1126 END loadLdapRecord;
1127
1128 function loadLdapRecord( ldapSession in out nocopy dbms_ldap.session, rec in out nocopy ldap_record_type,
1129 key in varchar2, key_type in pls_integer default G_DN_KEY ) return boolean
1130
1131 IS
1132 ret boolean;
1133 dn varchar2(4000);
1134
1135 BEGIN
1136 ret:= loadLdapRecord(ldapSession,rec.data,dn,key,key_type);
1137 if (ret) THEN
1138 rec.dn := dn;
1139 END IF;
1140 return ret;
1141 END loadLdapRecord;
1142
1143 end fnd_ldap_util;
1144