Re: Enumerate enabled computer accounts
Hello,
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
' Get the userAccountControl value. This lets us, among other things,
' determine if the account is disabled.
intUAC = objRecordset.Fields("userAccountControl")
' Process user if account is not disabled.
If (NOT intUAC AND ADS_UF_ACCOUNTDISABLE) Then
Wscript.Echo objRecordSet.Fields("Name").Value
strAdObj = strAdObj & objRecordSet.Fields("Name").Value & vbCrLf
End If
objRecordSet.MoveNext
Loop
Hi,
I have a script to enumerate active directory computer accounts. How
do I modify this so that it ignores "disabled" computer accounts?
Any tips would be appreciated.
-------
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.Properties("Cache Results") = False
objCommand.Properties("Timeout") = 30
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://DC=domainname, DC=com' " & _
"WHERE objectCategory='computer' " & _
"AND name='*' " & _
"ORDER BY name"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name").Value
strAdObj = strAdObj & objRecordSet.Fields("Name").Value & vbCrLf
objRecordSet.MoveNext
Loop
.
Relevant Pages
- Re: Does anyone know how to fix this??
... > Inside the Active Directory Users and Computers in the folder of SYSTEM I ... Give the site's SMS Service account full control rights to the ... MP encountered an error when connecting to SQL Server. ... (microsoft.public.sms.setup) - Re: Cross-Domain question (Parent - Child)
... computer accounts unless logged in directly to the server? ... different DC so the DC you are looking at doesn't get the audit entries. ... Author of O'Reilly Active Directory Third Edition ... User Account Created: ... (microsoft.public.win2000.active_directory) - Re: Domain troubles
... Workgroup administrative environment and the machine account in Active ... Another possiblity is that the Active Directory DNS cannot resolve the ... For example if you built a network segment and abitrarily choose ... (microsoft.public.windows.server.general) - Re: NTDS Replication Event ID 1083/1955 and account lockouts
... Active Directory could not update the following object with changes received ... from the domain controller at the following network address because Active ... Not sure if the event is ocurring after the account has been locked or the ... (microsoft.public.windows.server.active_directory) - Re: Does anyone know how to fix this??
... Inside the Active Directory Users and Computers in the folder of SYSTEM I ... > Basically sms secondary site reports me 3 kind of error.... ... > account may not have full control rights for the "System Management" ... > "System Management" container, and all child objects in Active Directory. ... (microsoft.public.sms.setup) |
|