netcmd: Change GPO commands to use s3 SMB Py bindings
authorTim Beale <timbeale@catalyst.net.nz>
Fri, 11 Jan 2019 01:53:16 +0000 (14:53 +1300)
committerJeremy Allison <jra@samba.org>
Thu, 17 Jan 2019 00:40:30 +0000 (01:40 +0100)
This means we can now use GPO commands on a DC that has SMBv1 disabled.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
python/samba/netcmd/gpo.py

index d44312965086e2cc08cb33012ed5449d7ec88d55..1b5e927f633dc4bbf743b2cd8ac4db861c18cec8 100644 (file)
@@ -43,7 +43,7 @@ import samba.auth
 from samba.auth import AUTH_SESSION_INFO_DEFAULT_GROUPS, AUTH_SESSION_INFO_AUTHENTICATED, AUTH_SESSION_INFO_SIMPLE_PRIVILEGES
 from samba.netcmd.common import netcmd_finddc
 from samba import policy
-from samba import smb
+from samba.samba3 import param as s3param
 from samba.samba3 import libsmb_samba_internal as libsmb
 from samba import NTSTATUSError
 import uuid
@@ -365,7 +365,10 @@ def create_directory_hier(conn, remotedir):
 def smb_connection(dc_hostname, service, lp, creds, sign=False):
     # SMB connect to DC
     try:
-        conn = smb.SMB(dc_hostname, service, lp=lp, creds=creds, sign=sign)
+        # the SMB bindings rely on having a s3 loadparm
+        s3_lp = s3param.get_context()
+        s3_lp.load(lp.configfile)
+        conn = libsmb.Conn(dc_hostname, service, lp=s3_lp, creds=creds, sign=sign)
     except Exception:
         raise CommandError("Error connecting to '%s' using SMB" % dc_hostname)
     return conn