1

重複の可能性:
Spring Securityを使用する場合、Bean内の現在のユーザー名(つまりSecurityContext)情報を取得する適切な方法は何ですか?
春のセキュリティユーザー名を取得する方法

Springldapを使用してWebアプリを認証します。

<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>

動作しますが、ログインページにユーザー名を入力する方法がわかりません。ページの上に表示したいからです。

ありがとう。

4

1 に答える 1

5

私はこれを見つけました:

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

検索されたエントリを返します。

于 2012-08-31T03:00:16.567 に答える