samba-tool {user,group,computer,contact} show: avoid base64 encoded strings if possible
authorBjörn Baumbach <bb@sernet.de>
Mon, 25 Nov 2019 13:13:37 +0000 (14:13 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 Nov 2019 00:44:40 +0000 (00:44 +0000)
Be more user friendly and use clear text argument strings if possible.

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/computer.py
python/samba/netcmd/contact.py
python/samba/netcmd/group.py
python/samba/netcmd/user.py

index b66dcc4a7a58ada7334fe0a3869a45d04896f042..11b2938464a159cd4ef31e7629cbc815e2fdabed 100644 (file)
@@ -36,6 +36,7 @@ from samba.auth import system_session
 from samba.samdb import SamDB
 from samba.compat import get_bytes
 from subprocess import check_call, CalledProcessError
+from . import common
 
 from samba import (
     credentials,
@@ -457,8 +458,6 @@ class cmd_computer_edit(Command):
 
     def run(self, computername, credopts=None, sambaopts=None, versionopts=None,
             H=None, editor=None):
-        from . import common
-
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
         samdb = SamDB(url=H, session_info=system_session(),
@@ -639,7 +638,7 @@ attribute.
                                samaccountname)
 
         for msg in res:
-            computer_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
+            computer_ldif = common.get_ldif_for_editor(samdb, msg)
             self.outf.write(computer_ldif)
 
 
index 506e644c3f83a01d21eb8c80cc7bbe5091caa989..b35f3f16a88056e048dcecebe52c877b07010048 100644 (file)
@@ -37,6 +37,7 @@ from samba.netcmd import (
     Option,
 )
 from samba.compat import get_bytes
+from . import common
 
 
 class cmd_create(Command):
@@ -365,8 +366,6 @@ class cmd_edit(Command):
             versionopts=None,
             H=None,
             editor=None):
-        from . import common
-
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
         samdb = SamDB(url=H, session_info=system_session(),
@@ -548,7 +547,7 @@ class cmd_show(Command):
                                contactname)
 
         for msg in res:
-            contact_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
+            contact_ldif = common.get_ldif_for_editor(samdb, msg)
             self.outf.write(contact_ldif)
 
 
index 3a01f8b96e90dec89b517bb5bc7edfff1a33e733..95843eecea41cfbd3e1b46d458d5b7b08880e94c 100644 (file)
@@ -39,6 +39,7 @@ from subprocess import check_call, CalledProcessError
 from samba.compat import get_bytes
 import os
 import tempfile
+from . import common
 
 security_group = dict({"Builtin": GTYPE_SECURITY_BUILTIN_LOCAL_GROUP,
                        "Domain": GTYPE_SECURITY_DOMAIN_LOCAL_GROUP,
@@ -589,7 +590,7 @@ Example3 shows how to display a groups objectGUID and member attributes.
             raise CommandError('Unable to find group "%s"' % (groupname))
 
         for msg in res:
-            group_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
+            group_ldif = common.get_ldif_for_editor(samdb, msg)
             self.outf.write(group_ldif)
 
 
@@ -747,8 +748,6 @@ class cmd_group_edit(Command):
 
     def run(self, groupname, credopts=None, sambaopts=None, versionopts=None,
             H=None, editor=None):
-        from . import common
-
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
         samdb = SamDB(url=H, session_info=system_session(),
index cadd80fd991fc4288c817b49c68398c7be893110..fb8da3d3d51903655fb5bf63bc8808d10128fc6f 100644 (file)
@@ -56,7 +56,7 @@ from samba.netcmd import (
 from samba.compat import text_type
 from samba.compat import get_bytes
 from samba.compat import get_string
-
+from . import common
 
 # python[3]-gpgme is abandoned since ubuntu 1804 and debian 9
 # have to use python[3]-gpg instead
@@ -2389,8 +2389,6 @@ LDAP server using the 'nano' editor.
 
     def run(self, username, credopts=None, sambaopts=None, versionopts=None,
             H=None, editor=None):
-        from . import common
-
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
         samdb = SamDB(url=H, session_info=system_session(),
@@ -2520,7 +2518,7 @@ Example3 shows how to display a users objectSid and memberOf attributes.
             raise CommandError('Unable to find user "%s"' % (username))
 
         for msg in res:
-            user_ldif = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
+            user_ldif = common.get_ldif_for_editor(samdb, msg)
             self.outf.write(user_ldif)