Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


home directory permissions script folder exception

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2831
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> home directory permissions script folder exception
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 home directory permissions script folder exception - 4/28/2005 6:50:26 AM   
  neocipher

 

Posts: 4
Score: 0
Joined: 4/28/2005
From:
Status: offline
I've found a script that changes permissions based on the directory name. Currently it asks for the location of the home directories and also allow you to select a specific folder or prefix of folders to run the script upon. I need a way to keep the script from running on certain folders, kind of an exection either specified by a prompt or manually placed in the file to keep the script from bothering with certain directories.


      
 
 
Post #: 1
 
 Re: home directory permissions script folder exception - 4/28/2005 1:23:21 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
If you can tell me EXACTLY what permission do you want to change and for what resource (files, directories and/or sub-directories), I might be more of help. and If you can give examples, that will be good too (eg: c:\folder, everyone:R administrators:F/c)

(in reply to neocipher)
 
 
Post #: 2
 
 Re: home directory permissions script folder exception - 4/29/2005 2:16:04 AM   
  neocipher

 

Posts: 4
Score: 0
Joined: 4/28/2005
From:
Status: offline
Well currently the script parses the name of a folder and add's user permissions according to the folder name and administrator permissions.


      
This prompts the user for stuff they want to change. I need to be able to exclude certain folders not specify which one's I need to change.

(in reply to neocipher)
 
 
Post #: 3
 
 Re: home directory permissions script folder exception - 4/30/2005 7:59:35 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I believe you can do it without this script. However, I need to know EXACTLY what is changed (what was the permission before and what is the permission after) for an object. As far as I can see, it will change the ACL for a directory to allow local admins F/C, adds a user with Modify permission and turns of inheritance for the folder, and process all files/sub-directories within the folder.

Do you want to exclude one or multiple folders ? and how do you intend to specify the filtering "string" ? (eg: any folders that start with A, or the complete folder name such as "AppFolder")

(in reply to neocipher)
 
 
Post #: 4
 
 Re: home directory permissions script folder exception - 5/2/2005 12:50:54 AM   
  neocipher

 

Posts: 4
Score: 0
Joined: 4/28/2005
From:
Status: offline
You are correct about the permissions. It removes any previously existing permissions and adds the administrator and the user according to the folder name.

I would like to exclude directories based on a list of folder names. A prompt would also work but it would need to prompt multiple time so it might be easier to just write them out.

(in reply to neocipher)
 
 
Post #: 5
 
 Re: home directory permissions script folder exception - 5/3/2005 8:31:00 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I have a script that does this already.

I search folders that are named after user accounts, then a match the folder names to user names, move the folders to a new server and ACL them with MS' SubInACL tool. I also supply a security group to the script so I can pick and choose what users are to be moved.

If this doesn't help, I also have a script to read an Excel spreadsheet for user names and copy folders and ACL them. That particular script will allow you to move users based on their first initial.

Any way, here is the first one I talked about:


Start = Now

' **************************************
' * Prompt user for Group to search in *
' **************************************
strGroup = InputBox("Please enter the Group to search through.", "Active Directory Group Search")
'strGroup = "Ctxusr Midd01fs"

Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("\\DOMAIN-share\users\TimeReport-" & strGroup & ".log", ForWriting)

' *********************************
' * Error handling for user input *
' *********************************
Const TIMEOUT = 10
Const POPUP_TITLE = "Input Error"

Set objScript = Wscript.CreateObject("Wscript.Shell")

If strGroup = "" Then
iRetVal = objScript.Popup( "You must enter a Group name to search through." & _
vbCrLf & "Would you like to enter it now?",TIMEOUT,POPUP_TITLE,vbQuestion + vbYesNo)
End If

Select Case iRetVal
Case vbYes
strGroup = InputBox("Please enter the Group you wish to search through.", "Active Directory Group Search")
Case vbNo
Wscript.Quit
Case -1
MsgBox "** POPUP TIMED OUT **" & vbCrLf & vbCrLf & "No files have been copied.",, "Notification Message"
wscript.Quit
End Select

' ***************
' * Script Main *
' ***************
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objGroup = GetObject _
("LDAP://CN=" & strGroup & ",OU=General,OU=Security Groups,DC=DOMAIN,DC=com")
objGroup.GetInfo

' Retrieves members of specified Group
arrMember = objGroup.GetEx("member")

' Defines the different OU's that contain user accounts
Set objOU = GetObject("LDAP://OU=Users,OU=All Users,DC=DOMAIN,DC=com")
objOU.GetInfo
Set objOU1 = GetObject("LDAP://OU=Admins,OU=All Users,DC=DOMAIN,DC=com")
objOU1.GetInfo
Set objOU2 = GetObject("LDAP://OU=Executives,OU=All Users,DC=DOMAIN,DC=com")
objOU2.GetInfo
Set objOU3 = GetObject("LDAP://OU=Emax Recipients,OU=Users,OU=All Users,DC=DOMAIN,DC=com")
objOU3.GetInfo
Set objOU4 = GetObject("LDAP://OU=MLN Recipients,OU=Users,OU=All Users,DC=DOMAIN,DC=com")
objOU4.GetInfo

arrLDAP = Array(objOU, objOU1, objOU2, objOU3, objOU4)

' Defines the paths to user folders
objPath = "\\midd01fs\vol3\Oakbrook\Users\"
objPath1 = "\\midd01fs\vol3\Atlanta\Users\"
objPath2 = "\\midd01fs\vol3\Horsham\Users\"
objPath3 = "\\midd01fs\vol1\Users\"
objPath4 = "\\Midd01bs\vol1\Delaware\Users\"
objPath5 = "\\Midd01bs\vol1\Phoenix\Users\"
objPath6 = "\\Midd01bs\vol1\Retail\Users\"
objPath7 = "\\Midd01bs\vol1\Referral\Users\"

arrPath = Array(objPath, objPath1, objPath2, objPath3, objPath4, objPath5, objPath6, objPath7)

' Loops from 0 to as many item as there are in the Array
For i = 0 To UBound(arrLDAP)

For Each objItem In arrLDAP(i)

objMembers = LCase(Join(arrMember))
strName = LCase(objItem.DistinguishedName)

If InStr(objMembers, strName) Then

' Copying files and folders
For Each Path In arrPath
strFolder = Path & objItem.SamAccountName
strDest = "\\DOMAIN-share\users\" & objItem.SamAccountName
If objFSO.FolderExists(strFolder) Then
' When disabling display of "Percent Complete" with switch, Robocopy hangs on large files.
objScript.Run ("robocopy.exe " & strFolder & " " _
& strDest & " /MIR /R:5 /NC /LOG+:CopyReport.log /TEE"), 1, True
objFile.WriteLine "Copied: " & objItem.SamAccountName
End If
Next

' Setting permissions on only the folders copied in this batch
If objFSO.FolderExists(strDest) Then
objScript.Exec ("SubInACL.exe /subdirectories " & strDest _
& " /grant=DOMAIN\" & objItem.SamAccountName & "=C")
End If

End If

Next

Next

If DateDiff("n", Start, Now) = 0 Then
objFile.WriteBlankLines 1
objFile.WriteLine "The script took less than 0 minutes to complete." & vbCrLf
objFile.WriteLine "There may have been a problem or the group that was entered does not exist."
objFile.Close
Else
objFile.WriteBlankLines 1
objFile.WriteLine "======================"
objFile.WriteLine "======================"
objFile.Write DateDiff("n", Start, Now) & " minutes to complete"
objFile.Close
End If

< Message edited by esnmb -- 1/2/2007 5:38:05 AM >

(in reply to neocipher)
 
 
Post #: 6
 
 Re: home directory permissions script folder exception - 5/3/2005 8:32:26 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Here is the other one to get user/folder names from an Excel Spreadsheet and move and ACL them.



' ********************************************************
' * Prompt to get the first initial of the users to copy *
' ********************************************************
strInitial = InputBox(vbCrLf & vbCrLf & vbCrLf & _
"Please enter the first initial of the users you wish to copy.","Folder Copy")

'strInitial = "a"

If strInitial = "" Then

Wscript.Echo "You must enter an initial to begin the copy." & vbCrLf & "Script is exiting."
Wscript.Quit

End If

' *********************
' * Script start time *
' *********************
Start = Now

' ***************
' * Script Main *
' ***************
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("\\DOMAIN-share\TestShare\TimeReport_Midd01fs - " & Left(UCase(strInitial), 1) _
& ".log", ForWriting)
Set objScript = Wscript.CreateObject("Wscript.Shell")

objPath = "\\midd01fs\vol1\Users\"

Set objExcel = CreateObject("Excel.Application")
strPathExcel = "c:\temp\midd01fsusers.xls"
objExcel.Workbooks.Open strPathExcel

NumofSheet = objExcel.ActiveWorkbook.Sheets.Count

For s = 1 To NumofSheet
objExcel.ActiveWorkbook.Sheets(s).Select
Set objSheet = objExcel.ActiveWorkbook.Activesheet

For intRow = 1 To objSheet.UsedRange.Rows.Count
strData= LCase(Trim(objSheet.Cells(intRow,1).Value))

If Left(strData, 1) = Left(LCase(strInitial), 1) Then

strFolder = objPath & strData
strDest = "\\DOMAIN-share\TestShare\" & strData

If objFSO.FolderExists(strFolder) Then
objScript.Run ("robocopy.exe " & strFolder & " " _
& strDest & " /Create /E /R:5 /NC /LOG+:CopyReport.log /TEE"), 1, True
objFile.WriteLine "Copied: " & strData
End If

If objFSO.FolderExists(strDest) Then
objScript.Exec ("SubInACL.exe /subdirectories " & strDest _
& " /grant=DOMAIN\" & strData & "=C")
End If

End If

Next

Next

' *************************************************************************
' * Updates log with time to complete as well as a form of error handling *
' *************************************************************************
If DateDiff("n", Start, Now) = 0 Then
objFile.WriteBlankLines 1
objFile.WriteLine "The script took less than 0 minutes to complete." & vbCrLf
objFile.WriteLine "There may have been a problem or the initial that was entered, " & Chr(34) _
& strInitial & Chr(34) & " does not exists."
objFile.Close
Else
objFile.WriteBlankLines 1
objFile.WriteLine "======================"
objFile.WriteLine "======================"
objFile.Write DateDiff("n", Start, Now) & " minute(s) to complete"
objFile.Close
End If

objExcel.Quit

< Message edited by esnmb -- 1/2/2007 5:38:19 AM >

(in reply to neocipher)
 
 
Post #: 7
 
 Re: home directory permissions script folder exception - 5/4/2005 2:08:23 AM   
  neocipher

 

Posts: 4
Score: 0
Joined: 4/28/2005
From:
Status: offline
I like the first script that you have posted. But I don't need all of the copying functions. Just lookup the OU check that the users exists and then assign right's to the folder. Problem is that there is still the same issue with the first script I was using. I need a way for the script to skip certain users that I specify that are in the same OU and their home directory is in the same area that the rest of the users' folder's reside in or a better method would be when listing the directory don't include folders that have a folder size greater then some amount.

Here's a little bit of code that I think might work the first script I posted.


      

but i'm not sure how to incorporate to skip a user's folder if the size is greater then some number

(in reply to neocipher)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> home directory permissions script folder exception Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts