3 # enabled the Recycle Bin optional feature
10 # Find right directory when running from source tree
11 sys.path.insert(0, "bin/python")
14 from samba import getopt as options, Ldb
15 from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError
19 parser = optparse.OptionParser("enablerecyclebin <URL>")
20 sambaopts = options.SambaOptions(parser)
21 parser.add_option_group(sambaopts)
22 credopts = options.CredentialsOptions(parser)
23 parser.add_option_group(credopts)
24 parser.add_option_group(options.VersionOptions(parser))
26 opts, args = parser.parse_args()
35 lp_ctx = sambaopts.get_loadparm()
37 creds = credopts.get_credentials(lp_ctx)
38 sam_ldb = Ldb(url, credentials=creds, lp=lp_ctx)
41 res = sam_ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
44 configbase=rootDse["configurationNamingContext"]
48 msg.dn = ldb.Dn(sam_ldb, "")
49 msg["enableOptionalFeature"] = ldb.MessageElement(
50 "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
51 ldb.FLAG_MOD_ADD, "enableOptionalFeature")
52 res = sam_ldb.modify(msg)
54 print "Recycle Bin feature enabled"