]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: Update 'samba-tool gpo list <>' description
authorAmit Kumar <amitkuma@redhat.com>
Thu, 27 Jun 2019 23:21:57 +0000 (04:51 +0530)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 17 Oct 2019 09:21:20 +0000 (09:21 +0000)
We have a command to get gpo listing from Active Directory.
samba-tool gpo list <username>

This command can list GPOs for both username and machinename,
But command help only shows 'username'.

This PR
- Updates the option presented in help.
- Updates name of variable used to retrieve GPO so that it's
 not misleading if someone reads code later on

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

Signed-off-by: Amit Kumar <amitkuma@redhat.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Oct 17 09:21:20 UTC 2019 on sn-devel-184

python/samba/netcmd/gpo.py

index 047f91951e88c38eb93f1d5ac7a5995940e01861..106c5cf2d56eb97526e618105b846505252fae22 100644 (file)
@@ -478,9 +478,9 @@ class cmd_listall(GPOCommand):
 class cmd_list(GPOCommand):
     """List GPOs for an account."""
 
-    synopsis = "%prog <username> [options]"
+    synopsis = "%prog <username|machinename> [options]"
 
-    takes_args = ['username']
+    takes_args = ['accountname']
     takes_optiongroups = {
         "sambaopts": options.SambaOptions,
         "versionopts": options.VersionOptions,
@@ -492,7 +492,7 @@ class cmd_list(GPOCommand):
                type=str, metavar="URL", dest="H")
     ]
 
-    def run(self, username, H=None, sambaopts=None, credopts=None, versionopts=None):
+    def run(self, accountname, H=None, sambaopts=None, credopts=None, versionopts=None):
 
         self.lp = sambaopts.get_loadparm()
         self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
@@ -503,17 +503,17 @@ class cmd_list(GPOCommand):
 
         try:
             msg = self.samdb.search(expression='(&(|(samAccountName=%s)(samAccountName=%s$))(objectClass=User))' %
-                                    (ldb.binary_encode(username), ldb.binary_encode(username)))
+                                    (ldb.binary_encode(accountname), ldb.binary_encode(accountname)))
             user_dn = msg[0].dn
         except Exception:
-            raise CommandError("Failed to find account %s" % username)
+            raise CommandError("Failed to find account %s" % accountname)
 
         # check if its a computer account
         try:
             msg = self.samdb.search(base=user_dn, scope=ldb.SCOPE_BASE, attrs=['objectClass'])[0]
             is_computer = 'computer' in msg['objectClass']
         except Exception:
-            raise CommandError("Failed to find objectClass for user %s" % username)
+            raise CommandError("Failed to find objectClass for %s" % accountname)
 
         session_info_flags = (AUTH_SESSION_INFO_DEFAULT_GROUPS |
                               AUTH_SESSION_INFO_AUTHENTICATED)
@@ -587,7 +587,7 @@ class cmd_list(GPOCommand):
         else:
             msg_str = 'user'
 
-        self.outf.write("GPOs for %s %s\n" % (msg_str, username))
+        self.outf.write("GPOs for %s %s\n" % (msg_str, accountname))
         for g in gpos:
             self.outf.write("    %s %s\n" % (g[0], g[1]))