summaryrefslogtreecommitdiff
path: root/python/samba/netcmd/main.py
AgeCommit message (Collapse)AuthorFilesLines
2025-02-08samba-tool: all subcommands know --versionDouglas Bagnall1-5/+0
Before `samba-tool -V` would give you the version, but `samba-tool spn -V` would complain. An ad-hoc selection of sub-commands already supported --version, depending on whether VersionOptions was manually added to the takes_options dict. The .run() methods of these subcommands all take a 'versionopts' keyword argument, but never use it. If it was set (i.e., argv contained "--version"), the process never gets to .run(), so the value of versionopts.version is always None in run(). After this commit we can remove VersionOptions/versionopts from sub-commands. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15770 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
2024-03-01netcmd: gmsa: base cli commands for group managed service accountsRob van der Linde1-0/+1
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2024-02-16netcmd: support hyphens in top-level commands and convert to underscoreRob van der Linde1-2/+3
Hyphens in python modules are invalid and makes them only importable by importlib, which makes them harder to import in tests. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2023-12-15netcmd: add shell commandRob van der Linde1-0/+1
A simple samba-tool shell, can be quite useful to play around with the ldb database and models. All models get imported and the samdb connection variable made available. Example usage: bin/samba-tool shell -H <host> --workgroup <workgroup> --realm <realm> >>> silos = AuthenticationSilo.query(ldb) >>> for silo in silos: ... print(silo) ... Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Dec 15 03:51:55 UTC 2023 on atb-devel-224
2022-09-08pytest/samba-tool: entry function follows too logicDouglas Bagnall1-2/+9
To further align the logic of the tool and the tests, we use the same logic in the test function as in samba-tool. In effect, this means the function is even less likely to raise an exception, rahter printing it out and returning an error code. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-08samba-tool: add a convenience function that does it allDouglas Bagnall1-0/+7
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool: implement contact management commandsBjörn Baumbach1-0/+1
Usage: samba-tool contact <subcommand> Contact management. Available subcommands: create - Create a new contact. delete - Delete a contact. edit - Modify a contact. list - List all contacts. move - Move a contact object to an organizational unit or container. show - Display a contact. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E123: closing bracket does not match indentation of opening ↵Joe Guo1-1/+1
bracket's line Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-05-29python/samba/netcmd/schema.py: add schema query and management.William Brown1-0/+1
Schema management in active directory is complex and dangerous. Having a tool that safely wraps administrative tasks as well as allowing query of the schema will make this complex topic more accessible to administrators. Signed-off-by: William Brown <william@blackhats.net.au> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-05-29python/samba/netcmd/{forest.py,main.py}: add configuration controlsWilliam Brown1-0/+1
With samba-tool we should expose ways to easily administer and control common configuration options. This adds the base framework for modifying forest settings, generally stored in cn=configuration partition. An example is: samba-tool forest directory_service show samba-tool forest directory_service dsheuristics X Signed-off-by: William Brown <william@blackhats.net.au> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-04-13python: bulk replace dict.iteritems to items for py3Joe Guo1-3/+1
In py3, iterxxx methods are removed. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-06samba-tool: implement computer management commandsBjörn Baumbach1-0/+1
Usage: samba-tool computer <subcommand> Computer management. Available subcommands: create - Create a new computer. delete - Delete a computer. list - List all computers. move - Move a computer to an organizational unit/container. show - Display a computer AD object Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-02-08samba-tool: implement ou management commandsBjörn Baumbach1-0/+1
Available subcommands: create - Create an organizational unit. delete - Delete an organizational unit. list - List all organizational units listobjects - List all objects in an organizational unit. move - Move an organizational unit. rename - Rename an organizational unit. Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-01-13samba-tool visualize for understanding AD DC behaviourDouglas Bagnall1-0/+1
To work out what is happening in a replication graph, it is sometimes helpful to use visualisations. We introduce a samba-tool subcommand to write Graphviz dot output and generate text-based heatmaps of the distance in hops between DCs. There are two subcommands, two graphical modes, and (roughly) two modes of operation with respect to the location of authority. `samba-tool visualize ntdsconn` looks at NTDS Connections. `samba-tool visualize reps` looks at repsTo and repsFrom objects. In '--distance' mode (default), the distances between DCs are shown in a matrix in the terminal. With '--color=yes', this is depicted as a heatmap. With '--utf8' it is a lttle prettier. In '--dot' mode, Graphviz dot output is generated. When viewed using dot or xdot, this shows the network as a graph with DCs as vertices and connections edges. Certain types of degenerate edges are shown in different colours or line-styles. Normally samba-tool talks to one database; with the '-r' (a.k.a. '--talk-to-remote') option attempts are made to contact all the DCs known to the first database. This is necessary to get sensible results from `samba-tool visualize reps` because the repsFrom/To objects are not replicated, and it can reveal replication issues in other modes. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-12-22samba-tool: give cache_loader pseudo-dict a .get() methodDouglas Bagnall1-0/+6
This makes it more dict-like, and makes the next patch (adding samba-tool help) simpler. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-07-20samba-tool: Speed up all samba-tool commandsGarming Sam1-37/+41
This in particular helps the docs.py test halve in time (at least on my machine) NOTE: The removal of enable_null_tracking is required because we are no longer importing join.py in every single samba-tool invocation. Without removing this line, memory would be hanging from both the actual NULL context and the talloc_null_context (causing a segfault at system_exit). Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Wed Jul 20 12:47:24 CEST 2016 on sn-devel-144
2016-05-19python:samba: move netcmd/time.py to python/samba/netcmd/nettime.pyStefan Metzmacher1-1/+1
This allows 'import time' to work. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu May 19 15:21:58 CEST 2016 on sn-devel-144
2015-10-26samba-tool: Remove vampire subcommand and now unused libnet_Vampire()Andrew Bartlett1-2/+0
This has been deprecated for a long time now Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2013-03-02Move python modules from source4/scripting/python/ to python/.Jelmer Vernooij1-0/+70
Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Mar 2 03:57:34 CET 2013 on sn-devel-104