Detect user logged on a computer using Java web app

后端 未结 4 974
梦如初夏
梦如初夏 2020-12-04 18:38

I want to develop an Java application that can detect the user logged on a Windows Domain. These credentials are going to be used to logging on the Java application running

相关标签:
4条回答
  • 2020-12-04 19:02

    This is my solution:

    Put jcifs-1.2.7.jar on [TOMCAT_HOME]/common/lib directory.

    Modify application's web.xml adding the followin text to section webapp:

    <filter>
        <filter-name>NtlmHttpFilter</filter-name>
        <filter-class>jcifs.http.NtlmHttpFilter</filter-class>
        <init-param>
            <param-name>jcifs.http.domainController</param-name>
            <param-value>xx.xx.xx.xxx</param-value>  --> Domain Controller IP
        </init-param>
        <init-param>
            <param-name>jcifs.util.loglevel</param-name>
            <param-value>2</param-value>
        </init-param>
      </filter>
      <filter-mapping>
           <filter-name>NtlmHttpFilter</filter-name>
           <url-pattern>/*</url-pattern>
      </filter-mapping>
    

    And the you can get the remote user using request.getRemoteUser() whithout prompt.

    See you.

    0 讨论(0)
  • 2020-12-04 19:03

    In general, you can hook into the local authorization service using Java Authentication and Authorization Service. That might do what you want.

    That said, are you sure this is the right way to go? What do you want to accomplish? Are you looking for a single-signon solution for the webapp?

    Then this: How to configure Tomcat to use Windows NTLM authentication? might be what you are looking for, as proposed by Steve Read in the comment above.

    0 讨论(0)
  • 2020-12-04 19:06

    Jcifs liabrary will be surely of your help. This library can be used for performing NTLM authentication.

    0 讨论(0)
  • 2020-12-04 19:13

    I recall using mod_ntlm for apache did the trick for me, but that was few years ago, so I don't know what had changed since.

    0 讨论(0)
提交回复
热议问题