Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to get windows user name in java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
Im using Struts 1.2 and JBOSS Application Server.

My server is mounted on LINUX server.

Iam working on Single Sign On feature in java., For that I need to get the user name of the logged in user. For that Im using System.getproperty("user.name").
Im getting the user name in my localserver (which is windows)., but when i ran the same code in LINUX server., it is showing the user name of Linux machine Server Name.

I need to know, how to get the user name of windows logged in user in Linux using Java code.?

Thanks in advance.
 
Marshal
Posts: 74374
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You appear to have arrived at the wrong location; this forum is for discussing the forum. I shall try to move you elsewhere.
Please explain more of what you require. You are on a Linux server and there is somebody on a Windows box using your services and you want the user name of the distant user? How would you do that without using Java? System.getProperty gives you the details of the local machine, so you wouldn't expect it to give information about a distant machine.
 
Venkatesh Deepak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Campbell Ritchie for your response.

I have developed a J2EE Web Application and that application runs on JBOSS 6.1.0 Application Server.

This application is used by 500 people across my Organisation.

The production server is LINUX (CentOS), where the JBOSS is mounted.

All the 500 users are using Windows 7 System and they need to login to the application. Here, instead of giving the username and password, we are tying to capture the Windows Logged in Username and using this name, we are using LDAP services to hit the Active Directory and processing the work.

My Problem is, I'm getting all the 500 users Logged in Name when the JBOSS runs on a windows machine as a server. But My Production server is mounted on LINUX, which returns the same Server Machine Name for all the 500 users., I don't need the Linux Server Machine Name and all i need is the Windows Logged in Name.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to set up an LDAP Security realm . The security guide at https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/ should provide the help you need.
 
Saloon Keeper
Posts: 24557
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using SSO, the users won't be logging into the application, they'll have logged into the SSO system, and if the SSO system is in turn including the Windows login, then you've "logged into the application" when you logged into Windows.

This is why there's no login listener for J2EE webapps. Because when the system handles authentication and authorization, the login may have been done somewhere else at some other time through some other app.

Wildfly uses a modified version of Tomcat as its servlet/JSP engine and Tomcat employs plugin Realm modules to handle container-managed authentication and authorization needs. For a stand-alone Tomcat, there's a CAS Realm that's popular for SSO. I seem to recall that last time I looked at JBoss, that it has a slightly different security manager of its own these days, so check the docs.

Also, be aware that to get Windows machines to share their LAN credentials with a web server you may have to change some registry settings on each participating client machine.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

Wildfly uses a modified version of Tomcat as its servlet/JSP engine and Tomcat employs plugin Realm modules to handle container-managed authentication and authorization needs.



Tim, JBoss application servers till the version 7 used to hav a modified version of Tomcat as its JSP/Servlet engine (it was called JBoss Web). However, WildFly (the renamed version of JBoss AS) whose first release version was WildFly 8 uses a completely different JSP/Servlet engine named Undertow http://undertow.io/ which has been written completely afresh by the JBoss team. Undertow doesn't use Tomcat and in fact is also a independent web server (i.e. can also be used outside of WildFly).
 
Tim Holloway
Saloon Keeper
Posts: 24557
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting. I'll have to look into that.

Regardless, the security model that's part of the J2EE would be unaffected, since otherwise WildFly would fail to be spec-compliant.

The question then becomes what security (Realm) modules are available for this version and whether any of them provide the requisite SSO features.
 
Venkatesh Deepak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all Thanks for your posts.

I have successfully connected my Active Directory with LDAP in JAVA and retreived all the users information..

My problem is I need to know who is the user that has hit the application ?
I need the Windows User Login Name to check the user who has hit the application.

Please help me..

Note: My server JBOSS is mounted on LINUX.
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am I correct in assuming that you want the user name from the client's computer? I believe there may be solutions for that which work in a Windows network, but for general networks (such as me connecting to the Ranch server) there isn't a way to find out how the user signed on to their computer. Which is a good thing in the general case because my user ID on my home computer is none of the Ranch's business. However you may be asking about a Windows LAN, in which case solutions may exist.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic