Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS change file permission of users in a domain

Status
Not open for further replies.

rmanalo

Programmer
May 22, 2019
1
0
0
PH
I have zero knowledge on how to make a vbscript. I found the code below from here.
' 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

'

objRecordSet.MoveNext


Loop


' Clean up

'

objRecordSet.Close

Set objRecordSet = Nothing

Set objCommand = Nothing

objConnection.Close

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top