DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_LDAP_MAPPER

Source


1 package body fnd_ldap_mapper as
2 /* $Header: AFSCOLMB.pls 120.9.12010000.3 2009/04/23 19:33:51 rsantis ship $ */
3    G_MODULE_SOURCE  constant varchar2(80) := 'fnd.plsql.oid.fnd_ldap_mapper.';
4 
5 --
6 -------------------------------------------------------------------------------
7 function map_sso_user_profiles(p_user_name in varchar2)
8   return fnd_oid_util.apps_sso_user_profiles_type is
9 
10   cursor cur_fnd_users is
11     select user_id
12       from fnd_user
13      where user_name = p_user_name;
14 
15   l_module_source   varchar2(256);
16   l_rec             cur_fnd_users%rowtype;
17   l_found           boolean;
18   l_val             varchar2(80);
19   l_defined         boolean;
20   l_user_profiles   fnd_oid_util.apps_sso_user_profiles_type;
21   no_such_user_exp  exception;
22 
23 begin
24   l_module_source := G_MODULE_SOURCE || 'map_sso_user_profiles: ';
25   l_found := false;
26 
27   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
28   then
29     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
30   end if;
31 
32   open cur_fnd_users;
33   fetch cur_fnd_users into l_rec;
34   l_found := cur_fnd_users%found;
35   close cur_fnd_users;
36 
37   if (not l_found)
38   then
39     raise no_such_user_exp;
40   end if;
41 
42   fnd_profile.get_specific(
43       name_z    => fnd_oid_util.G_APPS_SSO_LDAP_SYNC
44     , user_id_z => l_rec.user_id
45     , val_z     => l_val
46     , defined_z => l_defined);
47 
48   if (l_defined)
49   then
50     l_user_profiles.ldap_sync := l_val;
51   else
52     l_user_profiles.ldap_sync := fnd_oid_util.G_N;
53   end if;
54 
55   fnd_profile.get_specific(
56       name_z   => fnd_oid_util.G_APPS_SSO_LOCAL_LOGIN
57     , user_id_z => l_rec.user_id
58     , val_z    => l_val
59     , defined_z => l_defined);
60 
61   if (l_defined)
62   then
63     l_user_profiles.local_login := l_val;
64   else
65     l_user_profiles.local_login := fnd_oid_util.G_LOCAL;
66   end if;
67 
68   --Rada, 01/31/2005, AUTO LINK
69 
70   fnd_profile.get_specific(
71       name_z   => fnd_oid_util.G_APPS_SSO_AUTO_LINK_USER
72     , user_id_z => l_rec.user_id
73     , val_z    => l_val
74     , defined_z => l_defined);
75 
76   if (l_defined)
77   then
78     l_user_profiles.auto_link := l_val;
79   else
80     l_user_profiles.auto_link := fnd_oid_util.G_N;
81   end if;
82 
83   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
84   then
85     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
86       , 'l_user_profiles = ldap_sync: ' || l_user_profiles.ldap_sync ||
87       ', local_login: ' || l_user_profiles.local_login);
88     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
89   end if;
90 
91   return (l_user_profiles);
92 
93 exception
94   when no_such_user_exp then
95     if (cur_fnd_users%isopen)
96     then
97       close cur_fnd_users;
98     end if;
99     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
100     then
101       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source,
102         'no_such_user_exp: No matching record for FND_USER.user_name = ' ||
103         p_user_name);
104     end if;
105     raise;
106     return null;
107 
108   when others then
109     if (cur_fnd_users%isopen)
110     then
111       close cur_fnd_users;
112     end if;
113     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
114     then
115       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
116     end if;
117 
118     raise;
119     return null;
120 end map_sso_user_profiles;
121 --
122 -------------------------------------------------------------------------------
123 procedure map_entity_changes_rec(
124   p_entity_changes_rec  in out  nocopy  fnd_oid_util.wf_entity_changes_rec_type
125 ) is
126 
127   cursor cur_entity_changes is
128     select entity_type, entity_key_value, flavor, change_date
129            , to_char(change_date, fnd_oid_util.G_YYYYMMDDHH24MISS) change_date_in_char
130       from wf_entity_changes
131      where entity_id is null
132        and change_date <= sysdate
133      order by change_date
134        for update of entity_id;
135 
136   l_module_source varchar2(256);
137   l_rec           cur_entity_changes%rowtype;
138   l_found         boolean;
139 
140 begin
141   l_module_source := G_MODULE_SOURCE || 'map_entity_changes_rec: ';
142   l_found := false;
143 
144   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
145   then
146     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
147   end if;
148 
149   open cur_entity_changes;
150   fetch cur_entity_changes into l_rec;
151   l_found := cur_entity_changes%found;
152   if (cur_entity_changes%notfound)
153   then
154     raise fnd_oid_util.event_not_found_exp;
155   end if;
156 
157   p_entity_changes_rec.entity_type := l_rec.entity_type;
158   p_entity_changes_rec.entity_key_value := l_rec.entity_key_value;
159   p_entity_changes_rec.flavor := l_rec.flavor;
160   p_entity_changes_rec.change_date := l_rec.change_date;
161   p_entity_changes_rec.change_date_in_char := l_rec.change_date_in_char;
162 
163   select wf_entity_changes_s.nextval
164     into p_entity_changes_rec.entity_id
165     from dual;
166 
167   update wf_entity_changes
168      set entity_id = p_entity_changes_rec.entity_id
169    where current of cur_entity_changes;
170 
171   close cur_entity_changes;
172 
173   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
174   then
175     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
176   end if;
177 
178 exception
179   when fnd_oid_util.event_not_found_exp then
180     if (cur_entity_changes%isopen)
181     then
182       close cur_entity_changes;
183     end if;
184 
185     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
186     then
187       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source
188         , 'No more changes in WF_ENTITY_CHANGES');
189     end if;
190     raise;
191 
192   when others then
193     if (cur_entity_changes%isopen)
194     then
195       close cur_entity_changes;
196     end if;
197 
198     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
199     then
200       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
201     end if;
202     raise;
203 end map_entity_changes_rec;
204 --
205 -------------------------------------------------------------------------------
206 procedure map_ldap_attr_list(
207     p_entity_type       in            wf_attribute_cache.entity_type%type
208   , p_entity_key_value  in            wf_attribute_cache.entity_key_value%type
209   , p_ldap_key          in out nocopy fnd_oid_util.ldap_key_type
210   , p_ldap_attr_list    out    nocopy ldap_attr_list
211 ) is
212 
213   cursor cur_attribute_cache is
214     select attribute_name
215            , attribute_value
216            , decode(attribute_value, '*NULL*', 1, 2) attr_mod_op
217       from wf_attribute_cache
218      where entity_type = p_entity_type
219        and entity_key_value = p_entity_key_value
220        and attribute_name <> fnd_oid_util.G_CACHE_CHANGED;
221  cursor cur_user_guid is
222    select user_guid
223     from fnd_user
224    where user_name = p_entity_key_value;
225 
226   l_module_source   varchar2(256);
227   l_pwd             varchar2(256);
228   l_index           number;
229   l_attribute_value varchar2(4000);
230   l_ldap_attr       ldap_attr;
231   l_start_date      date;
232   l_end_date        date;
233   l_username_changed boolean;
234   l_oid_nickname fnd_user.user_name%type;
235   l_old_fnd_username fnd_user.user_name%type;
236   l_new_fnd_username fnd_user.user_name%type;
237   l_nicknameattr varchar2(256);
238 
239 begin
240   l_module_source := G_MODULE_SOURCE || 'map_ldap_attr_list: ';
241 
242   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
243   then
244     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
245     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
246       , 'p_entity_type = ' || p_entity_type ||
247       ', p_entity_key_value = ' || p_entity_key_value);
248   end if;
249 
250   p_ldap_attr_list := ldap_attr_list();
251   l_index := 1;
252   l_username_changed := false;
253   l_nicknameattr:= upper(fnd_oid_plug.getNickNameAttr(p_entity_key_value));
254   for l_rec in cur_attribute_cache
255   loop
256     if (l_rec.attribute_name = 'OLD_USER_NAME') then
257       l_username_changed := true;
258       l_old_fnd_username := l_rec.attribute_value;
259     end if;
260 
261     if (l_rec.attribute_name = 'USER_NAME') then
262       l_new_fnd_username := l_rec.attribute_value;
263     end if;
264 
265     if (l_rec.attribute_name = fnd_oid_util.G_ORCLGUID)
266     then
267       p_ldap_key.orclGUID := l_rec.attribute_value;
268 
269     elsif (l_rec.attribute_name = fnd_oid_util.G_SN)
270     then
271       p_ldap_key.sn := l_rec.attribute_value;
272 
273     elsif (l_rec.attribute_name = fnd_oid_util.G_CN)
274     then
275       p_ldap_key.cn := l_rec.attribute_value;
276 
277     elsif (l_rec.attribute_name = fnd_oid_util.G_ORCLACTIVESTARTDATE)
278     then
279       l_start_date := to_date(substr(l_rec.attribute_value,1,14), fnd_oid_util.G_YYYYMMDDHH24MISS);
280       p_ldap_key.orclActiveStartDate :=
281         to_date(substr(l_rec.attribute_value,1,14), fnd_oid_util.G_YYYYMMDDHH24MISS);
282     elsif (l_rec.attribute_name = fnd_oid_util.G_ORCLACTIVEENDDATE)
283     then
284      l_end_date := to_date(substr(l_rec.attribute_value,1,14), fnd_oid_util.G_YYYYMMDDHH24MISS);
285      p_ldap_key.orclActiveEndDate :=
286         to_date(substr(l_rec.attribute_value,1,14), fnd_oid_util.G_YYYYMMDDHH24MISS);
287 
288     elsif (l_rec.attribute_name = fnd_oid_util.G_ORCLISENABLED)
289     then
290       -- Elan, 18-MAR-2003. Skip the attribute, we'll compute it ourselves
291       -- based on start_date and end_date.
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
295             , 'Skipping attribute: ' || l_rec.attribute_name ||
296             ' - will be computed later with start_date and end_date');
297       end if;
298 
299     elsif (l_rec.attribute_name = fnd_oid_util.G_USERPASSWORD)
300     then
301       l_pwd := fnd_web_sec.get_reencrypted_password(
302         p_entity_key_value, fnd_oid_util.get_key(), fnd_oid_util.G_OID);
303 
304       if (l_pwd is not null
305         and l_pwd <> fnd_oid_util.G_INVALID
306         and l_pwd <> fnd_oid_util.G_EXTERNAL)
307       then
308         l_attribute_value := rawtohex(utl_raw.cast_to_raw(l_pwd));
309         l_ldap_attr := ldap_attr(
310             l_rec.attribute_name
311           , l_attribute_value
312           , null
313           , length(l_attribute_value)
314           , wf_oid.ATTR_TYPE_ENCRYPTED_STRING
315           , l_rec.attr_mod_op);
316         p_ldap_attr_list.extend;
317         p_ldap_attr_list(l_index) := l_ldap_attr;
318         l_index := l_index + 1;
319       end if;
320 
321     else
322       -- Fix bug 4231203: REMOVE NICKNAME/USER_NAME ATTRIBUTE FROM LDAP ATTRIBUTE LISTS
323       -- Handle USER_NAME later
324 
325       if (l_rec.attribute_name <> l_nicknameattr
326           and l_rec.attribute_name <> 'USER_NAME') then
327           l_ldap_attr := ldap_attr(
328             l_rec.attribute_name
329           , l_rec.attribute_value
330           , null
331           , length(l_rec.attribute_value)
332           , wf_oid.ATTR_TYPE_STRING
333           , l_rec.attr_mod_op);
334           p_ldap_attr_list.extend;
335           p_ldap_attr_list(l_index) := l_ldap_attr;
336           l_index := l_index + 1;
337      end if;
338 
339 --      if (l_rec.attribute_name = fnd_oid_util.G_ORCLACTIVESTARTDATE)
340 --      then
341 --        l_start_date := to_date(substr(l_rec.attribute_value,1,14), fnd_oid_util.G_YYYYMMDDHH24MISS);
342 --         null;
343 --      end if;
344 --
345 --      if (l_rec.attribute_name = fnd_oid_util.G_ORCLACTIVEENDDATE)
346 --      then
347 --        l_end_date := to_date(substr(l_rec.attribute_value,1,14), fnd_oid_util.G_YYYYMMDDHH24MISS);
348 --        null;
349 --      end if;
350 
351     end if;
352 
353     if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
354     then
355       fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
356         , 'l_ldap_attr(' || (l_index - 1) || ') = ' ||
357         fnd_oid_util.get_ldap_attr_str(l_ldap_attr));
358     end if;
359 
360   end loop;
361 
362 
363  if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
364   then
365     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Computing ORCLISENABLED l_start_date:: '||
366     to_char(l_start_date, fnd_oid_util.G_YYYYMMDDHH24MISS) ||' l_end_date:: '||
367     to_char(l_end_date, fnd_oid_util.G_YYYYMMDDHH24MISS));
368   end if;
369 
370   -- Translate start/end dates into orclIsEnabled --
371   if ((l_start_date is not null and l_start_date > sysdate)
372     or
373       (l_end_date is not null and l_end_date <= sysdate))
374   then
375    if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
376    then
377      fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Setting ORCLISENABLED to DISABLED');
378    end if;
379    p_ldap_key.orclisEnabled := fnd_oid_util.G_DISABLED;
380   else
381    if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
382    then
383      fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Setting ORCLISENABLED to ENABLED');
384    end if;
388   l_ldap_attr := ldap_attr(fnd_oid_util.G_ORCLISENABLED
385     p_ldap_key.orclisEnabled := fnd_oid_util.G_ENABLED;
386   end if;
387 
389     , p_ldap_key.orclisEnabled
390     , null
391     , length(p_ldap_key.orclisEnabled), wf_oid.ATTR_TYPE_STRING
392     , WF_OID.MOD_REPLACE);
393   p_ldap_attr_list.extend;
394   p_ldap_attr_list(l_index) := l_ldap_attr;
395   l_index := l_index + 1;
396 
397   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
398   then
399       fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
400         , 'l_ldap_attr(' || (l_index - 1) || ') = ' ||
401         fnd_oid_util.get_ldap_attr_str(l_ldap_attr));
402   end if;
403 
404 
405 -- Is this really new user? Guid in cache may not be up-to-date.
406  if (p_ldap_key.orclGUID is null) then
407   open cur_user_guid;
408   fetch cur_user_guid into p_ldap_key.orclGUID;
409   close cur_user_guid;
410  end if;
411 
412   -- This is a brand new user as far as we know
413   -- Sync SN and CN only if IDENTITY_ADD
414 
415   if (p_ldap_key.orclGUID is null) then
416     l_ldap_attr := ldap_attr(
417         fnd_oid_util.G_SN
418       , p_ldap_key.sn
419       , null
420       , length(p_ldap_key.sn)
421       , wf_oid.ATTR_TYPE_STRING
422       , WF_OID.MOD_REPLACE);
423 
424     p_ldap_attr_list.extend;
425     p_ldap_attr_list(l_index) := l_ldap_attr;
426     l_index := l_index + 1;
427 
428     if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
429     then
430       fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
431         , 'l_ldap_attr(' || (l_index - 1) || ') = ' ||
432         fnd_oid_util.get_ldap_attr_str(l_ldap_attr));
433     end if;
434     l_ldap_attr := ldap_attr(
435         fnd_oid_util.G_CN
436       , p_ldap_key.cn
437       , null
438       , length(p_ldap_key.cn)
439       , wf_oid.ATTR_TYPE_STRING
440       , WF_OID.MOD_REPLACE);
441     p_ldap_attr_list.extend;
442     p_ldap_attr_list(l_index) := l_ldap_attr;
443     l_index := l_index + 1;
444     --Add USER_NAME if new user
445     l_ldap_attr := ldap_attr(
446         'USER_NAME'
447       , p_ldap_key.cn
448       , null
449       , length(p_ldap_key.cn)
450       , wf_oid.ATTR_TYPE_STRING
451       , WF_OID.MOD_REPLACE);
452     p_ldap_attr_list.extend;
453     p_ldap_attr_list(l_index) := l_ldap_attr;
454     l_index := l_index + 1;
455 
456     if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
457     then
458       fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
459         , 'l_ldap_attr(' || (l_index - 1) || ') = ' ||
460         fnd_oid_util.get_ldap_attr_str(l_ldap_attr));
461     end if;
462   else
463    l_oid_nickname := upper(fnd_oid_util.get_oid_nickname(p_ldap_key.orclGUID));
464    if l_username_changed and l_oid_nickname = l_old_fnd_username then
465     -- Fixed bug 4309356:
466     --Change USER_NAME - but only if old fnd and OID user names are the same
467     l_ldap_attr := ldap_attr(
468         'USER_NAME'
469       , l_new_fnd_username
470       , null
471       , length(l_new_fnd_username)
472       , wf_oid.ATTR_TYPE_STRING
473       , WF_OID.MOD_REPLACE);
474     p_ldap_attr_list.extend;
475     p_ldap_attr_list(l_index) := l_ldap_attr;
476     l_index := l_index + 1;
477    end if;
478   end if;
479 
480   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
481   then
482     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
483   end if;
484 
485 exception
486   when others then
487     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
488     then
489       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
490     end if;
491 
492     raise;
493 end map_ldap_attr_list;
494 --
495 -------------------------------------------------------------------------------
496 procedure map_ldap_message(
497     p_wf_event      in wf_event_t
498   , p_event_type    in varchar2
499   , p_ldap_message  in out nocopy fnd_oid_util.ldap_message_type
500 ) is
501 
502   l_module_source varchar2(256);
503 
504 begin
505   l_module_source := G_MODULE_SOURCE || 'map_ldap_message: ';
506 
507   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
508   then
509     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
510   end if;
511 
512   p_ldap_message.object_name := p_wf_event.GetEventKey;
513 
514  p_ldap_message.sn := wf_entity_mgr.get_attribute_value(p_event_type,
515     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.sn);
516 
517   if (p_ldap_message.sn in ('*UNKNOWN*','*NULL*')) then
518     p_ldap_message.sn := null;
519  end if;
520 
521    if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
522   then
523     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Surname is:' ||  p_ldap_message.sn
524     || ', attribute name is: ' || fnd_oid_util.G_LDAP_MESSAGE_ATTR.sn);
525   end if;
526 
527   p_ldap_message.cn := wf_entity_mgr.get_attribute_value(p_event_type,
528     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.cn);
529 
530    if (p_ldap_message.cn in ('*UNKNOWN*','*NULL*')) then
531     p_ldap_message.cn := null;
532    end if;
533 
534   p_ldap_message.userPassword := wf_entity_mgr.get_attribute_value(p_event_type,
535     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.userPassword);
536 
537 
538   p_ldap_message.telephoneNumber := wf_entity_mgr.get_attribute_value(p_event_type,
539     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.telephoneNumber);
540 
544 
541    if (p_ldap_message.telephoneNumber in ('*UNKNOWN*','*NULL*')) then
542       p_ldap_message.telephoneNumber := null;
543    end if;
545   p_ldap_message.street := wf_entity_mgr.get_attribute_value(p_event_type,
546     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.street);
547 
548    if (p_ldap_message.street in ('*UNKNOWN*','*NULL*')) then
549       p_ldap_message.street := null;
550   end if;
551 
552   p_ldap_message.postalCode := wf_entity_mgr.get_attribute_value(p_event_type,
553     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.postalCode);
554 
555   if (p_ldap_message.postalCode in ('*UNKNOWN*','*NULL*')) then
556       p_ldap_message.postalCode := null;
557   end if;
558 
559   p_ldap_message.physicalDeliveryOfficeName := wf_entity_mgr.get_attribute_value(p_event_type,
560     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.physicalDeliveryOfficeName);
561 
562    if (p_ldap_message.physicalDeliveryOfficeName in ('*UNKNOWN*','*NULL*')) then
563       p_ldap_message.physicalDeliveryOfficeName := null;
564   end if;
565 
566   p_ldap_message.st := wf_entity_mgr.get_attribute_value(p_event_type,
567     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.st);
568 
569   if (p_ldap_message.st in ('*UNKNOWN*','*NULL*')) then
570       p_ldap_message.st := null;
571   end if;
572 
573   p_ldap_message.l := wf_entity_mgr.get_attribute_value(p_event_type,
574     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.l);
575 
576   if (p_ldap_message.l in ('*UNKNOWN*','*NULL*')) then
577       p_ldap_message.l := null;
578   end if;
579 
580   p_ldap_message.displayName := wf_entity_mgr.get_attribute_value(p_event_type,
581     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.displayName);
582 
583   if (p_ldap_message.displayName in ('*UNKNOWN*','*NULL*')) then
584       p_ldap_message.displayName := null;
585   end if;
586 
587   p_ldap_message.givenName := wf_entity_mgr.get_attribute_value(p_event_type,
588     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.givenName);
589 
590   if (p_ldap_message.givenName in ('*UNKNOWN*','*NULL*')) then
591       p_ldap_message.givenName := null;
592   end if;
593 
594    if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
595   then
596     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Given name is:' ||  p_ldap_message.givenName
597     || ', attribute name is: ' || fnd_oid_util.G_LDAP_MESSAGE_ATTR.givenName);
598   end if;
599 
600   p_ldap_message.homePhone := wf_entity_mgr.get_attribute_value(p_event_type,
601     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.homePhone);
602 
603   if (p_ldap_message.homePhone in ('*UNKNOWN*','*NULL*')) then
604       p_ldap_message.homePhone := null;
605   end if;
606 
607   p_ldap_message.mail := wf_entity_mgr.get_attribute_value(p_event_type,
608     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.mail);
609 
610    if (p_ldap_message.mail in ('*UNKNOWN*','*NULL*')) then
611       p_ldap_message.mail := null;
612   end if;
613 
614   p_ldap_message.c := wf_entity_mgr.get_attribute_value(p_event_type,
615     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.c);
616 
617    if (p_ldap_message.c in ('*UNKNOWN*','*NULL*')) then
618       p_ldap_message.c := null;
619   end if;
620 
621   p_ldap_message.facsimileTelephoneNumber := wf_entity_mgr.get_attribute_value(p_event_type,
622     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.facsimileTelephoneNumber);
623 
624    if (p_ldap_message.facsimileTelephoneNumber in ('*UNKNOWN*','*NULL*')) then
625       p_ldap_message.facsimileTelephoneNumber := null;
626   end if;
627 
628   p_ldap_message.description := wf_entity_mgr.get_attribute_value(p_event_type,
629     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.description);
630 
631    if (p_ldap_message.description in ('*UNKNOWN*','*NULL*')) then
632       p_ldap_message.description := null;
633   end if;
634 
635   p_ldap_message.orclisEnabled := wf_entity_mgr.get_attribute_value(p_event_type,
636     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclisEnabled);
637 
638   p_ldap_message.orclActiveStartDate := wf_entity_mgr.get_attribute_value(p_event_type,
639     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclActiveStartDate);
640 
641   p_ldap_message.orclActiveEndDate := wf_entity_mgr.get_attribute_value(p_event_type,
642     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclActiveEndDate);
643 
644   p_ldap_message.orclGUID := wf_entity_mgr.get_attribute_value(p_event_type,
645     p_ldap_message.object_name, fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclGUID);
646 
647   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
648   then
649     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
650   end if;
651 
652 exception
653   when others then
654     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
655     then
656       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
657     end if;
658     raise;
659 end map_ldap_message;
660 --
661 -------------------------------------------------------------------------------
662 procedure map_ldap_message(
663     p_user_name    in fnd_user.user_name%type
664   , p_ldap_attr_list   in ldap_attr_list
665   , p_ldap_message  in out nocopy fnd_oid_util.ldap_message_type
666 ) is
667 
668   l_module_source varchar2(256);
669 begin
670   l_module_source := G_MODULE_SOURCE || 'map_ldap_message: ';
671 
672   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
673   then
674     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
675   end if;
676 
680     for j in p_ldap_attr_list.first .. p_ldap_attr_list.last
677   p_ldap_message.object_name := p_user_name;
678   if (p_ldap_attr_list is not null AND p_ldap_attr_list.count > 0)
679   then
681     loop
682       if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
683       then
684         fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
685           , 'p_ldap_attr_list(' || j || ') = ' ||
686           fnd_oid_util.get_ldap_attr_str(p_ldap_attr_list(j)));
687       end if;
688 
689 
690       if (upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.sn)
691       then
692         p_ldap_message.sn := p_ldap_attr_list(j).attr_value;
693 
694          if (p_ldap_message.sn in ('*UNKNOWN*','*NULL*')) then
695             p_ldap_message.sn := null;
696          end if;
697 
698 
699       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.cn)
700       then
701         p_ldap_message.cn := p_ldap_attr_list(j).attr_value;
702         if (p_ldap_message.cn in ('*UNKNOWN*','*NULL*')) then
703             p_ldap_message.cn := null;
704         end if;
705 
706       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.telephoneNumber)
707       then
708         p_ldap_message.telephoneNumber := p_ldap_attr_list(j).attr_value;
709         if (p_ldap_message.telephoneNumber in ('*UNKNOWN*','*NULL*')) then
710             p_ldap_message.telephoneNumber := null;
711         end if;
712 
713       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.street)
714       then
715         p_ldap_message.street := p_ldap_attr_list(j).attr_value;
716           if (p_ldap_message.street in ('*UNKNOWN*','*NULL*')) then
717               p_ldap_message.street := null;
718           end if;
719 
720       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.postalCode)
721       then
722         p_ldap_message.postalCode := p_ldap_attr_list(j).attr_value;
723         if (p_ldap_message.postalCode in ('*UNKNOWN*','*NULL*')) then
724             p_ldap_message.postalCode := null;
725         end if;
726 
727       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.physicalDeliveryOfficeName)
728       then
729         p_ldap_message.physicalDeliveryOfficeName := p_ldap_attr_list(j).attr_value;
730          if (p_ldap_message.physicalDeliveryOfficeName in ('*UNKNOWN*','*NULL*')) then
731              p_ldap_message.physicalDeliveryOfficeName := null;
732          end if;
733 
734       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.st)
735       then
736          p_ldap_message.st := p_ldap_attr_list(j).attr_value;
737         if (p_ldap_message.st in ('*UNKNOWN*','*NULL*')) then
738             p_ldap_message.st := null;
739         end if;
740 
741       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.l)
742       then
743         p_ldap_message.l := p_ldap_attr_list(j).attr_value;
744         if (p_ldap_message.l in ('*UNKNOWN*','*NULL*')) then
745            p_ldap_message.l := null;
746         end if;
747 
748       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.displayName)
749       then
750         p_ldap_message.displayName := p_ldap_attr_list(j).attr_value;
751         if (p_ldap_message.displayName in ('*UNKNOWN*','*NULL*')) then
752           p_ldap_message.displayName := null;
753         end if;
754 
755       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.givenName)
756       then
757          p_ldap_message.givenName := p_ldap_attr_list(j).attr_value;
758          if (p_ldap_message.givenName in ('*UNKNOWN*','*NULL*')) then
759            p_ldap_message.givenName := null;
760          end if;
761 
762       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.homePhone)
763       then
764          p_ldap_message.homePhone := p_ldap_attr_list(j).attr_value;
765          if (p_ldap_message.homePhone in ('*UNKNOWN*','*NULL*')) then
766             p_ldap_message.homePhone := null;
767          end if;
768 
769       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.mail)
770       then
771         p_ldap_message.mail := p_ldap_attr_list(j).attr_value;
772           if (p_ldap_message.mail in ('*UNKNOWN*','*NULL*')) then
773               p_ldap_message.mail := null;
774           end if;
775 
776       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.c)
777       then
778         p_ldap_message.c := p_ldap_attr_list(j).attr_value;
779         if (p_ldap_message.c in ('*UNKNOWN*','*NULL*')) then
780             p_ldap_message.c := null;
781          end if;
782 
783       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.facsimileTelephoneNumber)
784       then
785         p_ldap_message.facsimileTelephoneNumber := p_ldap_attr_list(j).attr_value;
786         if (p_ldap_message.facsimileTelephoneNumber in ('*UNKNOWN*','*NULL*')) then
787             p_ldap_message.facsimileTelephoneNumber := null;
788          end if;
789 
790       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.description)
791       then
792         p_ldap_message.description := p_ldap_attr_list(j).attr_value;
793         if (p_ldap_message.description in ('*UNKNOWN*','*NULL*')) then
794             p_ldap_message.description := null;
795         end if;
796 
797       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclisEnabled)
798       then
799         p_ldap_message.orclisEnabled := p_ldap_attr_list(j).attr_value;
800 
801       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclActiveStartDate)
802       then
803         p_ldap_message.orclActiveStartDate := p_ldap_attr_list(j).attr_value;
804 
805       elsif(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclActiveEndDate)
806       then
807         p_ldap_message.orclActiveEndDate := p_ldap_attr_list(j).attr_value;
808       else
809 
810         if(upper(p_ldap_attr_list(j).attr_name)= fnd_oid_util.G_LDAP_MESSAGE_ATTR.orclGUID)
811         then
812           p_ldap_message.orclGUID := p_ldap_attr_list(j).attr_value;
813         end if;
814       end if;
815     end loop;
816   end if;
817 
818   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
819   then
820     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
821       , 'End');
822   end if;
823 
824 exception
825 when others then
826     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
827     then
828       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
829     end if;
830 
831     raise;
832 end map_ldap_message;
833 --
834 -------------------------------------------------------------------------------
835 procedure map_oid_event(
836     p_ldap_key            in          fnd_oid_util.ldap_key_type
837   , p_entity_changes_rec  in          fnd_oid_util.wf_entity_changes_rec_type
838   , p_ldap_attr_list      in          ldap_attr_list
839   , p_event               out nocopy  ldap_event
840 ) is
841 
842   l_module_source varchar2(256);
843 
844 begin
845   l_module_source := G_MODULE_SOURCE || 'map_oid_event: ';
846 
847   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
848   then
849     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
850   end if;
851 
852   if (p_ldap_key.orclGUID is null
853     and p_entity_changes_rec.entity_type = fnd_oid_util.G_USER)
854   then
855     p_event := ldap_event(
856         event_type  => wf_oid.IDENTITY_ADD
857       , event_id    => to_char(p_entity_changes_rec.entity_id)
858       , event_src   => fnd_oid_util.G_EBIZ
859       , event_time  => p_entity_changes_rec.change_date_in_char
860       , object_name => p_entity_changes_rec.entity_key_value
861       , object_type => p_entity_changes_rec.flavor
862       , object_guid => null
863       , object_dn   => null
864       , profile_id  => fnd_oid_util.G_NOT_FOR_IMPORT
865       , attr_list   => p_ldap_attr_list);
866   elsif (p_entity_changes_rec.entity_type = wf_oid.SUBSCRIPTION_ADD)
867   then
868     p_event := ldap_event(
869         event_type  => wf_oid.SUBSCRIPTION_ADD
870       , event_id    => to_char(p_entity_changes_rec.entity_id)
871       , event_src   => fnd_oid_util.G_EBIZ
872       , event_time  => p_entity_changes_rec.change_date_in_char
873       , object_name => p_entity_changes_rec.entity_key_value
874       , object_type => p_entity_changes_rec.flavor
875       , object_guid => p_ldap_key.orclGUID
876       , object_dn   => null
877       , profile_id  => fnd_oid_util.G_NOT_FOR_IMPORT
878       , attr_list   => null);
879 
880   elsif (p_entity_changes_rec.entity_type = fnd_oid_util.G_USER)
881   then
882     p_event := ldap_event(
883         event_type  => wf_oid.IDENTITY_MODIFY
884       , event_id    => to_char(p_entity_changes_rec.entity_id)
885       , event_src   => fnd_oid_util.G_EBIZ
886       , event_time  => p_entity_changes_rec.change_date_in_char
887       , object_name => null
888       , object_type => p_entity_changes_rec.flavor
889       , object_guid => p_ldap_key.orclGUID
890       , object_dn   => null
891       , profile_id  => fnd_oid_util.G_NOT_FOR_IMPORT
892       , attr_list   => p_ldap_attr_list);
893 
894   elsif (p_entity_changes_rec.entity_type = wf_oid.SUBSCRIPTION_DELETE)
895   then
896     p_event := ldap_event(
897         event_type  => wf_oid.SUBSCRIPTION_DELETE
898       , event_id    => to_char(p_entity_changes_rec.entity_id)
899       , event_src   => fnd_oid_util.G_EBIZ
900       , event_time  => p_entity_changes_rec.change_date_in_char
901       , object_name => null
902       , object_type => p_entity_changes_rec.flavor
903       , object_guid => p_ldap_key.orclGUID
904       , object_dn   => null
905       , profile_id  => fnd_oid_util.G_NOT_FOR_IMPORT
906       , attr_list   => null);
907 
908   end if;
909 
910   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
911   then
912     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
913   end if;
914 
915 exception
916   when others then
917     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
918     then
919       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
920     end if;
921 end map_oid_event;
922 --
923 -------------------------------------------------------------------------------
924 end fnd_ldap_mapper;