Module jcifs

Class SmbSession

java.lang.Object
org.codelibs.jcifs.smb1.SmbSession

public final class SmbSession extends Object
The SmbSession class represents an SMB session established with a server. It provides methods for authentication and session management.
  • Method Details

    • getChallengeForDomain

      public static NtlmChallenge getChallengeForDomain() throws SmbException, UnknownHostException
      Retrieves an NTLM challenge from a domain controller for the configured domain.
      Returns:
      the NTLM challenge from the domain controller
      Throws:
      SmbException - if an SMB error occurs
      UnknownHostException - if the domain controller cannot be resolved
    • getChallenge

      public static byte[] getChallenge(UniAddress dc) throws SmbException, UnknownHostException
      Retrieves the NTLM challenge from the specified domain controller.
      Parameters:
      dc - the domain controller address
      Returns:
      the NTLM challenge bytes
      Throws:
      SmbException - if an SMB error occurs
      UnknownHostException - if the host cannot be resolved
    • getChallenge

      public static byte[] getChallenge(UniAddress dc, int port) throws SmbException, UnknownHostException
      Retrieves the NTLM challenge from the specified domain controller using the specified port.
      Parameters:
      dc - the domain controller address
      port - the port to connect to
      Returns:
      the NTLM challenge bytes
      Throws:
      SmbException - if an SMB error occurs
      UnknownHostException - if the host cannot be resolved
    • logon

      public static void logon(UniAddress dc, NtlmPasswordAuthentication auth) throws SmbException
      Authenticate arbitrary credentials represented by the NtlmPasswordAuthentication object against the domain controller specified by the UniAddress parameter. If the credentials are not accepted, an SmbAuthException will be thrown. If an error occurs an SmbException will be thrown. If the credentials are valid, the method will return without throwing an exception. See the last FAQ question.

      See also the org.codelibs.jcifs.smb1.smb1.client.logonShare property.

      Parameters:
      dc - the domain controller to authenticate against
      auth - the authentication credentials
      Throws:
      SmbException - if authentication fails or an SMB error occurs
    • logon

      public static void logon(UniAddress dc, int port, NtlmPasswordAuthentication auth) throws SmbException
      Authenticate arbitrary credentials against the specified domain controller using the specified port.
      Parameters:
      dc - the domain controller to authenticate against
      port - the port to connect to
      auth - the authentication credentials
      Throws:
      SmbException - if authentication fails or an SMB error occurs
    • toString

      public String toString()
      Overrides:
      toString in class Object