1

Problem:

I am logging into a virtual machine(RDC) using the below credentials:

The user is part of a domain group called as teldept

user:147852 pass:helloworld

when i try to get the user details from java application it gives me : 147852

but when i click on start menu at the top i can see my Name displayed.

How is this done? i want to access this name from java application

I use the below snippet:

System.getProperty("user.name");

Whatever the above snippet gives me is correct as aper oracle docs. I am logging in with ID: 147852 and above snippet gives me 14852 but some how in windows this ID:147852 is mapped with my name so only in the start menu in XP i am getting my name displyed instead of 147852. we need to know how this mapping is done between the ID & Name . I am guessing it has something to do with Domain or some network logic which i am not good with .

Wills
  • 491
  • 8
  • 20

2 Answers2

4

The name shown on XP's start menu is not the logon name. It's Full Name Corresponding to the Logon Name. Not sure if your login is a local login or a domain login. If it's a local login, go to Admin Tools -> Computer Management -> Users and Groups -> Here against your username (147852), you will find a full name. If your login is a domain login, you can similarly lookup your name in Active Directory - or search for it at other places.

This is very OS Specific and cannot be found by Java. You will need to do this using JNI and Windows API - Calling GetUserNameEx or NetUserGetInfo depending on type of user.

If you just want to get your logon name (147852), calling com.sun.security.auth.module.NTSystem().getName is a better way than using System.getProperty("user.name")

user93353
  • 13,733
  • 8
  • 60
  • 122
2

From this SO question, you can use:

System.getProperty("user.name");

to return the currently logged in user. This will return the username string. I believe this is what you're asking for, but your question is rather unclear.

Community
  • 1
  • 1