I want to reference app_user in query
(where username=(:APP_USER))
Now my query returns null values, I guess it's happening because my username col is varchar2. How to reference app_user in this situation?
you can use below:
where username=v('APP_USER')
Edit1:
for performance constraints, it is always recommended that you do it like this:
where username=(select v('APP_USER') from dual)
:APP_USER value depends upon the authentication model set in your application. If application is running using database authentication then the value of the user is the same as the database pseudo column USER. If the application uses an authentication scheme that requires the user to authenticate, the value of APP_USER is set by the authentication scheme, usually to the user name used during authentication.
Reference : Oracle documentation
apex make username uppercase try (where UPPER(username)=(:APP_USER))
Related
I am capturing user names in an Azure Database table column using:
ALTER TABLE [***] ADD DEFAULT original_login() FOR [ChangedBy]
The problem is that when using Service Principal used by Azure Data Factory i am catching it's ID instead of Name.
Anyone knows how to catch it's name instead?
So I record: r2s1as1d6-9317-4226-ah89-8... instead of it's name from CREATE USER [User Name] FROM EXTERNAL PROVIDER;
Would appreciate help here
Best!
As far as I am aware, this can not achieve with using Service Principal. You can change to use SQL authentication.
I am defining a new table where a column suppose to store name of the logged in user. How to grab logged in user name as default value for a column? Is it possible out of the box ?
You can use SYSTEM_USER variable to fill that.
I would recommend using ORIGINAL_LOGIN in case there is some impersonation going on. It will always get the user name that initiated the connection.
ORIGINAL_LOGIN
SYSTEM_USER
The goal is to allow all the "Teachers" that have access to the Faculty table to have Select permissions to only their own social security number and not everybody elses. Do any of you know how I can perform something like this? I do have all my users setup as Windows Users and I have a windows group called Teachers, if that helps.
Not possible using the standard permissions in SQL server (that I am aware of)
You will need to implement this kind of constraint in your code.
You could in theory pass in the SS# and query based on this and raise an error if they do not match.
Social security numbers shoud be encrypted so they can't see each others numbers if they call up the record. You can use a decryption proc to allow them to decrypt that checks the userid against the profile id and will only decrypt if they match.
Implementing Row-level Permissions
Row-level permissions are used for applications that store information in a single table. Each row has a column that defines a differentiating parameter, such as a user name, label or other identifier. You then create parameterized stored procedures, passing in the appropriate value. Users can see only rows that match the supplied value.
The following steps describe how to configure row-level permissions based on a user or login name.
Create the table, adding an additional column to store the name.
Create a view that has a WHERE clause based on the user name column. This will restrict the rows returned to those with the specified value. Use one of the built-in functions to specify a database user or login name. This eliminates the need to create different views for different users.
' Returns the login identification name of the user.
WHERE UserName = SUSER_SNAME()
' USER_NAME or CURRENT_USER Return the database user name.
WHERE UserName = CURRENT_USER()
Create stored procedures to select, insert, update, and delete data based on the view, not the base tables. The view provides a filter that restricts the rows returned or modified.
For stored procedures that insert data, capture the user name using the same function specified in the WHERE clause of the view and insert that value into the UserName column.
Deny all permissions on the tables and views to the public role. Users will not be able to inherit permissions from other database roles, because the WHERE clause is based on user or login names, not on roles.
Grant EXECUTE on the stored procedures to database roles. Users can only access data through the stored procedures provided.
I am using basic forms authentication in my MVC 4 project. When I attempt to create a new user using CreateUserAndAccount() method, it creates a record in my profiles table (DB: SQL Server) but the password is defaulted null. I even tried to update the password using WebSecurity.ChangePassword() and WebSecurity.GeneratePasswordResetToken() + WebSecurity.ResetPassword() methods with no luck.
Has anyone had this issue before?
Thanks for your time.
Regards,
Arvind
I was looking for password in profiles table whereas it is stored in webpages_Membership table.
Answer: Why is WebSecurity ignoring my password?
I'm looking for a way to create a user with password for PostgreSQL >= 8.4 using SQL statement, but the password must match the windows password policy.
At MSSQL I can create a LOGIN and set CHECK_POLICY=ON
CREATE LOGIN [xy] WITH PASSWORD='pass', DEFAULT_DATABASE=[mydb], CHECK_POLICY=ON
and later create the user for this login.
Is there something similar for PostgreSQL? I have to support all versions beginning at 8.4.
Thank you
There is a module for that:
http://www.postgresql.org/docs/9.3/static/passwordcheck.html
Think this works since Version 9.0.