-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: How to capture username of the system?
PostPosted: Fri Oct 31, 2008 12:54 pm 
Hi,

I am working on an application where I need to capture the "User Name" of the system and return it. This should be saved into the database. Is there any function or any way available to do this. I found that we can use getusername() to capture the database user name. But I need the user name of the person who logged into the system.

Any solution is highly appreciated.

Regards
Shilpa Chalasani


Top
  
 
 Post subject:
PostPosted: Sun Nov 02, 2008 6:28 pm 
Newbie

Joined: Sat Oct 18, 2008 11:34 am
Posts: 10
You can do either:

Code:
String username = System.getProperty("user.name");
System.out.println(username);

or if running Windows:
Code:
com.sun.security.auth.module.NTSystem ntSystem = new com.sun.security.auth.module.NTSystem();
System.out.println(ntSystem.getName());

The latter method, using the NTSystem, allows you to get some other interesting data as well, like Domain, Group, SID etc.

However, this has not anything to do with Hibernate... ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 03, 2008 1:14 pm 
Newbie

Joined: Fri Oct 31, 2008 1:19 pm
Posts: 5
Thank you!!

It works..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 03, 2008 3:39 pm 
Newbie

Joined: Sat Oct 18, 2008 11:34 am
Posts: 10
Shilpa Chalasani wrote:
Thank you!!

It works..


No problem. BTW, clicking the "Rate this post as helpful" is a also a nice way of saying Thanks. ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 03, 2008 8:26 pm 
Newbie

Joined: Fri Oct 31, 2008 1:19 pm
Posts: 5
I am ready to do that..

By the way can I know how to rate in this forum..

I guess one more good question for u..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2008 4:22 am 
Newbie

Joined: Sat Oct 18, 2008 11:34 am
Posts: 10
You have to login with the same username you used when asking the question (posting the first post in the thread). Then you'll see the "Rate this post as helpful" link under the answer. Please read this for more details.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.