我试图获得用户名登录用户在alfresco使用
String name = serviceRegistry.getAuthenticationService().getCurrentUser();
但是无论哪个用户登录,它总是返回admin。
Then i try
String name = AuthenticationUtil.getFullyAuthenticatedUser();
对于所有用户它也返回admin。
我用谷歌搜索了一下,没有成功。这是一个bug在户外还是我需要照顾其他东西也得到适当的用户名?
或者是否有其他方法获得当前登录的用户名?
String name = AuthenticationUtil.getFullyAuthenticatedUser();
是获取当前用户的userName的正确方法。
每个webscript都有一个描述符,你可以在其中配置执行webscript所需的身份验证:http://docs.alfresco.com/4.2/references/api-wsdl-authentication.html
通常,您将使用<authentication>user</authentication>
在alfresco仓库中有两个不同的"运行时"可以用来执行webscript:
- /alfresco/s/…(长版本/alfresco/service)使用HTTP基本认证
- /alfresco/wcs/…(长版本/alfresco/wcservice)使用alfresco的WebClient (alfresco Explorer)认证。