2

我正在开发一个必须在 Tomcat 上运行的 Java 应用程序,并且我需要能够识别正在访问我的应用程序 Web 的远程用户。

这个远程用户在 Windows 上运行,所以我需要获取他的“Windows 登录”(SAMAccountName Active Directory 属性)。

在 IIS 上是最简单的。我按照这个Detect user logged on a computer using ASP.NET app让用户登录

server.xml 的内容是:

<Realm
    className="org.apache.catalina.realm.JNDIRealm" debug="99"
    connectionURL="ldap://DAServer:389"
    connectionName="userAuth@mydomain.local"
    connectionPassword="secret"
    referrals="follow"
    userBase="OU=mycompany,DC=mydomain,DC=local"
    userSubtree="true"
    roleBase="OU=groups,DC=mydomain,DC=local"
    roleName="name"
    roleSubtree="true"
    roleSearch="(member={0})"/>

而web.xml的内容是:

<!-- Define a Security Constraint on this Application -->
    <security-constraint>
        <web-resource-collection>
        <web-resource-name>Entire Application</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>

        <auth-constraint>
            <role-name>myCompany Users</role-name>
        </auth-constraint>
    </security-constraint>

    <!-- Define the Login Configuration for this Application -->
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>myRealm</realm-name>
    </login-config>

    <!-- Security roles referenced by this web application -->
    <security-role>
        <description>The role that is required to log in to APP</description>
        <role-name>myCompany Users</role-name>
    </security-role>

我需要自动登录。

4

2 回答 2

2

如果您正在构建 Intranet 应用程序并正在寻找 SSO,那么您可以使用基于jCIFS的Jespa 之类的东西。

于 2009-04-13T02:04:07.453 回答
0

您必须使用 Tomcat JNDI 领域并将其与服务器的活动目录集成

在这里尝试一些指南

于 2009-04-09T08:15:47.713 回答