Creating login session while using oracle forms - sql

I'm trying to build an app using oracle builder (oracle forms) and i want to know the user name after login, is there any option like sessions in (PHP/ JEE) to know who logged in my app?

To get User's Login&App Names, you may prefer setting them in Forms' ON-LOGON trigger with Dbms_Application_Info package's methods using this code :
Declare
v_db_name varchar2(35) := 'mydb1';
v_lg_name varchar2(350):= 'some DesiRed Value'; -- such as a username credential when the current user is being logged on to the DB OR SYS_CONTEXT('USERENV', 'IP_ADDRESS') provided static IP values are assigned per each user.
v_app_name varchar2(350):= :SYSTEM.CURRENT_FORM;
Begin
Logon(:Parameter.Un,:Parameter.Pwd||'#'||v_db_name); -- Un & Pwd are defined in Parameters node of Forms
Dbms_Application_Info.Set_Client_Info( v_lg_name );
Dbms_Application_Info.Set_Module( v_app_name, null );
End;
Whenever you need who logged your application, may issue this sql to see the related session information (provided your current session has select privilege to query gv$session dictionary view):
select s.*
from gv$session s
where lower(s.client_info) like lower('%'||'&cli_info'||'%')
and s.module = 'myApp'
order by floor(s.last_call_et / 60), s.username, s.logon_time desc

Sure; use "USER" system variable. For example:
message('You are connected as ' || user);

Related

Create user in Readers Account Snowflake

I have created a share and added that share to a reader account.
Now I have executed a create user statement there in the reader account i.e.
CREATE or replace USER client_test
PASSWORD = 'Client4321'
LOGIN_NAME = 'client'
DISPLAY_NAME = 'client test'
FIRST_NAME = 'client'
LAST_NAME = 'test'
EMAIL = 'mukul.kumar#gmail.com'
DEFAULT_ROLE = sysadmin;
This statement gets executed without any error and also I can see the user details under the account tab in snowflake UI
but still, when I am trying to login into this newly created user, there is an error of incorrect username or password coming up.
Is creating a user in a reader account not allowed or anything like there in snowflake?
I haven't found documentation on this as such. It will be appreciated if anyone helps me out with this.
The issue here is that the login_name is the one which should be used for logging in to the SF application. Use "client" and "Client4321" to login and it will be successful.

Cannot remove SID from User Mapping of Login object

During some testing I applied SID value 0x01050000000000051500000085E77E2F11C35F7307E53B2B531D0200 of a system account received from SUSER_SIDfunction to User Mapping of a certain Login object in SSMS. Now based on that I cannot get rid of it as I keep getting an error message Value was either too large or too small for a UInt64 no matter what I enter or erase. I would appreciate if somebody would know how to get rid of a certain User Mapping either via UI or code specially when I encountered such an error message, thank you
Your actions were:
Open login properties of some windows login
Changing the corresponding user for some database to sid (why on the erth did you map the login to the user named as sid???)
This corresponds to the following code:
alter user... with name = [0x01050000000000051500000085E77E2F11C35F7307E53B2B531D0200];
Now you want to do the inverse action, so you need to execute this code:
use CDR_MDS;
alter user [0x01050000000000051500000085E77E2F11C35F7307E53B2B531D0200] with name = NAME=[GROUP\gg ORG RAACO MS BI Team];

Authentication - PLS-00488: 'VALIDATE_USER_FROM_DB' must be a type ORA-06550

I'm currently working on an application in Oracle Application Express 5, more specifically I'm trying to create a custom authentication scheme.
I started by creating a function in the SQL command window that would provide my application with a basic level of authentication. I want my users to be able to sign in with their personal student reference number (srn) and date of birth (dob) and this information is taken from the table "student".
create or replace function validate_user_from_db
(p_username in number, p_password in date)
return boolean
as v_pw_check varchar2(1);
begin select 'x' into v_pw_check
from student
where upper(srn) = upper(p_username)
and dob = p_password; apex_util.set_authentication_result(0);
return true; exception when no_data_found then apex_util.set_authentication_result(4);
return false;
end validate_user_from_db;
This function compiled with no errors and so I then went on to create a simple query that would test the function.
declare
vresult varchar2(10);
begin
if validate_user_from_db ('30134852', '08/17/1997') then
DBMS_OUTPUT.PUT_LINE('Welcome Back');
else
DBMS_OUTPUT.PUT_LINE('Error');
end if;
end;
The query was successful and was outputting "Welcome Back" when the correct credentials were filled. Now that everything was working how I'd hoped I went about creating a new authentication scheme. I named it "User Validation" and set the scheme type to custom.
I've been following a tutorial and researching into authentication schemes and it was suggested that in the PL/SQL code I place the line,
return validate_user_from_db;
but when I saved and compiled it I got this error message.
Error Code
In attempt to try and resolve this issue I decided to write the following function in PL/SQL code window and it compiled without any issues, but when I try run the application and use correct login credentials it just hits me with an error message stating "Invalid Login Credentials".
function validate_user_from_db
(p_username in number, p_password in date)
return boolean
as v_pw_check varchar2(1);
begin select 'x' into v_pw_check
from student
where upper(srn) = upper(p_username)
and dob = p_password; apex_util.set_authentication_result(0);
return true; exception when no_data_found then apex_util.set_authentication_result(4);
return false;
end validate_user_from_db;
Any help will be much appreciated as this is my firs time creating authentication with Oracle Apex.
I resolved the issue after messing around with a test application. Turns out a login page is automatically generated depending on the authentication scheme you have set in place. Make sure you delete your existing login page when you change authentication.

How to enforce user validation EXCEPT on server startup in meteor?

I want no user to be able to create users with the super-admin role, I want the only super-admin created by the server upon startup. How do I create an Accounts.validateNewUser() function enforcing this?
More generally, I want all new users validated a certain way EXCEPT the one created during server startup. How do I do this?
Thank you!
When the server starts up, create the new super-admin user and make sure that this user has a unique key in its document. ex: isSuperAdmin: true. In your Accounts.validateNewUser() code (which runs on the server):
if ( Meteor.user().isSuperAdmin || Meteor.users.find().count() <= 1 ) return true; // only allow super admin to create users with exception for very first user
else throw new Meteor.error(403,'Forbidden');
You'll also need a deny rule for any attempt to set the isSuperAdmin key on a user.

SQL70527 error in database project

I have a database-project, created based on my existing database. It also added the scripts for creating users. One of those scripts is =>
CREATE USER [JOOS_NT\Indigo.Development] FOR LOGIN [JOOS_NT\Indigo.Dev.svc];
This script works fine on my database. But in my database-project this script is throwing an error when I build it. The error is:
"SQL70527: 'JOOS_NT\Indigo.Development' is not a valid name because it contains characters that are not valid."
It seems the "\" in the [JOOS_NT\Indigo.Development] is not allowed. However on the database itself I can run the query and it works fine. If I change it to [JOOS_NT/Indigo.Development] I don't get the error, but when comparing the scripts in the project to the existing database, it would drop the user ([JOOS_NT\Indigo.Development]) and replace it with ([JOOS_NT/Indigo.Development])
What am I missing?
Answering for someone who will look in the future.
On the database project, if a '\' character is included in the user name, the login should match the user name.
Because that, this don't work:
CREATE USER [JOOS_NT\Indigo.Development] FOR LOGIN [JOOS_NT\Indigo.Dev.svc];
But this will:
CREATE USER [JOOS_NT\Indigo.Development] FOR LOGIN [JOOS_NT\Indigo.Development];
Or
CREATE USER [JOOS_NT\Indigo.Dev.svc] FOR LOGIN [JOOS_NT\Indigo.Dev.svc];
I'm not sure if this is the expected behavior or a bug.
This is by design. The core issue is that in the "CREATE USER FOR LOGIN" based on a windows user login, if you are using a domain name for the user then this must match the login's domain name + login name. See this post on MSDN