gpo: Ensure that gplink works when empty
authorGarming Sam <garming@catalyst.net.nz>
Wed, 20 Feb 2019 00:43:42 +0000 (13:43 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 12 Mar 2019 00:42:19 +0000 (00:42 +0000)
It appears that RSAT can leave a space in the gPLink field, which we need to handle.

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

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/gpo.py

index 95fe5d6d439b9b5b167a543c22cc4812ad2cdfc5..ae06594e719da289d0659d73806d992fa43cc5ee 100644 (file)
@@ -93,6 +93,10 @@ def gplink_options_string(value):
 def parse_gplink(gplink):
     '''parse a gPLink into an array of dn and options'''
     ret = []
+
+    if gplink.strip() == '':
+        return ret
+
     a = gplink.split(']')
     for g in a:
         if not g:
@@ -656,7 +660,7 @@ class cmd_getlink(GPOCommand):
         except Exception:
             raise CommandError("Container '%s' does not exist" % container_dn)
 
-        if msg['gPLink']:
+        if 'gPLink' in msg and msg['gPLink']:
             self.outf.write("GPO(s) linked to DN %s\n" % container_dn)
             gplist = parse_gplink(str(msg['gPLink'][0]))
             for g in gplist: