rokkonet

PC・Androidソフトウェア・アプリの開発・使い方に関するメモ

jcifs-ngによるSMBサーバー接続認証

2021 Sep. 03.
2021 Aug. 31.

Up-to-date

                val prop = Properties()  // java.util.Properties
                prop.setProperty("jcifs.smb.client.minVersion", "SMB202")
                prop.setProperty("jcifs.smb.client.maxVersion", "SMB300")
                val baseCxt = BaseContext(PropertyConfiguration(prop))
                val auth = baseCxt.withCredentials(NtlmPasswordAuthenticator(domain, user, password))
                    // Example of domain:  "192.168.1.1"
                val smb = SmbFile(smbUrl, auth)
                    // smbUrl:  smb://DOMAIN/SMB/SERVER/PATH/


Deprecated

                val prop = Properties()  // java.util.Properties
                prop.setProperty("jcifs.smb.client.minVersion", "SMB202")
                prop.setProperty("jcifs.smb.client.maxVersion", "SMB300")
                val baseCxt = BaseContext(PropertyConfiguration(prop))
                val creds = NtlmPasswordAuthentication(baseCxt, domain, user, password)
                val auth: CIFSContext = bc.withCredentials(creds)
                val smb = SmbFile(smbUrl, auth)  // smbUrl: smb://DOMAIN/SMB/SERVER/PATH/