I'm developing an intranet web portal for our company, using Angular 5, Java Spring and REST, JDBC, JSON, MS SQL Server. I need seamless authentication to my website for which I've developed a method using LDAP, which retrieves the required details using the user's usename. Now, my only task is to get the username from the user automatically. Please help me to proceed further. Thank You!!
The current user's username is available through a system property:
String username = System.getProperty("user.name");
That's the user running the Java process.
If you're looking for the user running the browser, then you can't get the OS username using JavaScript.
Related
I'm developing a Java web application using Tomcat 9.In the Login page, I want a tool that can authenticate the user's credentials and sign him in automatically. Is there any simple example that can help, as I'm kind of new to Java development. In addition, I want the User's username and password to be fetched from the Operating system.
Thank you
Use Kerberos via SPNEGO: http://tomcatspnegoad.sourceforge.net/
works perfectly for me and my users
I'm apologizing in advance on the way the question is asked, i mean the way it is framed.
In our organization we have an internal portal like www.xyz.com and we use SAP web interface.
Basically i'm writing a java code using JCO to fetch the data from SAP table. but i need to authenticate to get into the application. In this web interface we don't enter the username and password.
when I open the webpage it directly takes the USERID and PASSWORD from xyz.com portal and logs in.
Is there a way that in my java code, i can retrieve that data(I don't want to view it, just authenticate directly using that portal) and get the data. Currently my code to retrieve to retrieve data is like below.
JCO.createClient("SAP client", "username","password","language",
"server name","system number");
Here i want to get the username and password directly.
Is there away to get this.
Thanks
It sounds that your portal is using a SSO solution?
In general it is possible by using JAAS.
Configure a JAAS LoginModule, get the username and - maybe - the password and providing that information to the JCO client.
I'm developing an application that would be hosted on tomcat server. I'm looking to get the username details with which the user would logon to his windows system for tracking purpose. Is there a way to get the user name details with which the user logged onto the system before accessing the application through a browser?
i doubt there is a java only way to do this. you have to check the username using javascript. here is an example for windows user:
Get Windows username with JavaScript?
Also you probably want to do the same for Linux/Mac users?
Once you got the java script name you could either save it into a cookie and read it with your Java servlet or send an Ajax request to your backend.
I have a web application which is hosted on apache web server. And i have external java application which runs on tomcat integrated in this web application.
The apache is kerberized and I get the username of the person accessing it in the intranet. I want to use the same username and pass it on tomcat to check against ldap and authorize the user.
I was looking into JNDI realm which supports LDAP module. But the problem is I do not have access to the user's password. But I'm able to get the groups the user belongs to and based on that I want to authenticate the user.
So my question is will i be able to authenticate a user against Tomcat server via LDAP with just the username and not the password?
PS: Sorry there is no code or configuration that I can post at this point. The only resources i found implemented both username and password. I cannot kerberize the tomcat server because I have other issues in the network.
"I was looking into JNDI realm which supports LDAP module. But the problem is I do not have
access to the user's password. But I'm able to get the groups the user belongs to and based
on that I want to authenticate the user."
Once I was asked to write some code to do the very same thing. I found a way to make it work. However, although it seemed to work well enough with Internet Explorer which would automatically detect the Windows username (because my code was parsing some NTLM information that only Internet Explorer passes in as a header), in Firefox or any other browser the user would be presented with an authentication box and any username they typed in would be accepted! Its very insecure.
(Well, its not really true that only IE passes the header in. Only IE passes it in automatically; but Firefox also passes it in after someone gets the authentication box and types in any name they want. That's the problem.)
What I would suggest is writing a C#.NET service to do the authentication for real on a webserver that is IIS and has Integrated Authentication on. Then, redirect to the C# service when someone hits the Java site and the username session variable is null. Have the C# service save the info in a trusted/secure database including ip address and browser and redirect to the Java app which reads the db to validate IP address and browser and that the record was just created.
Edit: I just noticed you said your Apache is kerberized and already gets the Windows username, which may render the problem above about the unreliability of parsing the NTLM header null and void. In this case, if you can get the AD groups via LDAP you can authenticate the user in your webapp with your own code, but probably not using the official Tomcat authentication scheme. What is described above is just because my Tomcat is not paired with an Apache server but with a IIS server. So basically, its the same thing, except you won't need C#.
I need to know if a user entered correct login information to Microsoft Active directory
I want the user to enter username and password on an xpage and it should only return if these values was entered correctly or not.
I know I can use ldap requests and send in credentials but have not seen any working solutions for this.
I need to use java as the code should be able to run on non windows servers
There are a number of approaches you can take:
The easiest would be to link the AD to Domino using DirectoryAssistance and let users login using their AD credentials in the first place.
If IIS is running on the AD server you could send an HTTP request using the Apache HTTPClient (and basic authentication) and see what's coming back
The best working Java libraries are listed in the Apache Directory project. There you would do an LDAP query (e.g. the user herself)
Let us know which one works for you
You can use JNDI to access the Active Directory. There are a lot of ressources on the web on how to do this, for example have a look at http://mhimu.wordpress.com/2009/03/18/active-directory-authentication-using-javajndi/
You have tagged the question as XPage, do you want to do the authentication from inside domino? In that case the domino server could do the authentication.