[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Sun Mar 17 05:57:03 MDT 2013


The branch, master has been updated
       via  96d731c samba-tool group list: add more info to samba-tool group list
      from  1d15fc7 Fix bug #9724 - is_encrypted_packet() function incorrectly used inside server.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 96d731c79befdee297eb0e72a3488547f6361ab4
Author: Ricky Nance <ricky.nance at weaubleau.k12.mo.us>
Date:   Mon Mar 11 14:47:19 2013 -0500

    samba-tool group list: add more info to samba-tool group list
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Sun Mar 17 12:56:47 CET 2013 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 python/samba/netcmd/group.py |   48 +++++++++++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py
index 731d4c1..4004a7d 100644
--- a/python/samba/netcmd/group.py
+++ b/python/samba/netcmd/group.py
@@ -27,6 +27,7 @@ from getpass import getpass
 from samba.auth import system_session
 from samba.samdb import SamDB
 from samba.dsdb import (
+    GTYPE_SECURITY_BUILTIN_LOCAL_GROUP,
     GTYPE_SECURITY_DOMAIN_LOCAL_GROUP,
     GTYPE_SECURITY_GLOBAL_GROUP,
     GTYPE_SECURITY_UNIVERSAL_GROUP,
@@ -35,8 +36,13 @@ from samba.dsdb import (
     GTYPE_DISTRIBUTION_UNIVERSAL_GROUP,
 )
 
-security_group = dict({"Domain": GTYPE_SECURITY_DOMAIN_LOCAL_GROUP, "Global": GTYPE_SECURITY_GLOBAL_GROUP, "Universal": GTYPE_SECURITY_UNIVERSAL_GROUP})
-distribution_group = dict({"Domain": GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP, "Global": GTYPE_DISTRIBUTION_GLOBAL_GROUP, "Universal": GTYPE_DISTRIBUTION_UNIVERSAL_GROUP})
+security_group = dict({"Builtin": GTYPE_SECURITY_BUILTIN_LOCAL_GROUP,
+                       "Domain": GTYPE_SECURITY_DOMAIN_LOCAL_GROUP,
+                       "Global": GTYPE_SECURITY_GLOBAL_GROUP,
+                       "Universal": GTYPE_SECURITY_UNIVERSAL_GROUP})
+distribution_group = dict({"Domain": GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP,
+                           "Global": GTYPE_DISTRIBUTION_GLOBAL_GROUP,
+                           "Universal": GTYPE_DISTRIBUTION_UNIVERSAL_GROUP})
 
 
 class cmd_group_add(Command):
@@ -274,6 +280,10 @@ class cmd_group_list(Command):
     takes_options = [
         Option("-H", "--URL", help="LDB URL for database or target server", type=str,
                metavar="URL", dest="H"),
+        Option("-v", "--verbose",
+               help="Verbose output, showing group type and group scope.",
+               action="store_true"),
+
         ]
 
     takes_optiongroups = {
@@ -282,7 +292,8 @@ class cmd_group_list(Command):
         "versionopts": options.VersionOptions,
         }
 
-    def run(self, sambaopts=None, credopts=None, versionopts=None, H=None):
+    def run(self, sambaopts=None, credopts=None, versionopts=None, H=None,
+            verbose=False):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
@@ -292,13 +303,36 @@ class cmd_group_list(Command):
         domain_dn = samdb.domain_dn()
         res = samdb.search(domain_dn, scope=ldb.SCOPE_SUBTREE,
                     expression=("(objectClass=group)"),
-                    attrs=["samaccountname"])
+                    attrs=["samaccountname", "grouptype"])
         if (len(res) == 0):
             return
 
-        for msg in res:
-            self.outf.write("%s\n" % msg.get("samaccountname", idx=0))
+        if verbose:
+            self.outf.write("Group Name                                  Group Type      Group Scope\n")
+            self.outf.write("-----------------------------------------------------------------------------\n")
 
+            for msg in res:
+                self.outf.write("%-44s" % msg.get("samaccountname", idx=0))
+                hgtype = hex(int("%s" % msg["grouptype"]) & 0x00000000FFFFFFFF)
+                if (hgtype == hex(int(security_group.get("Builtin")))):
+                    self.outf.write("Security         Builtin\n")
+                elif (hgtype == hex(int(security_group.get("Domain")))):
+                    self.outf.write("Security         Domain\n")
+                elif (hgtype == hex(int(security_group.get("Global")))):
+                    self.outf.write("Security         Global\n")
+                elif (hgtype == hex(int(security_group.get("Universal")))):
+                    self.outf.write("Security         Universal\n")
+                elif (hgtype == hex(int(distribution_group.get("Global")))):
+                    self.outf.write("Distribution     Global\n")
+                elif (hgtype == hex(int(distribution_group.get("Domain")))):
+                    self.outf.write("Distribution     Domain\n")
+                elif (hgtype == hex(int(distribution_group.get("Universal")))):
+                    self.outf.write("Distribution     Universal\n")
+                else:
+                    self.outf.write("\n")
+        else:
+            for msg in res:
+                self.outf.write("%s\n" % msg.get("samaccountname", idx=0))
 
 class cmd_group_list_members(Command):
     """List all members of an AD group.


-- 
Samba Shared Repository


More information about the samba-cvs mailing list