'/*============================================================
'/*此类是转贴于CoCoon.网址: http://www.ccopus.com/LeadBBS/Board/
'/*此类可以获取操作局域网的相关信息
'/*============================================================
Class CC_Net_Tools
'1. Domain Computers
'1.1 Display all domains in the server NameSpace
Sub PullAllDomains
Dim objNameSpace
Dim Domain
Set objNameSpace = GetObject("WinNT:")
For Each Domain in objNamespace
Response.Write "<span style='width:200px'>" & Domain.Name & "</span>"
Next
End sub
'1.2 Display all Connected Computers on the Primary Domain Controller
Sub PullAllComputers(strDomain)
Dim PrimDomainContr
Set PrimDomainContr = getobject("WinNT://" & strDomain)
PrimDomainContr.filter = Array("Computer")
For each Computer in PrimDomainContr
Response.Write "<span style='width:200px'>" & Computer.Name & "</span>"
Next
End sub
'1.3 Remove a Connected Computer from a Primary Domain Controller
Sub DelComputerFromPDC(strDomain,strDelComputer)
Dim PrimDomainContr
Set PrimDomainContr = getobject("WinNT://" & strDomain)
Call PrimDomainContr.Delete("Computer", strDelComputer)
End Sub
'2. Computer Users
'2.1 Display all user accounts
sub PullAllUsers(strDomain)
Dim Computer
Dim User
Set Computer = GetObject("WinNT://" & strDomain)
Computer.Filter = Array("User")
For Each User in Computer
Response.Write "<span style='width:200px'>" & User.Name & "</span>"
Next
End Sub
'2.2 Display Minimum Password Age
Sub DispMinPassAge(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write ((Computer.MinPasswordAge) / 86400)
End Sub
'2.3 Display Minimum Password Length
Sub DispMinPassLength(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.MinPasswordLength
End Sub
'2.4 Display Password History Length
Sub DispPassHisLength(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.PasswordHistoryLength
End Sub
'2.5 Display Auto Unlock Interval
Sub DispAutoUnlock(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.AutoUnlockInterval
End Sub
'2.6 Display Lockout Observation Interval
Sub DispAutoUnlockObservation(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.LockOutObservationInterval
End Sub
'3. Computer Groups
'3.1 Display All Groups
Sub PullAllGroups(strDomain)
Dim Computer
Dim Group
Set Computer = GetObject("WinNT://" & strDomain)
Computer.Filter = Array("Group")
For Each Group in Computer
Response.Write "<span style='width:200px'>" & Group.Name & "</span>"
Next
End Sub
'4. User Specific Fields
'4.1 Display User Fullname
Sub PullUserFullname(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Fullname
End sub
'4.2 Display User Description
Sub PullUserDescription(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Description
End sub
'4.3 Display User Must Change Password Flag
Sub PullUserMustChangePass(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Get("PasswordExpired") '// 1 Means the Password Expired
End Sub
'4.4 Display User Can't Change Password Flag
Sub PullUserCannotChangePass(strDomain,strUser)
Dim User
Dim Flags
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Flags = User.Get("UserFlags")
Response.Write Flags And &H00040 '// 0 Means that user CAN change pass
End sub
'4.5 Display Password Never Expires Flag
Sub PullPassNeverExpires(strDomain,strUser)
Dim User
Dim Flags
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Flags = User.Get("UserFlags")
Response.Write Flags And &H10000 '// 0 Means that Password DOES expire
End sub
'4.6 Display User Password Minimum Length
Sub PullUserPassMinLength(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.PasswordMinimumLength
End Sub
'4.7 Display User Password Required
Sub PullUserPassRequired(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.PasswordRequired
End Sub
'4.8 Display User Account Disabled Flag
Sub PullUserAccountDisabled(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.AccountDisabled
End Sub
'4.9 Display User Account Lockout Flag
Sub PullUserAccountLockout(strDomain,strUser)
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.IsAccountLocked
End Sub
'4.10 Display User Account Type
Sub PullUserAccountType(strDomain,strUser)
Dim User
Dim Flags
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Flags = User.Get("UserFlags")
Response.Write Flags And &H100'// 0 Means that account is GLOBAL
End sub
'4.11 Display User Profile Path
Sub PullUserProfilePath(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Profile
End Sub
'4.12 Display User Login Script
Sub PullUserLoginScript(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LoginScript
End Sub
'4.13 Display User Home Directory Path
Sub PullUserHomeDirPath(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.HomeDirectory
End Sub
'4.14 Display User Home Directory Mapping
Sub PullUserHomeDirDrive(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Get("HomeDirDrive")
End Sub
'4.15 Display User Account Expiration Date (NT 4.0 only)
Sub PullUserAccountExpireDate(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.AccountExpirationDate
End Sub
'4.16 Display User Bad Login Count (NT 4.0 only)
Sub PullUserBadLoginCount(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.BadLoginCount
End Sub
'4.17 Display User Last Login (NT 4.0 only)
Sub PullUserLastLogin(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LastLogin
End Sub
'4.18 Display User Last Logoff (NT 4.0 only)
Sub PullUserLastLogoff(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LastLogoff
End Sub
'4.19 Display User Last Logoff (NT 4.0 only)
Sub PullUserLastLogoff1(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LastLogoff
End Sub
'4.20 Display User Logon Hours Restriction(NT 4.0 only)
Sub PullUserLogonHourRestriction(strDomain,strUser)
Dim User
Dim RegTime
Dim Restrict
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
For Each RegTime In User.LoginHours
If RegTime < 255 Then Restrict = True
Next
Response.Write Restrict
End Sub
'5. Group Specific Fields
'5.1 Display All Users in a Group
Sub PullAllUserFromGroup(strDomain,strGroup)
Dim Group
Dim User
Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
For Each User in Group.Members
Response.Write "<span style='width:200px'>" & User.Name & "</span>"
Next
End Sub
'5.2 Display if a Users is listed in a Group
Sub DispUserInGroup(strDomain,strGroup,strUser)
Dim Group
Dim User
Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write Group.IsMember(User.ADsPath)
End Sub
'5.2 Display Group Description
Sub PullGroupDescription(strDomain,strGroup,strUser)
Dim Group
Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
Response.Write Group.Description
End Sub
'5.2 Display Which Group a User is Listed in
Sub DispUserInWhichGroup(strDomain,strGroup,strUser)
Dim Group
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
For Each Group in User.Groups
Response.Write Group.Name
Next
End Sub
End Class
%>
'/*此类是转贴于CoCoon.网址: http://www.ccopus.com/LeadBBS/Board/
'/*此类可以获取操作局域网的相关信息
'/*============================================================
Class CC_Net_Tools
'1. Domain Computers
'1.1 Display all domains in the server NameSpace
Sub PullAllDomains
Dim objNameSpace
Dim Domain
Set objNameSpace = GetObject("WinNT:")
For Each Domain in objNamespace
Response.Write "<span style='width:200px'>" & Domain.Name & "</span>"
Next
End sub
'1.2 Display all Connected Computers on the Primary Domain Controller
Sub PullAllComputers(strDomain)
Dim PrimDomainContr
Set PrimDomainContr = getobject("WinNT://" & strDomain)
PrimDomainContr.filter = Array("Computer")
For each Computer in PrimDomainContr
Response.Write "<span style='width:200px'>" & Computer.Name & "</span>"
Next
End sub
'1.3 Remove a Connected Computer from a Primary Domain Controller
Sub DelComputerFromPDC(strDomain,strDelComputer)
Dim PrimDomainContr
Set PrimDomainContr = getobject("WinNT://" & strDomain)
Call PrimDomainContr.Delete("Computer", strDelComputer)
End Sub
'2. Computer Users
'2.1 Display all user accounts
sub PullAllUsers(strDomain)
Dim Computer
Dim User
Set Computer = GetObject("WinNT://" & strDomain)
Computer.Filter = Array("User")
For Each User in Computer
Response.Write "<span style='width:200px'>" & User.Name & "</span>"
Next
End Sub
'2.2 Display Minimum Password Age
Sub DispMinPassAge(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write ((Computer.MinPasswordAge) / 86400)
End Sub
'2.3 Display Minimum Password Length
Sub DispMinPassLength(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.MinPasswordLength
End Sub
'2.4 Display Password History Length
Sub DispPassHisLength(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.PasswordHistoryLength
End Sub
'2.5 Display Auto Unlock Interval
Sub DispAutoUnlock(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.AutoUnlockInterval
End Sub
'2.6 Display Lockout Observation Interval
Sub DispAutoUnlockObservation(strDomain)
Dim Computer
Set Computer = GetObject("WinNT://" & strDomain)
Response.Write Computer.LockOutObservationInterval
End Sub
'3. Computer Groups
'3.1 Display All Groups
Sub PullAllGroups(strDomain)
Dim Computer
Dim Group
Set Computer = GetObject("WinNT://" & strDomain)
Computer.Filter = Array("Group")
For Each Group in Computer
Response.Write "<span style='width:200px'>" & Group.Name & "</span>"
Next
End Sub
'4. User Specific Fields
'4.1 Display User Fullname
Sub PullUserFullname(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Fullname
End sub
'4.2 Display User Description
Sub PullUserDescription(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Description
End sub
'4.3 Display User Must Change Password Flag
Sub PullUserMustChangePass(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Get("PasswordExpired") '// 1 Means the Password Expired
End Sub
'4.4 Display User Can't Change Password Flag
Sub PullUserCannotChangePass(strDomain,strUser)
Dim User
Dim Flags
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Flags = User.Get("UserFlags")
Response.Write Flags And &H00040 '// 0 Means that user CAN change pass
End sub
'4.5 Display Password Never Expires Flag
Sub PullPassNeverExpires(strDomain,strUser)
Dim User
Dim Flags
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Flags = User.Get("UserFlags")
Response.Write Flags And &H10000 '// 0 Means that Password DOES expire
End sub
'4.6 Display User Password Minimum Length
Sub PullUserPassMinLength(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.PasswordMinimumLength
End Sub
'4.7 Display User Password Required
Sub PullUserPassRequired(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.PasswordRequired
End Sub
'4.8 Display User Account Disabled Flag
Sub PullUserAccountDisabled(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.AccountDisabled
End Sub
'4.9 Display User Account Lockout Flag
Sub PullUserAccountLockout(strDomain,strUser)
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.IsAccountLocked
End Sub
'4.10 Display User Account Type
Sub PullUserAccountType(strDomain,strUser)
Dim User
Dim Flags
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Flags = User.Get("UserFlags")
Response.Write Flags And &H100'// 0 Means that account is GLOBAL
End sub
'4.11 Display User Profile Path
Sub PullUserProfilePath(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Profile
End Sub
'4.12 Display User Login Script
Sub PullUserLoginScript(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LoginScript
End Sub
'4.13 Display User Home Directory Path
Sub PullUserHomeDirPath(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.HomeDirectory
End Sub
'4.14 Display User Home Directory Mapping
Sub PullUserHomeDirDrive(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.Get("HomeDirDrive")
End Sub
'4.15 Display User Account Expiration Date (NT 4.0 only)
Sub PullUserAccountExpireDate(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.AccountExpirationDate
End Sub
'4.16 Display User Bad Login Count (NT 4.0 only)
Sub PullUserBadLoginCount(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.BadLoginCount
End Sub
'4.17 Display User Last Login (NT 4.0 only)
Sub PullUserLastLogin(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LastLogin
End Sub
'4.18 Display User Last Logoff (NT 4.0 only)
Sub PullUserLastLogoff(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LastLogoff
End Sub
'4.19 Display User Last Logoff (NT 4.0 only)
Sub PullUserLastLogoff1(strDomain,strUser)
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write User.LastLogoff
End Sub
'4.20 Display User Logon Hours Restriction(NT 4.0 only)
Sub PullUserLogonHourRestriction(strDomain,strUser)
Dim User
Dim RegTime
Dim Restrict
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
For Each RegTime In User.LoginHours
If RegTime < 255 Then Restrict = True
Next
Response.Write Restrict
End Sub
'5. Group Specific Fields
'5.1 Display All Users in a Group
Sub PullAllUserFromGroup(strDomain,strGroup)
Dim Group
Dim User
Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
For Each User in Group.Members
Response.Write "<span style='width:200px'>" & User.Name & "</span>"
Next
End Sub
'5.2 Display if a Users is listed in a Group
Sub DispUserInGroup(strDomain,strGroup,strUser)
Dim Group
Dim User
Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
Response.Write Group.IsMember(User.ADsPath)
End Sub
'5.2 Display Group Description
Sub PullGroupDescription(strDomain,strGroup,strUser)
Dim Group
Set Group = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
Response.Write Group.Description
End Sub
'5.2 Display Which Group a User is Listed in
Sub DispUserInWhichGroup(strDomain,strGroup,strUser)
Dim Group
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
For Each Group in User.Groups
Response.Write Group.Name
Next
End Sub
End Class
%>