Pregunta

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.

¿Fue útil?

Solución

I found this:

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

which returns searched entry.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top