summaryrefslogtreecommitdiff
path: root/python/samba/netcmd/user.py
AgeCommit message (Collapse)AuthorFilesLines
2021-03-01samba-tool user: add ';format=[GeneralizedTime,UnixTime,TimeSpec]' support ↵Stefan Metzmacher1-28/+68
in "samba-tool user show" This is useful to convert various time values to other formats. Pair-Programmed-With: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-01samba-tool user: add ';format=[GeneralizedTime,UnixTime,TimeSpec]' supportStefan Metzmacher1-0/+125
These are useful to convert various time values to other formats. Pair-Programmed-With: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-01samba-tool user: use an implicit_attrs list instead of add_ATTR variablesStefan Metzmacher1-68/+119
We'll extent GetPasswordCommand.get_password_attributes() to handle more virtual formats in future. It'll be much easier to to maintain a list of attributes we need to filter out again. sAMAccountName and userPrincipalName are always implicitly requested in order to keep the existing code sane. supplementalCredentials and unicodePwd are requested by default when generating virtual password attributes. Pair-Programmed-With: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-01samba-tool user: use remote domain informationBjörn Baumbach1-2/+2
Required, when running get_account_attributes() against a remote samdb. avoid: ERROR(<class 'AttributeError'>): uncaught exception - 'NoneType' object has no attribute 'get' File "bin/python/samba/netcmd/__init__.py", line 186, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/user.py", line 2769, in run obj = self.get_account_attributes(samdb, username, File "bin/python/samba/netcmd/user.py", line 1250, in get_account_attributes realm = self.lp.get("realm") Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-01samba-tool user: fix some typosBjörn Baumbach1-23/+23
Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-01-15samba-tool: Optionally hide disabled/expired accounts in "user list"Björn Baumbach1-2/+28
--hide-expired Do not list expired user accounts --hide-disabled Do not list disabled user accounts Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-11-11samdb: Add samdb.domain_netbios_name()Andrew Bartlett1-8/+2
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2020-11-03samba-tool: add new "user unlock" commandBjörn Baumbach1-1/+73
Can be used to unlock a user when the badPwdCount has been reached. Introduces SamDB error classes, as suggested by Douglas Bagnall <douglas.bagnall@catalyst.net.nz> - thanks! This helps to handle expected failures. Tracebacks of really unexpected failures will not be hidden. Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2020-10-02python2 reduction: Merge remaining compat code into commonDavid Mulder1-2/+2
The remaining compat code (get_string, get_bytes, cmp) are useful helper routines which we should simply merge into common (especially since there is some duplication here). Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Fri Oct 2 14:49:36 UTC 2020 on sn-devel-184
2020-10-01samba-tool user: rename 'user create' to 'user add'Jule Anger1-29/+15
Keep 'user create' for compatibility reasons. Signed-off-by: Jule Anger <ja@sernet.de> Reviewed-by: Björn Baumbach <bb@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2020-10-01samba-tool user: add new user 'rename' commandBjörn Baumbach1-0/+225
Usage: samba-tool user rename <username> [options] Rename a user and related attributes. This command allows to set the user's name related attributes. The user's CN will be renamed automatically. The user's new CN will be made up by combining the given-name, initials and surname. A dot ('.') will be appended to the initials automatically. Use the --force-new-cn option to specify the new CN manually. The username specified on the command is the sAMAccountName. Example1: samba-tool user rename johndoe --surname='Bloggs' Example1 shows how to change the surname of a user 'johndoe' to 'Bloggs' on the local server. The user's CN will be renamed automatically, based on the given name, initials and surname. Pair-Programmed-With: Jule Anger <ja@sernet.de> Signed-off-by: Björn Baumbach <bb@sernet.de> Signed-off-by: Jule Anger <ja@sernet.de> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2020-09-02samba-tool: Create unix user with modified template homedirDavid Mulder1-2/+3
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-11python compat: remove text_typeDouglas Bagnall1-3/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2020-03-05python: Fix userPrincipalName in GetPasswordCommand.get_account_attributes()Jonathon Reinhart1-1/+1
Signed-off-by: Jonathon Reinhart <Jonathon.Reinhart@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Mar 5 16:27:50 UTC 2020 on sn-devel-184
2020-01-21samba-tool: add -b/--base-dn option to users list commandJule Anger1-2/+10
With this option it's e.g. possible to list the users of a specify OU or users which are located under a different specific place in the AD. Signed-off-by: Jule Anger <ja@sernet.de> Reviewed-by: Björn Baumbach <bb@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-01-21samba-tool: add --full-dn option for user getgroups commandBjörn Baumbach1-2/+17
Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-01-21samba-tool: add --full-dn option to user list commandJule Anger1-1/+14
With this option the command lists the users distringuished names instead of the sAMAccountNames. Signed-off-by: Jule Anger <ja@sernet.de> Reviewed-by: Björn Baumbach <bb@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-01-15samba-tool: implement user getgroups commandStefan Metzmacher1-0/+78
samba-tool user getgroups command to list a users group memberships. Pair-programmed-with: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andreas Schneider <asn@samba.org>
2020-01-15samba-tool: implement user setprimary group command (set primaryGroupID)Björn Baumbach1-0/+111
Introduce an option to set the primaryGroupID attribute of a user account. Pair-programmed-with: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-12-10samba-tool: add user-sensitive command to set not-delegated flagIsaac Boukris1-0/+58
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2019-11-29samba-tool {user,group,computer,contact} show: avoid base64 encoded strings ↵Björn Baumbach1-4/+2
if possible 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>
2019-10-23samba-tool: py3 compatiblity in 'user syncpasswords --daemon'Heinz Hoelzl1-1/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14154 Signed-off-by: Heinz Hölzl <heinz.hoelzl@gvcc.net> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Björn Baumbach <bb@sernet.de> Autobuild-User(master): Björn Baumbach <bb@sernet.de> Autobuild-Date(master): Wed Oct 23 15:54:43 UTC 2019 on sn-devel-184
2019-10-17samba-tool: Add facility to add rfc2307 attributes to an already created ↵Rowland Penny1-0/+224
user or group Signed-off-by: Rowland Penny <rpenny@samba.org> Reviewed-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlet <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Oct 17 12:21:55 UTC 2019 on sn-devel-184
2019-09-24user.py: avoid inefficient string concatenationsBjörn Jacke1-30/+28
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-09-21user.py: import tempfile module only where neededBjörn Jacke1-1/+1
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-08-22python: use os.urandom, which is available in python by definitionBjörn Jacke1-39/+2
os.urandom also uses CSPRNG methods like getrandom() when the underlying OS provides those. Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool user edit: avoid base64 encoded strings in editable ldif if possibleBjörn Baumbach1-1/+2
Use clear text arguments strings if possible. Makes it more comfortable for users to edit the user objects attributes. Remove test from knownfail: samba.tests.samba_tool.user_edit.change_attribute_force_no_base64 Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool user edit: simplify codeBjörn Baumbach1-3/+1
Use "None"-changetype here, instead of "Add". This avoids the need to remove the changetype line afterwards. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool user edit: use ldb methods to create ldif to modify userBjörn Baumbach1-38/+13
Remove tests from knownfail: samba.tests.samba_tool.user_edit.add_attribute_base64 samba.tests.samba_tool.user_edit.add_attribute_base64_control samba.tests.samba_tool.user_edit.change_attribute_base64_control BUG: https://bugzilla.samba.org/show_bug.cgi?id=14003 Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool: fix format of command description (help messages)Björn Baumbach1-7/+7
Need to quote the backslash '\'. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-09netcmd/user: python[3]-gpgme unsupported and replaced by python[3]-gpgJoe Guo1-25/+61
python[3]-gpgme is deprecated since ubuntu 1804 and debian 9. use python[3]-gpg instead, and adapt the API. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13728 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> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2018-11-20sync_passwords: Remove dirsync cookie logging for continuous operationGarming Sam1-1/+2
Under normal operation, users shouldn't see giant cookies in their logs. We still log the initial cookie retrieved from the cache database, which should still be helpful for identifying corrupt cookies. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13686 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-14python/samba/netcmd: PY3 port samba.tests.samba_tool.editNoel Power1-1/+1
Need to write bytes to file Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-01samba-tool user: fix message formatDouglas Bagnall1-2/+3
There were 2 % formats and 3 arguments. Also reformat for line length Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-11-01python: PY3 Exceptions don't have .messageDouglas Bagnall1-1/+1
but str(e) is the same as str(e.message), so we can use that on 2 and 3. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-10-29python: do not use "is" for string equalityDouglas Bagnall1-5/+5
This is not always going to work, and is not guaranteed to be consistent even between minor versions. Here is a simple counterexample: >>> a = 'hello' >>> a is 'hello' True >>> a is 'hello'.lower() False >>> a == a.lower() True Possibly it always works for the empty string, but we cannot rely on that. Signed-off-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): Mon Oct 29 23:13:36 CET 2018 on sn-devel-144
2018-10-25samba-tool user: remove unused importDouglas Bagnall1-1/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-09-06PEP8: fix E122: continuation line missing indentation or outdentedJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-05samba-tool: add virtualKerberosSalt attribute to 'user ↵Stefan Metzmacher1-0/+24
getpassword/syncpasswords' This might be useful for someone, but at least it's very useful for tests. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13539 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03python/samba/netcmd: PY2/PY3 changes required for user_virtualCryptSHA testNoel Power1-5/+10
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03python/samba/tests: PY2/PY3 required changes for samba.tests.samba_tool.userNoel Power1-3/+3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03s4/selftest: enable samba.tests.samba_tool.user_wdigest for python3Noel Power1-1/+2
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03python/samba: PY3 port for samba.tests.samba_tool.user_wdigest testNoel Power1-14/+15
In addition to the attributes that caused some issues specifically with the test some other ldb.bytes objects (those seen to be used as strings) have been adjusted (with str()) to ensure they should work correct in PY3. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E712: comparison to False should be 'if cond is False:' or 'if not ↵Joe Guo1-1/+1
cond:' 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 E703: statement ends with a semicolonJoe Guo1-1/+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 E306: expected 1 blank line before a nested definition, found 0Joe Guo1-0/+2
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 E305: expected 2 blank lines after class or function definition, ↵Joe Guo1-0/+1
found 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 E303: too many blank lines (2)Joe Guo1-2/+0
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 E302: expected 2 blank lines, found 1Joe Guo1-0/+13
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 E261: at least two spaces before inline commentJoe Guo1-2/+2
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>