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
18 from samba
.auth
import system_session
20 parser
= optparse
.OptionParser("enablerecyclebin <URL>")
21 sambaopts
= options
.SambaOptions(parser
)
22 parser
.add_option_group(sambaopts
)
23 credopts
= options
.CredentialsOptions(parser
)
24 parser
.add_option_group(credopts
)
25 parser
.add_option_group(options
.VersionOptions(parser
))
27 opts
, args
= parser
.parse_args()
36 lp_ctx
= sambaopts
.get_loadparm()
38 creds
= credopts
.get_credentials(lp_ctx
)
39 sam_ldb
= Ldb(url
, session_info
=system_session(), credentials
=creds
, lp
=lp_ctx
)
42 res
= sam_ldb
.search(base
="", expression
="", scope
=SCOPE_BASE
, attrs
=["configurationNamingContext"])
45 configbase
=rootDse
["configurationNamingContext"]
49 msg
.dn
= ldb
.Dn(sam_ldb
, "")
50 msg
["enableOptionalFeature"] = ldb
.MessageElement(
51 "CN=Partitions," + str(configbase
) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
52 ldb
.FLAG_MOD_ADD
, "enableOptionalFeature")
53 res
= sam_ldb
.modify(msg
)
55 print "Recycle Bin feature enabled"