[jcifs] Member in Domain?

eglass1 at attbi.com eglass1 at attbi.com
Mon Dec 9 20:24:59 EST 2002


If you have obtained a non-null NtlmPasswordAuthentication object from the 
doAuthentication call (i.e., the client has responded with a well-formed type-3 
message), and you want to check if the response will successfully authenticate 
them against a specific domain, you should be able to do:

public boolean isInDomain(NtlmPasswordAuthentication np,
        UniAddress domainController, String domain) throws IOException {
    try {
        if (!domain.equalsIgnoreCase(np.getDomain())) return false;
        SmbSession.logon(domainController, np);
        return true;
    } catch (SmbAuthException ex) {
        return false;
    }
}

The domainController above should be the same box which produced the type-2 
challenge, i.e. via SmbSession.getChallenge(domainController)

Eric
> 
> Hi @ all,
> 
> > if got a a little problem and don't know how i could resolve it.
> > Im using a ntlm-servlet wich gets the the domain, username, hashed pass,
> > etc from the browser (iex).
> > It works like your NtlmServlet.
> > 
> > I put the third Message in following:
> > 
> > NtlmSsp ns = new NtlmSsp();
> > NtlmPasswordAuthentication np = ns.doAuthentication(request, response,
> > msg);
> > 
> > System.out.println("Domain: " + np.getDomain());
> > System.out.println("Name  : " + np.getName());
> > System.out.println("Pass  : " + np.getPassword());
> > System.out.println("User  : " + np.getUsername());
> > System.out.println("Uhash : " + new String(np.getUnicodeHash(msg)));
> > System.out.println("AHash : " + new String(np.getAnsiHash(msg)));
> > 
> > What I now want, is to check if the user is really a member of the nt
> > domain.
> > For this I want to try a logon or something else with the username, the
> > domainname and the hashed password.
> > As result i need only a boolean. If it is false, the user has maybee used
> > a local account on his computer.
> > 
> > Does the jcifs-libraries such a method? Do you have an idee, how I can
> > resolve this problem?
> > 
> > Thanks for your help!
> > 
> > Best Regards
> > Jens Mueller



More information about the jcifs mailing list