-2

I am building an webapp in JSF-2. I want to know the username of person who is viewing the website.

Client

<h:outputText value="Welcome #{mailRoomAppView.userID}" style="float: right; float: top" />

Backend Bean

public void setUserID(){ userID = System.getProperty("user.name"); }

App is showing Hello mwadmin which is from the system where war is deployed.

I want to get the windows userid of the request session

I tried below code but it returns null FacesContext.getCurrentInstance().getExternalContext().getRemoteUser()

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Sudhik
  • 119
  • 8
  • logged user from session. Nobody knows, what is your code & config – Jacek Cz Aug 23 '17 at 20:52
  • I'm using JSF2.2. In my backing bean of xhtml, I need to get the username of system of client. Now I'm using System.getProperty("user.name") but it takes username of server where the app is deployed – Sudhik Aug 23 '17 at 21:02
  • Be more specific with your question and show some code and security configuration for your application – Marc Nuri Aug 23 '17 at 21:11

1 Answers1

0

To view the name of the person who is viewing your site, you need the user session. So, you need some login strategy to identify who is connected.

Once you have a login, you can get the user name with:

#{request.userPrincipal}

If you want the windows user name, and your app is for a company with LDAP and all PC's are in the same windows domain, you can use the same LDAP for your login.

C.P.O
  • 1,213
  • 2
  • 11
  • 29
  • Thanks. This is my exact requirement. I don't have any hands on LDAP as well, searching on that. – Sudhik Aug 24 '17 at 17:11