1

Possible Duplicate:
When using Spring Security, what is the proper way to obtain current username (i.e. SecurityContext) information in a bean?
spring security how to retrieve username

I use spring ldap to authenticate my web app,

<ldap-server id="sss" port="389"
             url="ldap://ldap.example.com:389/ou=active,ou=employees,ou=people,o=example.com?uid?sub"/>

<authentication-manager alias="authenticationManager">
    <ldap-authentication-provider
            server-ref="sss"
            role-prefix="ROLE_">
    </ldap-authentication-provider>
</authentication-manager>

it works, but I don't know how to get the username filled in login page, because I want to display it on top of my page.

Thanks.

Community
  • 1
  • 1
user435657
  • 625
  • 2
  • 10
  • 28

1 Answers1

5

I found this:

SecurityContextHolder.getContext().getAuthentication().getPrincipal()

which returns searched entry.

user435657
  • 625
  • 2
  • 10
  • 28