?
Solved

how to get the remote username in java

Posted on 2009-04-30
15
Medium Priority
?
1,881 Views
Last Modified: 2013-11-24
Hi Experts,

my application will execute at office i want to display who are login to my application that login name should display welcome: xxxx,

how to get the remote username in java.
i tryed System.getProperty("user.name");
but it working only local system i want remote system user name.

could you send me some code.

thanks.
0
Comment
Question by:krish12345
  • 7
  • 5
  • 3
15 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24276031
you can use the getRemoteUser() method
0
 

Author Comment

by:krish12345
ID: 24276580
thanks your replay

i tryed request.getRemoteUser(),
but i'm getting null.
0
 
LVL 92

Expert Comment

by:objects
ID: 24276592
then it sounds like the details of the user are not avaiable ie. the browser (or whatever) is not including them in the request

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:krish12345
ID: 24276688
sorry i didn't get you.
when i use System.getProperty(), this method will giving login name only my local system
insted of System.getProperty i'm using request.getRemoteUser()

this time i'm getting null,

i think not working getRemoteUser, i'm trying to print both System.getProperty i'm getting login name but getRemoteUser i'm getting null value.

i'm using Websphere6.1, jsp

thanks.
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 24276708
getRemoteUser() relies on the username being included in the http request. Where should the username be coming from exactly?

0
 

Author Comment

by:krish12345
ID: 24276730
System.getProperty("user.name);
this method to getting user name.

not for getRemoteUser();

thanks
0
 
LVL 92

Expert Comment

by:objects
ID: 24276736
what username exactly  are you after?

0
 

Author Comment

by:krish12345
ID: 24276744
who are login system that person user name i need why because i need to show my application like welcome: xxxname so if i use System.getProperty(); it is getting my system name only but who are using my application that person login name should be come.

thanks
0
 
LVL 92

Expert Comment

by:objects
ID: 24276784
login to what, their OS login, or webapp login, or something else?

0
 

Author Comment

by:krish12345
ID: 24276801
oh sorry OS login only
0
 
LVL 19

Assisted Solution

by:Kuldeepchaturvedi
Kuldeepchaturvedi earned 600 total points
ID: 24276857
System.getProperty will give you only the local name because its reading the local system property. ( i.e. the server where its running).

getRemoteUser will get the user name that is set in the HTTP header IF its set there..

does your application use any kind of login password mechanism? or its open to all?
0
 

Author Comment

by:krish12345
ID: 24276878
my application open to all,

the thing is once i get the OS Login information then i will authenticate.

could you tell me more details about getRemoteUser how to get the Remote User Name how to set the HTTP Header

thanks
0
 
LVL 19

Assisted Solution

by:Kuldeepchaturvedi
Kuldeepchaturvedi earned 600 total points
ID: 24276901
if your app is open to all, you can not use getRemoteUser, specifically you can not use getRemoteUser to get the windows domain login information ( I am assuming that your clients are running on windows)..

you will have to use a third party tool ( JCIFS)

http://jcifs.samba.org/

by using this, you should be able to implement the whole NTLM security model.
0
 

Author Comment

by:krish12345
ID: 24276998
thanks

any how my Websphere was providing basic authentication right.
so why i need third part security.

could you tell me plz.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 24277022
the basic authentication is there, but it will not be able to provide you the NTLM ( i.e. windows domain authentication which you are trying to use)..

However if you aim is to only get the user name and not really authenticate, then you can turn on the basic authentication on websphere and try to see if getRemoteUser gives you a name.

the API says that the getRemoteUser will return null for all non autheticated access. and will give the name for which authetication is set as required.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question