SuperCommand,
)
from samba.samdb import SamDB
-from samba import drs_utils, nttime2string, dsdb, dcerpc
-from samba.dcerpc import misc
+from samba import dsdb, dcerpc
from samba.ndr import ndr_unpack
import samba.security
import samba.auth
def parse_unc(unc):
'''Parse UNC string into a hostname, a service, and a filepath'''
if unc.startswith('\\\\') and unc.startswith('//'):
- return []
+ raise ValueError("UNC doesn't start with \\\\ or //")
tmp = unc[2:].split('/', 2)
if len(tmp) == 3:
return tmp
tmp = unc[2:].split('\\', 2)
if len(tmp) == 3:
- return tmp;
- return []
+ return tmp
+ raise ValueError("Invalid UNC string: %s" % unc)
def copy_directory_remote_to_local(conn, remotedir, localdir):
gplist.remove(g)
break
else:
- raise CommandError("Specified GPO is not linked to this container");
+ raise CommandError("Specified GPO is not linked to this container")
m = ldb.Message()
m.dn = ldb.Dn(self.samdb, container_dn)
inheritance = 0
if 'gPOptions' in msg:
- inheritance = int(msg['gPOptions'][0]);
+ inheritance = int(msg['gPOptions'][0])
if inheritance == dsdb.GPO_BLOCK_INHERITANCE:
print("Container has GPO_BLOCK_INHERITANCE")
if 'gPOptions' in msg:
m['new_value'] = ldb.MessageElement(str(inheritance), ldb.FLAG_MOD_REPLACE, 'gPOptions')
else:
- m['new_value'] = ldb.MessageElement(str(inheritance), ldb.FLAG_MOD_ADD, 'gPOptions');
+ m['new_value'] = ldb.MessageElement(str(inheritance), ldb.FLAG_MOD_ADD, 'gPOptions')
try:
self.samdb.modify(m)
unc = msg['gPCFileSysPath'][0]
try:
[dom_name, service, sharepath] = parse_unc(unc)
- except:
+ except ValueError:
raise CommandError("Invalid GPO path (%s)" % unc)
# SMB connect to DC