s4:torture:smb2: fix the compound.invalid3 test to work against windows
[Samba/gebeck_regimport.git] / source4 / scripting / bin / enablerecyclebin
blobab36ead1b8f2b8a6e6c3ff22d7bf339aa7f077cc
1 #!/usr/bin/env python
3 # enabled the Recycle Bin optional feature
5 import optparse
6 import sys
8 # Find right directory when running from source tree
9 sys.path.insert(0, "bin/python")
11 import samba
12 from samba import getopt as options, Ldb
13 from ldb import SCOPE_BASE
14 import sys
15 import ldb
16 from samba.auth import system_session
18 parser = optparse.OptionParser("enablerecyclebin <URL>")
19 sambaopts = options.SambaOptions(parser)
20 parser.add_option_group(sambaopts)
21 credopts = options.CredentialsOptions(parser)
22 parser.add_option_group(credopts)
23 parser.add_option_group(options.VersionOptions(parser))
25 opts, args = parser.parse_args()
26 opts.dump_all = True
28 if len(args) != 1:
29 parser.print_usage()
30 sys.exit(1)
32 url = args[0]
34 lp_ctx = sambaopts.get_loadparm()
36 creds = credopts.get_credentials(lp_ctx)
37 sam_ldb = Ldb(url, session_info=system_session(), credentials=creds, lp=lp_ctx)
39 # get the rootDSE
40 res = sam_ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
41 rootDse = res[0]
43 configbase=rootDse["configurationNamingContext"]
45 # enable the feature
46 msg = ldb.Message()
47 msg.dn = ldb.Dn(sam_ldb, "")
48 msg["enableOptionalFeature"] = ldb.MessageElement(
49 "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
50 ldb.FLAG_MOD_ADD, "enableOptionalFeature")
51 res = sam_ldb.modify(msg)
53 print "Recycle Bin feature enabled"