summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-18 11:44:20 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-18 21:03:39 +1100
commit811b4054f95dca3c61a32b99627394ba40f9c1fc (patch)
treebb11d1c39040714dfa89db94e1ea15b910aff8ad /source4/scripting
parent20869a0bf0758936b31dc648db7c1ee435dadc34 (diff)
downloadsamba-811b4054f95dca3c61a32b99627394ba40f9c1fc.tar.gz
samba-811b4054f95dca3c61a32b99627394ba40f9c1fc.tar.bz2
samba-811b4054f95dca3c61a32b99627394ba40f9c1fc.zip
s4-scripts: add a enablerecyclebin script
This can be used to enable the recyclebin on a windows box. Once we properly implement this feature in samba we will use this to enable the feature on ourselves as well.
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/enablerecyclebin54
1 files changed, 54 insertions, 0 deletions
diff --git a/source4/scripting/bin/enablerecyclebin b/source4/scripting/bin/enablerecyclebin
new file mode 100755
index 0000000000..d02e90b533
--- /dev/null
+++ b/source4/scripting/bin/enablerecyclebin
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+#
+# enabled the Recycle Bin optional feature
+#
+import base64
+import optparse
+import os
+import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
+import samba
+from samba import getopt as options, Ldb
+from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError
+import sys
+import ldb
+
+parser = optparse.OptionParser("enablerecyclebin <URL>")
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+credopts = options.CredentialsOptions(parser)
+parser.add_option_group(credopts)
+parser.add_option_group(options.VersionOptions(parser))
+
+opts, args = parser.parse_args()
+opts.dump_all = True
+
+if len(args) != 1:
+ parser.print_usage()
+ sys.exit(1)
+
+url = args[0]
+
+lp_ctx = sambaopts.get_loadparm()
+
+creds = credopts.get_credentials(lp_ctx)
+sam_ldb = Ldb(url, credentials=creds, lp=lp_ctx)
+
+# get the rootDSE
+res = sam_ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
+rootDse = res[0]
+
+configbase=rootDse["configurationNamingContext"]
+
+# enable the feature
+msg = ldb.Message()
+msg.dn = ldb.Dn(sam_ldb, "")
+msg["enableOptionalFeature"] = ldb.MessageElement(
+ "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a",
+ ldb.FLAG_MOD_ADD, "enableOptionalFeature")
+res = sam_ldb.modify(msg)
+
+print "Recycle Bin feature enabled"