3 # enabled the Recycle Bin optional feature
8 # Find right directory when running from source tree
9 sys
.path
.insert(0, "bin/python")
12 from samba
import getopt
as options
, Ldb
13 from ldb
import SCOPE_BASE
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()
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
)
40 res
= sam_ldb
.search(base
="", expression
="", scope
=SCOPE_BASE
, attrs
=["configurationNamingContext"])
43 configbase
=rootDse
["configurationNamingContext"]
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"