Open donaldhughes opened 7 years ago
Here's the code chunk I'm running...
SharpCifs.Config.SetProperty("jcifs.smb.client.laddr", "192.168.1.171"); // ip of iPhone
SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "8137");
try
{
var auth1 = new NtlmPasswordAuthentication("domain", "user", "password");
var smb1 = new SmbFile("smb://192.168.1.218/Docs/Documentation", auth1);
Console.WriteLine($"exists? {smb1.Exists()}");
} catch(Exception ex) {
Console.WriteLine(ex.Message);
}
Hi!
The most frequently occurring problems is on a network, but...
on a Windows Domain.
Are you using Active Directory( or NT Domain)? I have not confirmed that it can be used correctly under AD Env, so I will try it.
if you trying on Workdgroup network, remove "domain", like:
var auth1 = new NtlmPasswordAuthentication("domain", "user", "password");
↓
var auth1 = new NtlmPasswordAuthentication(null, "user", "password");
Thanks, it's on a Windows domain. I've tried both a domain account and a local administrator account. I've also tried a share allowing access to Everyone. Fails to connect.
I also tried the "Scan Servers & Shares on LAN" example (specifying the machine instead of scanning the LAN), and it resulted in the same "Failed to connect" exception.
Not sure if it helps, but I am able to connect to this share from my iPad using Stratospherix FileBrowserLite, but NOT from Readdle Documents. I'm assuming there's an underlying difference in how SMB is implemented.
Hi! I'm sorry for being late.
I attempted to connect to a share on Active Directory, it succeeded.
Env: [AD-Server] OS: Win2012R2 IP: 192.168.254.21 Domian Name: dobes.local Domain's User: domuser1 Password: P@ssw0rd
[Share-hosted PC] OS: Win10Pro(ver1709-FallCreatorUpdate) IP: 192.168.254.31 Share Name: Share
Code:
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
//Get SmbFile-Object of a folder.
var auth2 = new NtlmPasswordAuthentication("dobes.local", "domuser1", "P@ssw0rd");
var folder = new SmbFile("smb://192.168.254.31/Share/", auth2);
//UnixTime
var epocDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
Console.WriteLine("--------------------------------------------------");
Console.WriteLine("");
//List items
foreach (SmbFile item in folder.ListFiles())
{
var lastModDate = epocDate.AddMilliseconds(item.LastModified())
.ToLocalTime();
var name = item.GetName();
var type = item.IsDirectory() ? "dir" : "file";
var date = lastModDate.ToString("yyyy-MM-dd HH:mm:ss");
var msg = $"{name} ({type}) - LastMod: {date}";
Console.WriteLine(msg);
}
Console.WriteLine("");
Console.WriteLine("--------------------------------------------------");
}
Console:
Loaded assembly: /Users/vm/Library/Developer/CoreSimulator/Devices/0F65016A-0BCE-4914-BDD6-0E1C62011AE1/data/Containers/Bundle/Application/FF36AB38-B43E-437D-A16E-FD32F8B76DE0/SmbTest.app/System.Security.Cryptography.Algorithms.dll [External]
Loaded assembly: /Users/vm/Library/Developer/CoreSimulator/Devices/0F65016A-0BCE-4914-BDD6-0E1C62011AE1/data/Containers/Bundle/Application/FF36AB38-B43E-437D-A16E-FD32F8B76DE0/SmbTest.app/System.Reflection.Extensions.dll [External]
Loaded assembly: /Users/vm/Library/Caches/Xamarin/XMA/Agents/Inspector/iOS/Xamarin.Interactive.iOS.dll [External]
Loaded assembly: /Users/vm/Library/Caches/Xamarin/XMA/Agents/Inspector/iOS/Xamarin.Interactive.dll [External]
2017-11-26 09:43:46.891 SmbTest[1614:29491] --------------------------------------------------
2017-11-26 09:43:46.892 SmbTest[1614:29491]
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
Thread started: #8
Thread started: <Thread Pool> #9
Thread started: <Thread Pool> #10
Thread started: <Thread Pool> #11
2017-11-26 09:43:48.046 SmbTest[1614:29491] 20171115_ml17.sql (file) - LastMod: 2017-11-15 16:45:32 <- It's file name in the shared folder.
2017-11-26 09:43:48.048 SmbTest[1614:29491]
2017-11-26 09:43:48.049 SmbTest[1614:29491] --------------------------------------------------
Thread finished: <Thread Pool> #7
Thread finished: <Thread Pool> #6
Thread finished: <Thread Pool> #10
Apparently, this problem seems to be irrelevant to Active Directory.
var auth1 = new NtlmPasswordAuthentication("domain", "user", "password");
var smb1 = new SmbFile("smb://192.168.1.218/Docs/Documentation", auth1);
Console.WriteLine($"exists? {smb1.Exists()}");
Is "Documentation" a folder? If so, '/' is required at the end of the uri string. like:
var smb1 = new SmbFile("smb://192.168.1.218/Docs/Documentation/", auth1);
Depending on the situation you use, settings such as previous IP address may be left. try Config.Apply() method. like:
SharpCifs.Config.SetProperty("jcifs.smb.client.laddr", "192.168.1.171"); // ip of iPhone
SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "8137");
SharpCifs.Config.Apply(); // <- here
For now, I can not find to come up with these other things...
(I still hope that you are watching here...) I released a new version, 2.12. It's connect even without specifying a local address.
Thanks for checking... I updated the package, but still unable to connect, though. I can still connect to the specific Windows share from a Mac and from Stratospherix FileBrowser for Business app on an iPad. I've tried two different Windows machines, one was running Windows 10 and another running Windows 7.
On Sun, Feb 4, 2018 at 6:33 AM, ume05rw notifications@github.com wrote:
I still hope that you are watching here...
I released a new version, 2.12. It's connect even without specifying a local address.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ume05rw/SharpCifs.Std/issues/12#issuecomment-362903433, or mute the thread https://github.com/notifications/unsubscribe-auth/AE9B6oBbI09xExeRsYsVpMXLYR4kZfN0ks5tRaOUgaJpZM4Qas-k .
Maybe SMB 1.0 on your Windows has been disabled?
SharpCifs.Std only supports up to SMB 1.0. (There is the same restriction as JCIFS)
Last year Wanna Cry virus became popular. As a measure, many PCs seem to have invalidated SMB 1.0.
I am using the jcifs maven jar of version 1.3.17 and facing the same issue
My code is mentioned below: String path="smb://43.90.254.51/NWInput/BDIAutomationNW/Master_Automation_Custom_Network_to_FTP_Input/"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass); SmbFile smbFile = new SmbFile(path,auth); arrFileList = smbFile.listFiles();
Give an error jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/43.90.254.51 jcifs.util.transport.TransportException java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at jcifs.util.transport.Transport.readn(Transport.java:29) at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388) at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288) at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319) at jcifs.util.transport.Transport.run(Transport.java:241) at java.lang.Thread.run(Unknown Source)
at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)
please advice
meet the same problem, as I investigating, my random local port(25293..) is not open(), then I switched to set a specific opened port(1400), SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "1400"); SharpCifs.Config.Apply(); but the code does not work, I still get error with the random port.
FYI, installed today and met the same problem. Is it still not fixed? But the advertising works, specially the hyper noisy sound :)
I am facing the same error. can anyone tell how did they fix it?
I think, the issue is something about windows server or server config. When I use it on my dev server, its edition is windows server 2008, it worked. But when I change it to windows server 2022, it appears. I also try to open some windows service and close the firewalls, but still failed.
I think, the issue is something about windows server or server config. When I use it on my dev server, its edition is windows server 2008, it worked. But when I change it to windows server 2022, it appears. I also try to open some windows service and close the firewalls, but still failed.
maybe the solution is here. https://github.com/ume05rw/SharpCifs.Std/issues/38
I've followed the instructions, but all of the examples produce the same error. I am able to connect to the share from a Mac, other Windows machines, and from another app, AirDisk Pro. The share is on a Windows 10 Professional machine on a Windows Domain. Any ideas or known issues?