Home » Developer & Programmer » Forms » Forms 10g And Filter Data With SSO ID (10.1.2.3.0)
Forms 10g And Filter Data With SSO ID [message #479147] Thu, 14 October 2010 14:18 Go to next message
Kevin58
Messages: 79
Registered: January 2009
Member
Hello Gurus,

I'm having difficulty trying to show a list of forms that I would like to present the user after they log on with SSO.

The funny thing is that I can show the user in a message box.
However, I cannot filter records that the user should have on an "Application" menu. The application menu is designed to allow the user to launch the form by double clicking on the menu item.
That works fine. It is just that I cannot seem to filter. It shows no records.

Here is my WNFI code:
DECLARE
	sso_user varchar2(40);
	
	nn number;
	v_vis VARCHAR2(20);
	
	uid varchar2(50);
  udn varchar2(50);
  sdn varchar2(50);
  
  myid varchar2(8);
  ckid varchar2(8);
  atpos number;
  
  cursor chk_user is
     select ID
        from users
        where id = upper(myid);
        
	
BEGIN

  --set_window_property (forms_mdi_window, window_size, 600, 385);
  set_window_property (forms_mdi_window, window_size, 625, 435);
  set_window_property (forms_mdi_window, position, 0, 0);                
  set_window_property ('Application Menu', window_state, maximize);

  --sso_user := get_application_property(sso_userid);
  --message('SSO User: ' || sso_user);
  --return;
  
  --execute_query;
  --clear_form;
  --clear_message;
  --:system.message_level:=25;
  
	-- get the SSO logon ID
	uid := Get_Application_Property(sso_userid);
	
	-- keep the first portion of the SSO user stopping at the @ sign
	atpos := instr(uid, '@') - 1;
	myid := substr(uid, 1, atpos);
	
	MESSAGE('myid: ' || myid);
	
	open chk_user;
	fetch chk_user into ckid;
	close chk_user;
	
	:GLOBAL.ID := upper(ckid);
	
	--message('ckid is: ' || ckid);
	
	--if uid is null then
      --message('Invalid sso userid is '||uid);
  --end if;

  --udn := Get_Application_Property(sso_usrdn);
  --dbms_output.put_line('sso userid is '||udn);
  --sdn := Get_Application_Property(sso_subdn);
  --dbms_output.put_line('sso userid is '||sdn);

	-- initialize global.id if null
	IF :GLOBAL.ID IS NULL THEN 	
		Default_Value('MARTIN','GLOBAL.ID'); 
	end if;


  ckid := upper(:global.id);
  message('ckid is: ' || ckid);
  
	--IF app_user_security.valid_user(:USERS.id,:USERS.password) then
	if ckid is not null then
		--:GLOBAL.ID := TO_CHAR(ckid); 
		
		v_vis := GET_VIEW_PROPERTY('APPLICATIONS', VISIBLE);
		IF v_vis = 'FALSE' THEN
			SET_VIEW_PROPERTY('APPLICATIONS', VISIBLE, PROPERTY_TRUE);
		END IF;
    GO_BLOCK('AUTHUSER');
    --do_key('enter_query');
    --:authuser.id := :global.id;
    EXECUTE_QUERY;
    clear_message;
    :system.message_level:=25;
	ELSE
		SET_ALERT_PROPERTY ('note_alert', alert_message_text, 
	  'Your Password is incorrect please try again.');
		nn := show_alert('note_alert');
	END IF;
END;

Re: Forms 10g And Filter Data With SSO ID [message #479154 is a reply to message #479147] Thu, 14 October 2010 15:36 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Code would be easier to follow if you
a) removed all comments (as they only make noise)
b) formatted the code
c) said which part is, actually, the one you are talking about

Now some general objections: you don't need a cursor here - the same can be done with a simple SELECT statement.
CKID and :GLOBAL.ID : why do you keep setting it to each other (global.id = ckid, ckid = upper(global.id) ...) all that seems to be unnecessary. Can't you simplify it?
Re: Forms 10g And Filter Data With SSO ID [message #479220 is a reply to message #479154] Fri, 15 October 2010 06:23 Go to previous messageGo to next message
Kevin58
Messages: 79
Registered: January 2009
Member
Ok here is an attempt to "clean up" the code.

All I am really trying to do is see if the SSO ID has any records in the "authuser" data block. And then present them in a list.

The where clause is set to "ID = :GLOBAL.ID".

However, I am getting no records returned when there should be 9 rows.

Here is the simplified WNFI code:
DECLARE
  nn number;	
  uid varchar2(50);
  myid varchar2(8);
  ckid varchar2(8);
  atpos number;
	
BEGIN

  set_window_property (forms_mdi_window, window_size, 625, 435);
  set_window_property (forms_mdi_window, position, 0, 0);                
  set_window_property ('Application Menu', window_state, maximize);
  
  -- get the SSO logon ID
  uid := Get_Application_Property(sso_userid);
	
  -- keep the first portion of the SSO user stopping at the @ sign
  atpos := instr(uid, '@') - 1;
  myid := substr(uid, 1, atpos);
	
  MESSAGE('SSO ID: ' || myid);
	
  select ID into :global.id
      from users
      where id = myid;

  -- initialize global.id if null
  IF :GLOBAL.ID IS NULL THEN 	
     Default_Value('MARTIN','GLOBAL.ID'); 
  end if;

  if :global.id is not null then
    GO_BLOCK('AUTHUSER');
    EXECUTE_QUERY;
  ELSE
     SET_ALERT_PROPERTY ('note_alert', alert_message_text, 
	  'Your Password is incorrect please try again.');
     nn := show_alert('note_alert');
  END IF;
END;


Wow. That is shorter than I started with! Smile

[Updated on: Fri, 15 October 2010 06:42]

Report message to a moderator

Re: Forms 10g And Filter Data With SSO ID [message #479222 is a reply to message #479220] Fri, 15 October 2010 06:58 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
The where clause is set to "ID = :GLOBAL.ID".

This is set, I guess, in block's WHERE property?

What happens if you set it in trigger code, right before executing the query?
if :global.id is not null then
   set_block_property('authuser', default_where, 'id = ' || :global.id);
else
   ...
end if;

Also, just to make sure what query really does, you could display the last query using get_block_property built-in (with the LAST_QUERY property).
Re: Forms 10g And Filter Data With SSO ID [message #479230 is a reply to message #479222] Fri, 15 October 2010 07:38 Go to previous messageGo to next message
Kevin58
Messages: 79
Registered: January 2009
Member
The select statement errors with a no data found exception.

Then it complains that :global.id does not exist.
Re: Forms 10g And Filter Data With SSO ID [message #479257 is a reply to message #479147] Fri, 15 October 2010 10:54 Go to previous messageGo to next message
Kevin58
Messages: 79
Registered: January 2009
Member
I got it narrowed down to I don't think Oracle likes an "@" symbol in the user id.

The user id I am testing with is MARTIN@DOT.INT.LAN

The odd thing is if I hard code 'MARTIN\@DOT.INT.LAN' then the form runs just fine.

Otherwise there is no complaint and no rows returned.

Is the "@" symbol some kind of reserved character?
Re: Forms 10g And Filter Data With SSO ID [message #479268 is a reply to message #479147] Fri, 15 October 2010 14:14 Go to previous messageGo to next message
Kevin58
Messages: 79
Registered: January 2009
Member
Got it to work!

Thanks for all the suggestions. Smile
Re: Forms 10g And Filter Data With SSO ID [message #479276 is a reply to message #479268] Fri, 15 October 2010 14:41 Go to previous message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Is "user id", actually, a "user" (schema owner, created with the CREATE USER statement)?
SQL> create user abc@dot.net identified by a;
create user abc@dot.net identified by a
               *
ERROR at line 1:
ORA-00922: missing or invalid option


SQL>

However: you can create a user with such a name, but you'd have to enclose it into double quotes:
SQL> create user "abc@dot.net" identified by a;

User created.

SQL>

Though, I wouldn't recommend anyone to do that. Using the same principle (double quotes, that is), you could create tables with "funny" names, other schema objects as well, but that'd require using double quotes every single time you reference anything of the above. Too much pain for nothing.

For more information, check schema object naming rules.
Previous Topic: issue with post-query trigger
Next Topic: Custom Form
Goto Forum:
  


Current Time: Thu Sep 19 12:32:10 CDT 2024