Way to figure out / retrieve Windows username in Oracle APEX - windows

I wanted to know, if there is a way to just get the Windows username with some kind of function, ... in Oracle APEX 4.2 an populate it a Display Only element in an application page. I don't want to do a login authentification, I just want to get the username.
On the Oracle Database you could do something like
SELECT SYS_CONTEXT('USERENV', 'OS_USER') "USERNAME"
FROM dual;
to get it. Is there a similar way for APEX?

ActiveX (IE only)
For clients with Internet Explorer then you can identify the windows username through an ActiveX control. There are security requirements to allow the ActiveX to run on the users browser, see this related answer.
To implement this in Apex you would create a dynamic action that runs the ActiveX & javascript on page load to retrieve the username and the set a page item value using the JS API
var net = new ActiveXObject ( "WScript.NetWork" );
var username = net.UserName;
$s('P123_HIDDEN_USERNAME',username);
From the Web Server
You may be able to retrieve the OS username at the application server level as described in this post on the Oracle Forums - using either weblogic or mod_ntlm/mod_auth_kerberos. Even if not using for authentication it maybe possible to retrieve the username into an application level item at the start of a session.
This solution would be quite involved however and require access to configure the application server hosting your Apex listener.

Related

Two login pages after opening Database Actions in Autonomous

From the Autonomous Tools tab, when we click on “Open Database Actions” -
we are forwarded to a page to enter a username -
then to a second page to enter a username and password -
Why am I being prompted twice?
The first prompt is for your schema as it is known by ORDS. When you REST enable a database account, you have the option of providing an ALIAS, such that RESTful Web Services and their associated URIs don't have your database username in the addresses.
So I could create a schema called FOO, but alias it to FOOBAR.
To login to my SQL worksheet in Database Actions, I would enter FOOBAR in the first box.
ORDS then sees that schema mapping is available and sets the URL correctly, and brings you to the database login page.
On the second prompt, you enter your actual username and password - this is used to attempt a login to the database. If that succeeds, you get to use Database Actions (formerly known as SQL Developer Web).
If you're always using the same user on the same db, you can simply bookmark the URL, and then go directly to your SQL worksheet or REST workshop or or or - and since the right schema alias is in the URL, we'll know exactly who you need to login as, so only the single login prompt.
We now directly log you into Database Actions/SQL Developer Web as ADMIN. If for some reason the single-sign on auth fails, we'll default to the previous behavior as described in the accepted answer.

Getting following error while running oracle oracle apex 20.1 application: Forbidden The requested operation is not allowed

I have problem using default Apex Application Express Authentication. If user has to change password (no matter if developer or end user), you are unable to login in. Instead of password change window i get error "Forbidden The requested operation is not allowed". If password is valid and not expired or not required to change, you can login successfully. Can't find solution for this problem. Using Apex 20.1, oracle 18c (18.0.0.0.0 ).
Accidentally found problem. All applications share same session (Session Sharing set to Workspace Sharing). This prevents user from being able to change password and login if user needs to change it. So I've went easy way. Created another application without session sharing for users, to be able to change password.

Create a default Windows Authentication Domain and Username Prompt for a URL

I'm having a hard time researching my specific issue. Is there a way to tie a default Windows Authentication DOMAIN/Username to a specific URL?
I'm distributing a QlikView application in my IE Browser (AJAX) and it retains the last DOMAIN/Username used upon the next session. I would like to create a URL that generates a default Windows Authen. I didn't know if this could be done through some URL parameter.
Any ideas?
Thanks!
Channing

Know windows username via WebScripting [duplicate]

I have a site which is built in ASP.net and C#. Let's call it webapp. it uses a Form system to log on into it, and cannot be changed easliy.
I got a request to change the log in to some kind of windows authentication. I'll explain.
Our windows login uses active directory for users to log into their windows account. their login name is sXXXXXXX. X are numbers.
in my webapp, I want to take the users numbers from their active directory login, and check if those exist in the webapp database. if it exists, they will automatically log in. If it doesn't, they will be referred to the regular login page for the webapp system which is currently in use.
I tried changing my IIS to disable anonymous login and enabling windows authentication, therefore making the user browser to send it's current logged in user name to my webapp. I changed the web config as well from "Forms" to "Windows", which made my whole webapp obsolete as the whole forms system did not work.
My question is this - is there a different way for the browser only to send the username to my webapp? I thought maybe javascript, I just don't know how to implement that, if it's even possible. I know it's not very secure, but all this platform and system is built outside the internet, it's on a private network.
<script language="javascript">
var username = '<%HttpContext.Current.User.Identity.Name %>';
</script>
The only way you could get at the user's domain credentials via javascript would be by deploying some type of ActiveX component to expose that data to the browser. I wouldn't recommend that.
I would look at implementing a Login page for forms authentication that authenticates the user on the page load using HttpContext.Current.User.
The way forms works is that if an unauthenticated user attempts to access an access-controlled page and have not logged in (no cookie), they will be redirected to a login page that gives the facility to log in (this sets a cookie on the client-side). The user is then directed to the page they initially requested. You would simply be automating the login part.
If you have a mixture of pass-through and user who need to manually login you could check their client IP address to see if it matches one on your domain or not.
The solution I found for getting the username sent to the server was:
string winlogon = Request.ServerVariables["LOGON_USER"];
After enabled Windows Authentication Mode in IIS.

Accessing the value of a session variable of a specific session

I'm trying to integrate a public message board service into an existing web site.
The handshaking between the apps goes like this:
1) File on my web site loads a flash file. The Flash reads a local variable that is the Session ID, or some other GUID unique to the user session.
2) Flash app connects with the remote service, passing the SessionID to the service.
3) The service issues a GET request back to the originating web site, asking for additional information about the user.
4) The originating web site (my site) validates that the session ID is for a valid session, and if yes, passes back the other requested information.
I'd like to be able to use the intrinsic ASP SessionID but I'm not sure how in Classic ASP to retrieve session variables for a specific ASP Session, ie, I want the value of Session("FirstName") where SessionID=1234 and not Session("FirstName") for any other session ID. I haven't been able to find any syntax that would allow me to do this.
The alternative is to create a new GUID for every session, but that's adding a lot of overhead.
Any ideas?
I'm not aware of any way to retrieve Session details for a particular instance or ID.
However, you could utilise the Application object to store the information you need using the Session.SessionID value:
Application(Session.SessionID & tag) = myTagValue
This way you are not creating a new GUID, but utilising the already existing one for session that both client and server are using in your example.

Resources