从 Java Websphere 应用程序确定网络用户
我有一个使用 Java 1.6 和 Websphere 构建的内部 Web 应用程序。只有登录到域的用户才能访问该应用程序。我需要能够访问使用该应用程序的任何人的用户名。我们正在使用 Windows 域控制器。我对 Java 相当陌生,不知道如何获取这些信息。任何帮助将不胜感激。如果您需要更多信息,我将很乐意提供。
谢谢,
安德鲁
I've got an internal web application built with Java 1.6 and Websphere. Only users logged into the domain can reach the application. I need to be able to access the username of anyone using the application. We're using Windows domain controllers. I'm fairly new to Java and can't figure out how to get this information. Any help would be appreciated. If you need more information I'll be happy to provide it.
Thanks,
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是最终起作用的代码。
Here's the code that eventually worked.
根据我对 J2EE 和 Web 应用程序的了解,您通常可以获取主体对象,然后从中检索用户名。这是你需要的吗?
下面是如何在 doGet 或 doPost 方法内的 servlet 中执行此操作的示例:
获取密码要复杂得多,但如果您需要的只是用户名,那么这应该是他们“登录”您的 WebSphere 服务器的名称with(即传递给它的任何 ID)。
这就是您要找的吗?
From what I know of J2EE and web apps, you can generally acquire the Principal object and then retrieve the user name from that. Is that what you need?
Here's an example of how you could do this in a servlet inside of the doGet or doPost methods:
Getting to a password is much trickier, but if all you need is the username, this should be the name they "logged onto" your WebSphere server with (ie whatever ID was passed to it).
Is that what you are looking for?
请参阅:javax.servlet.http.HttpServletRequest.getRemoteUser()
See:javax.servlet.http.HttpServletRequest.getRemoteUser()
你的问题并不是真正的Java,而是相关的。基本上,如果您想使用 WAS 的安全设施进行网络安全,则必须从 WAS 配置所针对的 LDAP 中找到您的所有用户。如果您无法做到这一点,请对应用程序进行更改,以便它实现自己定制的安全(身份验证和授权)机制。
听起来好像有人为您的应用程序使用的 servlet 以及 SPNEGO 启用了 JavaEE 安全角色。这是相当不错的配置,但它确实不允许任何未从默认 LDAP 中找到的人访问任何内容。
Your question is not really Java but WAS related. Basically if you want to use the security facilities of WAS for Web Security all your users must be found from the LDAP the WAS is configured against. If that is not possible for you please have changes made to the application so that it implements its own custom made security (authentication & authorization) mechanisms.
It sounds like someone enabled the JavaEE security role for the servlets used by your application and probably also the SPNEGO. That is pretty nice configuration but it really doesn't allow anyone that is not found from the default LDAP to access anything.