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

Last change on this file was 740, checked in by Silvan Scherrer, 13 years ago

Samba Server: update vendor to 3.6.0

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