From aacbd383b9e843b5d36b91ef75f6f2d2724a438b Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 28 Jun 2019 04:51:57 +0530 Subject: [PATCH] samba-tool: Update 'samba-tool gpo list <>' description We have a command to get gpo listing from Active Directory. samba-tool gpo list 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 Reviewed-by: Douglas Bagnall Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Thu Oct 17 09:21:20 UTC 2019 on sn-devel-184 --- python/samba/netcmd/gpo.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 047f91951e8..106c5cf2d56 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -478,9 +478,9 @@ class cmd_listall(GPOCommand): class cmd_list(GPOCommand): """List GPOs for an account.""" - synopsis = "%prog [options]" + synopsis = "%prog [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])) -- 2.47.3