Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VBS change file permission of users in a domain

VBS change file permission of users in a domain

VBS change file permission of users in a domain

I have zero knowledge on how to make a vbscript. I found the code below from here. https://blogs.msdn.microsoft.com/alejacma/2008/04/...

' Get OU


strOU = "OU=Users,DC=DOMAIN.BIZ,DC=com"

' Create connection to AD


Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open "Provider=ADsDSOObject;"

' Create command


Set objCommand = CreateObject("ADODB.Command")

objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

' Execute command to get all users in OU


objCommand.CommandText = _
"<LDAP://" & strOU & ">;" _
& "(&(objectClass=user)(objectCategory=person));" _
& "adspath,distinguishedname,sAMAccountName;subtree"

Set objRecordSet = objCommand.Execute

' Show info for each user in OU


Do Until objRecordSet.EOF

' Show required info for a user


WScript.Echo objRecordSet.Fields("adspath").Value

WScript.Echo objRecordSet.Fields("distinguishedname").Value

WScript.Echo objRecordSet.Fields("sAMAccountName").Value

' Move to the next user




' Clean up



Set objRecordSet = Nothing

Set objCommand = Nothing


Set objConnection = Nothing

It's not what I really wanted but at least it's something I could try to work on. I'm running it on a client pc using Windows 7.

I fixed some minor stuff like the multi line. Now it always throw an error on Set objRecordSet = objCommand.Execute, saying The specified domain either does not exist or could not be contacted. I'm not using an admin account.
From the comments on the page, it seemed to work for them.
Replies continue below

Recommended for you

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close