source: vendor/current/source4/scripting/bin/enablerecyclebin

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 1.4 KB
Line 
1#!/usr/bin/env python
2#
3# enabled the Recycle Bin optional feature
4#
5import optparse
6import sys
7
8# Find right directory when running from source tree
9sys.path.insert(0, "bin/python")
10
11import samba
12from samba import getopt as options, Ldb
13from ldb import SCOPE_BASE
14import sys
15import ldb
16from samba.auth import system_session
17
18parser = optparse.OptionParser("enablerecyclebin <URL>")
19sambaopts = options.SambaOptions(parser)
20parser.add_option_group(sambaopts)
21credopts = options.CredentialsOptions(parser)
22parser.add_option_group(credopts)
23parser.add_option_group(options.VersionOptions(parser))
24
25opts, args = parser.parse_args()
26opts.dump_all = True
27
28if len(args) != 1:
29 parser.print_usage()
30 sys.exit(1)
31
32url = args[0]
33
34lp_ctx = sambaopts.get_loadparm()
35
36creds = credopts.get_credentials(lp_ctx)
37sam_ldb = Ldb(url, session_info=system_session(), credentials=creds, lp=lp_ctx)
38
39# get the rootDSE
40res = sam_ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
41rootDse = res[0]
42
43configbase=rootDse["configurationNamingContext"]
44
45# enable the feature
46msg = ldb.Message()
47msg.dn = ldb.Dn(sam_ldb, "")
48msg["enableOptionalFeature"] = ldb.MessageElement(
49 "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
50 ldb.FLAG_MOD_ADD, "enableOptionalFeature")
51res = sam_ldb.modify(msg)
52
53print "Recycle Bin feature enabled"
Note: See TracBrowser for help on using the repository browser.