diff --git a/Example/Example/ServerDiscoveryViewController.swift b/Example/Example/ServerDiscoveryViewController.swift index 6a27405..3cebb85 100644 --- a/Example/Example/ServerDiscoveryViewController.swift +++ b/Example/Example/ServerDiscoveryViewController.swift @@ -76,7 +76,7 @@ extension ServerDiscoveryViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let svr = self.servers[indexPath.row] - let smbServer = SMBServer(hostname: svr.name, ipAddress: svr.ipAddress) + let smbServer = SMBServer(hostname: svr.name, ipAddress: svr.ipAddress, domain: svr.group) self.tableView.deselectRow(at: indexPath, animated: true) let vc = UIStoryboard.authViewController(server: smbServer) diff --git a/Sources/NetBIOSNameServiceEntry.swift b/Sources/NetBIOSNameServiceEntry.swift index c8f4f2c..6bb94f6 100644 --- a/Sources/NetBIOSNameServiceEntry.swift +++ b/Sources/NetBIOSNameServiceEntry.swift @@ -74,7 +74,7 @@ public struct NetBIOSNameServiceEntry { } public var smbServer: SMBServer { - return SMBServer(hostname: self.name, ipAddress: self.ipAddress) + return SMBServer(hostname: self.name, ipAddress: self.ipAddress, domain: self.group) } } diff --git a/Sources/SMBServer.swift b/Sources/SMBServer.swift index 8c516c3..d825918 100644 --- a/Sources/SMBServer.swift +++ b/Sources/SMBServer.swift @@ -11,15 +11,18 @@ import Foundation public struct SMBServer { public let hostname: String public let ipAddress: UInt32 + public let domain: String - public init(hostname: String, ipAddress: UInt32) { + public init(hostname: String, ipAddress: UInt32, domain: String) { self.hostname = hostname self.ipAddress = ipAddress + self.domain = domain } // fails initiation if ipAddress lookup fails - public init?(hostname: String) { + public init?(hostname: String, domain: String = "") { self.hostname = hostname + self.domain = domain let ns = NetBIOSNameService() if let addr = ns.resolveIPAddress(forName: self.hostname, ofType: .fileServer) { self.ipAddress = addr diff --git a/Sources/SMBSession.swift b/Sources/SMBSession.swift index 5432735..3250359 100644 --- a/Sources/SMBSession.swift +++ b/Sources/SMBSession.swift @@ -255,7 +255,7 @@ public class SMBSession { } smb_session_set_creds(self.rawSession, - self.server.hostname.cString(using: .utf8), + self.server.domain.cString(using: .utf8), self.credentials.userName.cString(using: .utf8), self.credentials.password.cString(using: .utf8)) if smb_session_login(self.rawSession) != 0 {