[green]
'==========================================================================
'
' NAME: AssignRights2HomeDirectories.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYRIGHT (c) 2006 All Rights Reserved
' DATE : 6/10/2006
'
' COMMENT: Assigns NTFS rights to a folder when username
' matches the folder name.
'
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS
' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
' OF THIS CODE OR INFORMATION.
'
' This script and many more can be found in the Admin Script Pack
' by The Spider's Parlor [URL unfurl="true"]http://www.thespidersparlor.com/vbscript[/URL]
'==========================================================================
'Where are the user directories? Local path on the server.
'End with a backslash.[/green]
Path = [red]"E:\UserShares\"[/red][green]
'Where can I find XCACLS.EXE? Keep a space at the end of this string.[/green]
sXpath = [red]"\\server\util\xcacls.exe "[/red]
Dim fso,WSHShell,oFolder,oFile,oSubFolder,Partition, Partitions
Set fso = CreateObject("Scripting.FileSystemObject")
Set WSHShell= CreateObject("Wscript.Shell")
On Error Resume Next[green]
'Find the domain name[/green]
Set Partitions = GetObject("LDAP://CN=Partitions,CN=Configuration," & _
GetObject("LDAP://RootDSE").Get("DefaultNamingContext"))
For Each Partition In Partitions
DomainString = Partition.Get("nETBIOSName") & "\"
If Err.Number = 0 then Exit For
Next
Set Partitions = Nothing
[green]
'Now bind to the parent folder and then get the sub folders[/green]
Set oFolder = fso.GetFolder(Path)
Set colSubfolders = oFolder.Subfolders
For Each oSubfolder in colSubfolders
UserName = oSubFolder.Name[green]
'Set the permissions.
'XCACLS will wipe out previous permissions
'so be sure to set all that you want.[/green]
WSHShell.Run "cmd /c " & sXpath & Path & UserName & " /E /G " & DomainString & "Network System:F"
WSHShell.Run "cmd /c " & sXpath & Path & UserName & " /E /G " & DomainString & "Administrator:F"[green]
'Give the user Read, Change, take Ownership,
'eXecute, rEad (special access), Write and Delete rights[/green]
WSHShell.Run "cmd /c " & sXpath & Path & UserName & " /E /G " & DomainString & UserName & ":RCOXEWD"
Next
Set oSubFolder = Nothing
Set oFolder = Nothing
Set fso = Nothing