Author: brad
Date: 2006-05-30 13:19:09 +0000 (Tue, 30 May 2006)
New Revision: 15954

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15954

Log:
A script to remove a named file share and directory, and another to remove an 
ADS user account.
These scripts are intended to facilitate cleaning up after a RAW-QFILEINFO 
smbtorture test run.


Added:
   branches/SOC/bnh/ads_deluser.vbs
   branches/SOC/bnh/smb_delshare.vbs


Changeset:
Added: branches/SOC/bnh/ads_deluser.vbs
===================================================================
--- branches/SOC/bnh/ads_deluser.vbs    2006-05-30 05:57:43 UTC (rev 15953)
+++ branches/SOC/bnh/ads_deluser.vbs    2006-05-30 13:19:09 UTC (rev 15954)
@@ -0,0 +1,20 @@
+Set stdout = WScript.StdOut
+Set stdin = WScript.StdIn
+
+' Check passed in parameters.
+Set argv = WScript.Arguments.Named
+
+If Not argv.Exists("username") Then
+       stdout.Write "You must specify a username (/username:<username>)"
+       WScript.Quit
+Else        
+       username = argv.Item("username")
+End If
+
+' Bind to the DC.
+Set rootDSE = GetObject("LDAP://rootDSE")
+Set container = GetObject("LDAP://CN=Users," & _
+       rootDSE.Get("defaultNamingContext"))
+
+' Delete the user account.
+container.Delete "User", "CN=" & username

Added: branches/SOC/bnh/smb_delshare.vbs
===================================================================
--- branches/SOC/bnh/smb_delshare.vbs   2006-05-30 05:57:43 UTC (rev 15953)
+++ branches/SOC/bnh/smb_delshare.vbs   2006-05-30 13:19:09 UTC (rev 15954)
@@ -0,0 +1,36 @@
+Set stdout = WScript.StdOut
+Set stdin = WScript.StdIn
+
+' Check passed in parameters.
+Set argv = WScript.Arguments.Named
+
+if WScript.Arguments.Count = 2 Then
+       sharename = argv.Item("sharename")
+       pathname = argv.Item("sharepath")
+
+       If Not argv.Exists("sharename") Then
+               stdout.Write "You must specify a share name (/sharename:<share 
name>)"
+               WScript.Quit
+       ElseIf Not argv.Exists("sharepath") Then
+               stdout.Write "You must specify a share path (/sharepath:<share 
path>)"
+               WScript.Quit
+       End If
+Else
+       stdout.Write "Usage: cscript smb_addshare.vbs /sharename:<share name> 
/sharepath:<share path>"
+       WScript.Quit
+End If
+
+' Check if the directory exists, and exit if it does not.
+Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
+if Not fileSystemObject.FolderExists(pathname) Then
+       stdout.Write "Error: Directory " & pathname & " does not exist. 
Exiting." 
+       WScript.Quit
+End If
+
+' Delete the share.
+Set shell = WScript.CreateObject("WScript.Shell")
+netsharecmd = "net share " & sharename & " /DELETE"
+shell.Run netsharecmd, 7, True
+
+' Delete the directory.
+fileSystemObject.DeleteFolder(pathname)

Reply via email to