1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-19 12:23:49 +03:00

samba-tool: Update 'samba-tool gpo list <>' description

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
This commit is contained in:
Amit Kumar
2019-06-28 04:51:57 +05:30
committed by Andreas Schneider
parent 6bd2f0e9c4
commit aacbd383b9

View 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]))