Python SMB Connection
-
Hey Guys,
I have a Problem and i don't find my solution...
Here's my test Code:import smb from smb.SMBConnection import SMBConnection from nmb.NetBIOS import NetBIOS netbios = NetBIOS() share_name = "share" user_name = "user" password = "passwd" server_IP = "xxx.xxx.xxx.251" local_machine_name = socket.gethostname() server_machine_name = netbios.queryIPForName(server_IP) print(server_machine_name[0]) # create and establish connection conn = SMBConnection(user_name, password, local_machine_name, server_machine_name[0], domain="WORKGROUP", use_ntlm_v2=True) # 139 # 445 print(conn.connect(server_IP, 445))
i get every Time this Message:
ELEKTROTECHNIK False
but the Function
conn.connect
return on Success True... not False....
i Have no idea what i'm doing wrong...im trying to connect to my Synology NAS 718
i hope you guys know what im doing wrong....
Thanks!!
-
@DavinE I always use it with port=139 on my Western Digital NAS.
-
@DavinE said:
local_machine_name = socket.gethostname()
Try
local_machine_name = socket.gethostname()[0]
-
@cvp i tried both :( same result...
-
@DavinE said:
server_machine_name = netbios.queryIPForName(server_IP)
Sorry, error😢 , try
server_machine_name = netbios.queryIPForName(server_IP)[0]
-
@cvp said:
@DavinE said:
server_machine_name = netbios.queryIPForName(server_IP)
Sorry, error😢 , try
server_machine_name = netbios.queryIPForName(server_IP)[0]
@cvp, no :(
i want to cry ^^
-
last edited by
-
@cvp
yes, sorry :(I used both ports
-
@DavinE strange, I use this successfully
ip = bios.queryName(self.smb_name) return ip[0]
-
@cvp said:
@DavinE strange, I use this successfully
ip = bios.queryName(self.smb_name) return ip[0]
in your case whats the
self.smb_name
? Server Name ?
-
@DavinE sorry, a mistake more,
bios = NetBIOS() srv_name = bios.queryIPForName(remote_smb_ip, timeout=timeout) return srv_name[0]
-
@cvp
hmm...
I get the same output as i get with my codeELEKTROTECHNIK
-
last edited by
-
@DavinE said:
local_machine_name = socket.gethostname()
server_machine_name = netbios.queryIPForName(server_IP)Did you try with
local_machine_name = socket.gethostname()[0] server_machine_name = netbios.queryIPForName(server_IP)[0]
-
@cvp said:
@DavinE said:
in your case whats the self.smb_name? Server Name
Yes
When i use your code above
ip = bios.queryName(self.smb_name) return ip[0]
server_machine_name = netbios.queryIPForName(server_IP)[0]
print(server_machine_name)
ELEKTROTECHNIK
print(local_machine_name)Davin
print(netbios.queryName(server_machine_name))and here None
why none ?
-
@cvp said:
@DavinE said:
local_machine_name = socket.gethostname()
server_machine_name = netbios.queryIPForName(server_IP)Did you try with
local_machine_name = socket.gethostname()[0] server_machine_name = netbios.queryIPForName(server_IP)[0]
This did not work here i get only the first letter
local_machine_name = socket.gethostname()[0]
in my case
D
-
@DavinE could you try with my module
SMB_client.pyand
from SMB_client import SMB_client my_smb = SMB_client(username='admin',password='admin',smb_name='share') my_smb.connect() tree = my_smb.getRemoteTree() for elem in tree: print(elem)
-
@cvp said:
@DavinE could you try with my module
SMB_client.pyand
from SMB_client import SMB_client my_smb = SMB_client(username='admin',password='admin',smb_name='share') my_smb.connect() tree = my_smb.getRemoteTree() for elem in tree: print(elem)
yeah i tried it but i can retry it...
i do not have
SMB_client
installed
should i install it ? and try
-
@DavinE did you see the link in my post?
-
last edited by
-
@cvp said:
@DavinE did you see the link in my post?
yeah sry, that's my mistake....
i get this output:
Error on line 47 TypeError 'NoneType' object is not subscriptable Error on line 62 TypeError str, bytes or bytearray expected, not NoneType Error on line 87 NotReadyError SMB connection not authenticated