svn commit: samba r15948 - in branches/SOC/bnh: .

brad at samba.org brad at samba.org
Tue May 30 04:27:08 GMT 2006


Author: brad
Date: 2006-05-30 04:27:07 +0000 (Tue, 30 May 2006)
New Revision: 15948

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

Log:
Two .vbs scripts which create a directory and share it for a specified user, and another to create that user in Active Directory.
These scripts are intended to facilitate setting up the Windows server side of the RAW-QFILEINFO smbtorture test.


Added:
   branches/SOC/bnh/ads_adduser.vbs
   branches/SOC/bnh/smb_addshare.vbs


Changeset:
Added: branches/SOC/bnh/ads_adduser.vbs
===================================================================
--- branches/SOC/bnh/ads_adduser.vbs	2006-05-30 03:57:43 UTC (rev 15947)
+++ branches/SOC/bnh/ads_adduser.vbs	2006-05-30 04:27:07 UTC (rev 15948)
@@ -0,0 +1,46 @@
+Const ADS_UF_ACCOUNTDISABLE=2
+
+Set stdout = WScript.StdOut
+Set stdin = WScript.StdIn
+
+'Check passed in parameters.
+Set argv = WScript.Arguments.Named
+
+if WScript.Arguments.Count = 2 Then
+	username = argv.Item("username")
+	password = argv.Item("password")
+	
+	If Not argv.Exists("username") Then
+	        stdout.Write "You must specify a username (/username:<username>)"
+	        WScript.Quit
+	ElseIf Not argv.Exists("password") Then
+	        stdout.Write "You must specify a password (/password:<password>)"
+	        WScript.Quit
+	End If
+Else
+	stdout.Write "Usage: cscript ads_adduser.vbs /username:<username> /password:<password>"
+	WScript.Quit
+End If
+
+'Bind to the DC.
+Set rootDSE = GetObject("LDAP://rootDSE")
+Set container = GetObject("LDAP://CN=Users," & _
+	rootDSE.Get("defaultNamingContext"))
+
+'Create the user account.
+Set userAccount = container.Create("User", "CN=" & username)
+userAccount.Put "sAMAccountName", username
+userAccount.SetInfo
+
+'Get user account info.
+Set userAccount = GetObject _
+	("LDAP://CN=" & username & ",CN=Users," & _ 
+	rootDSE.Get("defaultNamingContext"))
+
+'Set the password and enable the account.
+userAccount.SetPassword password
+userAccountControl = userAccount.Get("userAccountControl")
+userAccount.Put "userAccountControl", _
+	userAccountControl XOR ADS_UF_ACCOUNTDISABLE
+userAccount.SetInfo
+

Added: branches/SOC/bnh/smb_addshare.vbs
===================================================================
--- branches/SOC/bnh/smb_addshare.vbs	2006-05-30 03:57:43 UTC (rev 15947)
+++ branches/SOC/bnh/smb_addshare.vbs	2006-05-30 04:27:07 UTC (rev 15948)
@@ -0,0 +1,48 @@
+
+Set stdout = WScript.StdOut
+Set stdin = WScript.StdIn
+
+' Check passed in parameters.
+Set argv = WScript.Arguments.Named
+
+if WScript.Arguments.Count = 3 Then
+	username = argv.Item("username")
+	sharename = argv.Item("sharename")
+	pathname = argv.Item("sharepath")
+	
+	If Not argv.Exists("username") Then
+		stdout.Write "You must specify a username (/username:<username>)"
+		WScript.Quit
+	ElseIf 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 /username:<username> /sharename:<share name> /sharepath:<share path>"
+	WScript.Quit
+End If
+
+' Check if the directory exists, and exit if it does.
+Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
+if fileSystemObject.FolderExists(pathname) Then
+	stdout.Write "Error: Directory " & pathname & " exists. Exiting." 
+	WScript.Quit
+End If
+
+' Create the directory to share.
+Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
+Set folder = fileSystemObject.CreateFolder(pathname)
+
+' Share the directory.
+Set shell = WScript.CreateObject("WScript.Shell")
+netsharecmd = "net share " & sharename & "=" & pathname & " /GRANT:" _
+	 & username & ",FULL"
+shell.Run netsharecmd, 7, True
+
+' Remove share.
+' Delete shared directory.
+'fileSystemObject.DeleteFolder(pathname)
+



More information about the samba-cvs mailing list