域内计算机和用户获取实现vbs代码
更新时间:2010年11月28日 20:17:33 作者:
域内计算机和用户获取(转自冰点极限-赤龙),学习vbs的朋友可以参考下。
显示当前域内所有计算机名称及数目
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = ObjRootDSE.Get("defaultNamingContext")
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 * FROM 'LDAP://" & strDomain & "' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("ADsPath").Value
objRecordSet.MoveNext
Loop
Wscript.Echo ""
Wscript.Echo "Total Computer: "&objRecordSet.RecordCount
显示当前域内所有用户名称及数目
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = ObjRootDSE.Get("defaultNamingContext")
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 * FROM 'LDAP://" & strDomain & "' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("ADsPath").Value
objRecordSet.MoveNext
Loop
Wscript.Echo ""
Wscript.Echo "Total User: "&objRecordSet.RecordCount
复制代码 代码如下:
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = ObjRootDSE.Get("defaultNamingContext")
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 * FROM 'LDAP://" & strDomain & "' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("ADsPath").Value
objRecordSet.MoveNext
Loop
Wscript.Echo ""
Wscript.Echo "Total Computer: "&objRecordSet.RecordCount
显示当前域内所有用户名称及数目
复制代码 代码如下:
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = ObjRootDSE.Get("defaultNamingContext")
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 * FROM 'LDAP://" & strDomain & "' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("ADsPath").Value
objRecordSet.MoveNext
Loop
Wscript.Echo ""
Wscript.Echo "Total User: "&objRecordSet.RecordCount
相关文章
vbs ShellExecute运行外部程序时如何判断外部程序执行成功与否
这篇文章主要介绍了vbs ShellExecute运行外部程序时如何判断外部程序执行成功与否,需要的朋友可以参考下2023-06-06使用 Iisext.vbs 删除 Web 服务扩展文件的方法
这篇文章主要介绍了如何使用 iisext.vbs 从本地或远程计算机上删除 Web 服务扩展文件,需要的朋友可以参考下2014-07-07vbs sendKeys Virtual-Key Codes 十六进制符号
下表显示了十六进制符号常量名,,由系统所使用的虚拟键码和鼠标或键盘等值。这些代码数字顺序列出。2011-02-02最新恶意复制型病毒autorun.inf,stNP.VBS,NP.VBS代码简单解析和解决方法
最新恶意复制型病毒autorun.inf,stNP.VBS,NP.VBS代码简单解析和解决方法...2007-05-05vbs中实现启动两个应用程序,一直等到其中一个程序结束,然后关闭另一个?
vbs中实现启动两个应用程序,一直等到其中一个程序结束,然后关闭另一个?...2007-04-04VBS教程:方法-GetAbsolutePathName 方法
VBS教程:方法-GetAbsolutePathName 方法...2006-11-11
最新评论