Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Script to set user permissions

Reply
Thread Tools Display Modes

Script to set user permissions

 
 
NZSchoolTech
Guest
Posts: n/a

 
      01-30-2009

I've had to set up a new server after a disk crash. We had backups of all of
the home directories of our users, but we lost all of the ACLs because these
were not backed up in any form.

The situation is that I now have 250 home directories all named by a user,
and none of those users can access their own directory unless I set their
permissions on each one.

Since I don't want to have to do 250 permissions entries by hand, I need a
script that can do it for me. The following is what is relevant to the
script:

1. We can easily put all of the affected accounts into a special OU just for
this script, so that the script doesn't need to have any filtering in it for
what users it is working on.
2. The user's home directory is stored in their ADUC account as the Home
Folder, whereby we have configured for drive H to be connected to this
folder. It should therefore be possible to read this attribute to find the
path that the ACE needs to be set on.
3. The permissions need to be Modify, and need to be made inheritable, and
to propagate automatically to existing files.

I think that covers enough info to be able to put a script together. I
haven't done any scripting for years, although I'm an experienced
programmer, and have mislaid the original scripts I wrote way back when we
needed to create many of those user accounts automatically from a CSV file.

Therefore any assistance this group can give in the form of a script outline
would be most appreciated.

TIA

--


 
Reply With Quote
 
 
 
 
Al Dunbar
Guest
Posts: n/a

 
      02-04-2009


"NZSchoolTech" <> wrote in message
news:...
> I've had to set up a new server after a disk crash. We had backups of all
> of the home directories of our users, but we lost all of the ACLs because
> these were not backed up in any form.
>
> The situation is that I now have 250 home directories all named by a user,
> and none of those users can access their own directory unless I set their
> permissions on each one.
>
> Since I don't want to have to do 250 permissions entries by hand, I need a
> script that can do it for me. The following is what is relevant to the
> script:
>
> 1. We can easily put all of the affected accounts into a special OU just
> for this script, so that the script doesn't need to have any filtering in
> it for what users it is working on.
> 2. The user's home directory is stored in their ADUC account as the Home
> Folder, whereby we have configured for drive H to be connected to this
> folder. It should therefore be possible to read this attribute to find the
> path that the ACE needs to be set on.
> 3. The permissions need to be Modify, and need to be made inheritable, and
> to propagate automatically to existing files.
>
> I think that covers enough info to be able to put a script together. I
> haven't done any scripting for years, although I'm an experienced
> programmer, and have mislaid the original scripts I wrote way back when we
> needed to create many of those user accounts automatically from a CSV
> file.
>
> Therefore any assistance this group can give in the form of a script
> outline would be most appreciated.


If the name of the folder is identical to the sAMAccountName of the user
account, there is a simpler method. First, apply the standard admin
permissions to the folder containing the user home folders, and force this
to be replicated to all contained folders. Then run a batch script such as
this:

for /d %%D in ("D:\users\*.*") do (
echo/cacls "%%~dpnxF" /g %%~nF:C /t
)

if you are happy with the cacls commands displayed, change "echo/cacls" to
"cacls".

/Al


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      02-04-2009

"acray" <> wrote in message
news:...
>
> fyi, cacls does not correctly traverse sub directories to apply
> permissions, at least not in all situations. So it should not be relied
> upon to fully set the permissions on all the files.


Interesting. Can you give an example or quote an authoritative source for
this claim?


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      02-04-2009

"acray" <> wrote in message
news:...
>
> fyi, cacls does not correctly traverse sub directories to apply
> permissions, at least not in all situations. So it should not be relied
> upon to fully set the permissions on all the files.


That is why I suggested the first step of setting background admin
permissions and replicating them from windows explorer - in the hope that
this would configure subfolders to inherit all permissions.

/Al

> However, I believe a For loop similar to what Al Dunbar provided could
> be used to call SetACL, simplifying my vbscript approach.
>
> Remember, if my VBscript was retrofitted to use SetACL, the first pass
> (first occurrence of WScript.Run) would not be needed at all.
>
>
> --
> acray
> ------------------------------------------------------------------------
> acray's Profile: http://forums.techarena.in/members/acray.htm
> View this thread: http://forums.techarena.in/server-scripting/1112376.htm
>
> http://forums.techarena.in
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Req: Script to create directory for users listed in a file and apply permissions for each user Jeffery Hicks Scripting 0 02-12-2007 08:54 PM
Script How? Check If Current User Has Read Permissions To A Share? Hardeep Rakhra Windows Server 1 05-24-2005 01:44 AM
Editing user permissions from a script Brian Scripting 5 03-18-2005 08:57 AM
Using a script to create user accounts via active directory and also create folders/permissions Writing Implement Scripting 1 09-08-2003 11:12 PM
Login as user but run login script portions with Domain Admins Permissions Steven Sutherland Scripting 1 07-15-2003 02:26 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59