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!

Admin Script

Status
Not open for further replies.

coch

Technical User
Jul 4, 2002
106
0
0
GB
Hi I have the following script and I would like to amend it so that it looks at the lastlogon attribute of each user on each domain controller and then moves the user dependent on the age of the lastlogon attribute as this isn't replictaed to each DC. The script currently only queries the DC that the script is run on. So do I need IF and ELSE statements in here?

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
"SELECT ADsPath FROM 'LDAP://OU=People,dc=test,dc=co,dc=uk' WHERE objectCategory='user' " & _
"AND lastlogon <> '*'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strADsPath = objRecordSet.Fields("ADsPath").Value
Set objOU = GetObject("LDAP://OU=Logons,DC=test,DC=co,DC=uk")
intReturn = objOU.MoveHere(strADsPath, vbNullString)
objRecordSet.MoveNext
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top