diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 17:47:29 +0000 |
commit | 4f5791ebd03eaec1c7da0865a383175b05102712 (patch) | |
tree | 8ce7b00f7a76baa386372422adebbe64510812d4 /source4/scripting/bin/enablerecyclebin | |
parent | Initial commit. (diff) | |
download | samba-4f5791ebd03eaec1c7da0865a383175b05102712.tar.xz samba-4f5791ebd03eaec1c7da0865a383175b05102712.zip |
Adding upstream version 2:4.17.12+dfsg.upstream/2%4.17.12+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'source4/scripting/bin/enablerecyclebin')
-rwxr-xr-x | source4/scripting/bin/enablerecyclebin | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source4/scripting/bin/enablerecyclebin b/source4/scripting/bin/enablerecyclebin new file mode 100755 index 0000000..3477f90 --- /dev/null +++ b/source4/scripting/bin/enablerecyclebin @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# +# enabled the Recycle Bin optional feature +# +import optparse +import sys + +# Find right directory when running from source tree +sys.path.insert(0, "bin/python") + +import samba +from samba import getopt as options, Ldb +from ldb import SCOPE_BASE +import sys +import ldb +from samba.auth import system_session + +parser = optparse.OptionParser("enablerecyclebin <URL>") +sambaopts = options.SambaOptions(parser) +parser.add_option_group(sambaopts) +credopts = options.CredentialsOptions(parser) +parser.add_option_group(credopts) +parser.add_option_group(options.VersionOptions(parser)) + +opts, args = parser.parse_args() +opts.dump_all = True + +if len(args) != 1: + parser.print_usage() + sys.exit(1) + +url = args[0] + +lp_ctx = sambaopts.get_loadparm() + +creds = credopts.get_credentials(lp_ctx) +sam_ldb = Ldb(url, session_info=system_session(), credentials=creds, lp=lp_ctx) + +# get the rootDSE +res = sam_ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"]) +rootDse = res[0] + +configbase=rootDse["configurationNamingContext"] + +# enable the feature +msg = ldb.Message() +msg.dn = ldb.Dn(sam_ldb, "") +msg["enableOptionalFeature"] = ldb.MessageElement( + "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a", + ldb.FLAG_MOD_ADD, "enableOptionalFeature") +res = sam_ldb.modify(msg) + +print("Recycle Bin feature enabled") |