35: end CanSync;
36:
37: --
38: -------------------------------------------------------------------------------
39: function get_ldap_user_name(p_user_name in fnd_user.user_name%type) return varchar2 is
40:
41: l_module_source varchar2(256);
42: l_result varchar2(4000);
43: l_user_guid fnd_user.user_guid%type;
39: function get_ldap_user_name(p_user_name in fnd_user.user_name%type) return varchar2 is
40:
41: l_module_source varchar2(256);
42: l_result varchar2(4000);
43: l_user_guid fnd_user.user_guid%type;
44: l_found boolean;
45:
46: l_apps_sso varchar2(50);
47: l_profile_defined boolean;
51: sso_registration_failure exception;
52: l_sso_version varchar2(10);
53: l_allow_sync varchar2(1);
54:
55: cursor cur_fnd_users is
56: select user_guid
57: from fnd_user
58: where user_name = upper(p_user_name);
59: begin
53: l_allow_sync varchar2(1);
54:
55: cursor cur_fnd_users is
56: select user_guid
57: from fnd_user
58: where user_name = upper(p_user_name);
59: begin
60: l_module_source := G_MODULE_SOURCE || 'get_ldap_user_name ';
61: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
100: end if;
101:
102: if (registered) then
103: l_found := false;
104: open cur_fnd_users;
105: fetch cur_fnd_users into l_user_guid;
106: l_found := cur_fnd_users%found;
107:
108: if (fnd_log.LEVEL_EXCEPTION >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
101:
102: if (registered) then
103: l_found := false;
104: open cur_fnd_users;
105: fetch cur_fnd_users into l_user_guid;
106: l_found := cur_fnd_users%found;
107:
108: if (fnd_log.LEVEL_EXCEPTION >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
109: then
102: if (registered) then
103: l_found := false;
104: open cur_fnd_users;
105: fetch cur_fnd_users into l_user_guid;
106: l_found := cur_fnd_users%found;
107:
108: if (fnd_log.LEVEL_EXCEPTION >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
109: then
110: fnd_log.string(fnd_log.LEVEL_EXCEPTION, l_module_source,
119: else
120: if (fnd_log.LEVEL_EXCEPTION >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
121: then
122: fnd_log.string(fnd_log.LEVEL_EXCEPTION, l_module_source,
123: 'no such user in FND_USER: '||p_user_name);
124: end if;
125: l_result := null;
126: end if;
127: close cur_fnd_users;
123: 'no such user in FND_USER: '||p_user_name);
124: end if;
125: l_result := null;
126: end if;
127: close cur_fnd_users;
128:
129: else -- if (!registered)
130: if (fnd_log.LEVEL_EXCEPTION >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
131: then
159: end if;
160: return l_result;
161: exception
162: when sso_registration_failure then
163: if (cur_fnd_users%isopen)
164: then
165: close cur_fnd_users;
166: end if;
167: if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
161: exception
162: when sso_registration_failure then
163: if (cur_fnd_users%isopen)
164: then
165: close cur_fnd_users;
166: end if;
167: if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
168: then
169: fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
171: l_result := null;
172: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
173: return l_result;
174: when others then
175: if (cur_fnd_users%isopen)
176: then
177: close cur_fnd_users;
178: end if;
179: if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
173: return l_result;
174: when others then
175: if (cur_fnd_users%isopen)
176: then
177: close cur_fnd_users;
178: end if;
179: if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
180: then
181: fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
191: x_result out nocopy pls_integer) is
192:
193: l_module_source varchar2(256);
194: plsql_block varchar2(500);
195: l_fnd_user pls_integer;
196: l_oid pls_integer;
197: l_attribute varchar2(4000);
198: l_realm varchar2(4000);
199:
210: is_operation_allowed(p_realm=> l_realm, p_direction => G_EBIZ_TO_OID,
211: p_entity => G_IDENTITY,
212: p_operation => G_MODIFY,
213: x_attribute => l_attribute,
214: x_fnd_user => l_fnd_user,
215: x_oid => l_oid);
216:
217: if (l_oid = G_SUCCESS) then
218:
225: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
226: then
227: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_oid is false');
228: end if;
229: x_result := l_fnd_user;
230:
231: end if;
232:
233: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
249:
250: end change_user_name;
251: --
252: -------------------------------------------------------------------------------
253: procedure synch_user_from_LDAP(p_user_name in fnd_user.user_name%type
254: , p_result out nocopy pls_integer) is
255: l_module_source varchar2(256);
256: l_apps_sso varchar2(50);
257: l_profile_defined boolean;
356: x_result out nocopy pls_integer) is
357:
358: l_module_source varchar2(256);
359: plsql_block varchar2(500);
360: l_fnd_user pls_integer;
361: l_oid pls_integer;
362: l_attribute varchar2(4000);
363: l_allowed boolean;
364: l_password varchar2(400);
393: is_operation_allowed(p_realm=>l_realm,p_direction => G_EBIZ_TO_OID,
394: p_entity => G_IDENTITY,
395: p_operation => G_ADD,
396: x_attribute => l_attribute,
397: x_fnd_user => l_fnd_user,
398: x_oid => l_oid);
399:
400: if (l_oid = G_SUCCESS) then
401: /* don't handle userpassword now
454: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
455: then
456: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_oid is false');
457: end if;
458: x_result := l_fnd_user;
459:
460: end if; -- l_oid
461:
462: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
508: x_result out nocopy pls_integer) is
509:
510: l_module_source varchar2(256);
511: plsql_block varchar2(500);
512: l_fnd_user pls_integer;
513: l_oid pls_integer;
514: l_attribute varchar2(4000);
515: l_new_pwd varchar2(4000);
516: l_realm varchar2(4000);
529: is_operation_allowed(p_realm=>l_realm,p_direction => G_EBIZ_TO_OID,
530: p_entity => G_IDENTITY,
531: p_operation => G_MODIFY,
532: x_attribute => l_attribute,
533: x_fnd_user => l_fnd_user,
534: x_oid => l_oid);
535:
536: if (l_oid = G_SUCCESS) then
537: if (p_new_pwd<>FND_WEB_SEC.EXTERNAL_PWD and p_new_pwd<>'EXTERNAL' ) then
549: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
550: then
551: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Password Sync Not Allowed');
552: end if;
553: x_result := l_fnd_user;
554:
555: end if; -- l_oid
556:
557: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
573:
574: end change_password;
575: --
576: -------------------------------------------------------------------------------
577: procedure delete_user(p_user_guid in fnd_user.user_guid%type,
578: x_result out nocopy pls_integer) is
579:
580: l_module_source varchar2(256);
581: plsql_block varchar2(500);
578: x_result out nocopy pls_integer) is
579:
580: l_module_source varchar2(256);
581: plsql_block varchar2(500);
582: l_fnd_user pls_integer;
583: l_oid pls_integer;
584: l_attribute varchar2(4000);
585: l_realm varchar2(4000);
586:
596: is_operation_allowed(p_realm=>l_realm,p_direction => G_EBIZ_TO_OID,
597: p_entity => G_IDENTITY,
598: p_operation => G_DELETE,
599: x_attribute => l_attribute,
600: x_fnd_user => l_fnd_user,
601: x_oid => l_oid);
602:
603: if (l_oid = G_SUCCESS) then
604:
611: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
612: then
613: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_oid is false');
614: end if;
615: x_result := l_fnd_user;
616:
617: end if; -- l_oid
618:
619: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
641: x_result out nocopy pls_integer) is
642:
643: l_module_source varchar2(256);
644: plsql_block varchar2(500);
645: l_fnd_user pls_integer;
646: l_oid pls_integer;
647: l_attribute varchar2(4000);
648: l_realm varchar2(4000);
649:
660: is_operation_allowed(p_realm=>l_realm,p_direction => G_EBIZ_TO_OID,
661: p_entity => G_SUBSCRIPTION,
662: p_operation => G_ADD,
663: x_attribute => l_attribute,
664: x_fnd_user => l_fnd_user,
665: x_oid => l_oid);
666:
667: if (l_oid = G_SUCCESS) then
668:
676: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
677: then
678: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_oid id false');
679: end if;
680: x_result := l_fnd_user;
681:
682: end if; -- l_oid
683:
684: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
700:
701: end link_user;
702: --
703: -------------------------------------------------------------------------------
704: procedure unlink_user(p_user_guid in fnd_user.user_guid%type,
705: p_user_name in varchar2,
706: x_result out nocopy pls_integer) is
707:
708: l_module_source varchar2(256);
706: x_result out nocopy pls_integer) is
707:
708: l_module_source varchar2(256);
709: plsql_block varchar2(500);
710: l_fnd_user pls_integer;
711: l_oid pls_integer;
712: l_attribute varchar2(4000);
713: l_realm varchar2(4000);
714:
725: is_operation_allowed(p_realm=>l_realm,p_direction => G_EBIZ_TO_OID,
726: p_entity => G_SUBSCRIPTION,
727: p_operation => G_DELETE,
728: x_attribute => l_attribute,
729: x_fnd_user => l_fnd_user,
730: x_oid => l_oid);
731:
732: if (l_oid = G_SUCCESS) then
733:
741: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
742: then
743: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_oid is false');
744: end if;
745: x_result := l_fnd_user;
746:
747: end if; -- l_oid
748:
749: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
896: x_result out nocopy pls_integer) is
897:
898: l_module_source varchar2(256);
899: plsql_block varchar2(500);
900: l_fnd_user pls_integer;
901: l_oid pls_integer;
902: l_attribute varchar2(4000);
903: l_allowed boolean;
904: l_password varchar2(400);
978: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
979: then
980: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_oid is false');
981: end if;
982: x_result := l_fnd_user;
983:
984: end if; -- l_oid
985:
986: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1167: p_operation in pls_integer,
1168: p_user_name in varchar2,
1169: p_user_id in number,
1170: x_attribute in out nocopy varchar2,
1171: x_fnd_user out nocopy pls_integer,
1172: x_oid out nocopy pls_integer) is
1173:
1174: l_module_source varchar2(256);
1175: l_apps_sso varchar2(50);
1183: l_allow_sync varchar2(1);
1184:
1185: -- Bug 9405673 - added for user_id and user_name args to get APPS_SSO_LDAP_SYNC
1186: -- at user level. Default to site if both are null
1187: l_user_id FND_USER.user_ID%TYPE := -1;
1188:
1189:
1190: begin
1191: l_module_source := G_MODULE_SOURCE || 'is_operation_allowed: ';
1194: then
1195: fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
1196: end if;
1197:
1198: x_fnd_user := G_SUCCESS;
1199: x_oid := G_FAILURE;
1200:
1201: if (p_user_id is not null) then
1202:
1212: end if;
1213:
1214: begin
1215: select user_id into l_user_id
1216: from fnd_user
1217: where user_name = p_user_name;
1218: exception when others then
1219: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
1220: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source,'User not found..use site');
1249: ,'Valid registration');
1250: end if;
1251: plsql_block :=
1252: 'begin fnd_sso_registration.is_operation_allowed(:1, :2, :3, :4, :5, :6,null,:7); end;';
1253: execute immediate plsql_block using p_direction, p_entity, p_operation, in out x_attribute, out x_fnd_user, out x_oid,in p_realm;
1254:
1255: elsif(l_registration = FND_LDAP_WRAPPER.G_INVALID_REGISTRATION) then
1256: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
1257: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
1262: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
1263: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source
1264: ,'No registration');
1265: end if;
1266: x_fnd_user := G_SUCCESS;
1267: x_oid := G_FAILURE;
1268: end if;
1269:
1270: else -- APPS_SSO_LDAP_SYNC not enabled.
1277:
1278: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1279: then
1280: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source,
1281: 'out values x_fnd_user: '||x_fnd_user||' x_oid: '||x_oid);
1282: end if;
1283:
1284:
1285: if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1289:
1290: exception
1291: when registration_failure_exception then
1292: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
1293: x_fnd_user := G_FAILURE;
1294: x_oid := G_FAILURE;
1295: raise registration_failure_exception;
1296: when no_data_found then
1297: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
1294: x_oid := G_FAILURE;
1295: raise registration_failure_exception;
1296: when no_data_found then
1297: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
1298: x_fnd_user := G_FAILURE;
1299: x_oid := G_FAILURE;
1300: raise registration_failure_exception;
1301: when others then
1302: fnd_message.set_name ('FND', 'FND_SSO_UNEXP_ERROR');
1308: end is_operation_allowed;
1309: --
1310: -------------------------------------------------------------------------------
1311: procedure is_operation_allowed(p_realm in varchar2,p_operation in pls_integer,
1312: x_fnd_user out nocopy pls_integer,
1313: x_oid out nocopy pls_integer) is
1314:
1315: l_module_source varchar2(256);
1316: l_apps_sso varchar2(50);
1327: then
1328: fnd_log.string(fnd_log.LEVEL_PROCEDURE, l_module_source, 'Begin');
1329: end if;
1330:
1331: x_fnd_user := G_SUCCESS;
1332: x_oid := G_FAILURE;
1333:
1334: fnd_profile.get_specific(
1335: name_z => 'APPS_SSO',
1356:
1357: if (registered) then
1358: plsql_block :=
1359: 'begin fnd_sso_registration.is_operation_allowed(:1, :2, :3,null,:4); end;';
1360: execute immediate plsql_block using p_operation, out x_fnd_user, out x_oid,in p_realm;
1361: else
1362: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1363: then
1364: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'SSO profile enabled but improper regitration');
1372: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1373: then
1374: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'SSO not enabled, returning false');
1375: end if;
1376: x_fnd_user := G_SUCCESS;
1377: x_oid := G_FAILURE;
1378: fnd_message.set_name ('FND', 'FND_SSO_NOT_ENABLED');
1379: end if;
1380:
1380:
1381: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1382: then
1383: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source,
1384: 'out values x_fnd_user: '||x_fnd_user||' x_oid: '||x_oid);
1385: end if;
1386:
1387: if (fnd_log.LEVEL_PROCEDURE >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1388: then
1391:
1392: exception
1393: when sso_registration_failure then
1394: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
1395: x_fnd_user := G_SUCCESS;
1396: x_oid := G_SUCCESS;
1397: when no_data_found then
1398: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
1399: x_fnd_user := G_SUCCESS;
1395: x_fnd_user := G_SUCCESS;
1396: x_oid := G_SUCCESS;
1397: when no_data_found then
1398: fnd_message.set_name ('FND', 'FND_SSO_OID_REG_ERROR');
1399: x_fnd_user := G_SUCCESS;
1400: x_oid := G_SUCCESS;
1401: when others then
1402: fnd_message.set_name ('FND', 'FND_SSO_UNEXP_ERROR');
1403: if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1671:
1672: procedure unlink_ebiz_user(p_user_name in varchar2) is
1673:
1674: l_module_source varchar2(256);
1675: l_user_id fnd_user.user_id%type;
1676: l_user_name fnd_user.user_name%type;
1677: l_user_guid fnd_user.user_guid%type;
1678: l_local_login varchar2(10);
1679: l_profile_defined boolean;
1672: procedure unlink_ebiz_user(p_user_name in varchar2) is
1673:
1674: l_module_source varchar2(256);
1675: l_user_id fnd_user.user_id%type;
1676: l_user_name fnd_user.user_name%type;
1677: l_user_guid fnd_user.user_guid%type;
1678: l_local_login varchar2(10);
1679: l_profile_defined boolean;
1680: l_result pls_integer;
1673:
1674: l_module_source varchar2(256);
1675: l_user_id fnd_user.user_id%type;
1676: l_user_name fnd_user.user_name%type;
1677: l_user_guid fnd_user.user_guid%type;
1678: l_local_login varchar2(10);
1679: l_profile_defined boolean;
1680: l_result pls_integer;
1681:
1682: l_del_prof boolean;
1683:
1684: cursor ebiz_users is
1685: select user_name, user_id, user_guid
1686: from fnd_user
1687: where user_name like upper(p_user_name)
1688: and user_guid is not null;
1689:
1690: begin
1713: then
1714: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Unlink user '||l_user_name);
1715: end if;
1716:
1717: update fnd_user
1718: set user_guid = null
1719: where user_name = l_user_name and user_guid is not null;
1720:
1721: fnd_profile.get_specific(
1774: close ebiz_users;
1775:
1776: if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
1777: then
1778: fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Done unlinking FND users');
1779: end if;
1780:
1781: END IF;
1782: