1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Option Explicit
On Error Resume Next
Dim User , LstNm , Acry , dlg , UserName, MSG ,Prop , result,domainname,newpass
domainname = InputBox("Please enter domain name: " & vbcrlf & "If you leave it blank the domain name will be accepted as DOMAIN. " , "Domain Information")
if domainname = "" then domainname = "DOMAIN"
call main()
sub main()
UserName = InputBox("Please enter UserName: ", "User Information")
set User = GetObject("WinNT://" + domainname + "/" + UserName)
If User.Name = "" Then
Dim wu
wu = MsgBox("UserName is not specified." & vbcrlf & vbcrlf & "Do you want to enter another name?",4,"No such user")
msgbox wu
if wu=6 then call main else exit sub
Else
MSG= vbCRLf
MSG = MSG & "User (ID): " & UserName & vbcrlf
MSG = MSG & "Full Name: " & User.FullName & vbcrlf
MSG = MSG & "Description: " & User.Description & vbcrlf
MSG = MSG & vbcrlf
MSG = MSG & "Group Membership " & vbcrlf
For Each Prop In User.groups
MSG = MSG & " " & Prop.Name & vbcrlf
Next 'Prop
Acry = Instr(1, User.FullName, ", ", 1)
'LstNm = Left(User.FullName, Acry - 1)
If User.IsAccountLocked = -1 Then
MSG = MSG & vbcrlf
MSG = MSG & "Account Status: Locked" & vbcrlf
Else
MSG = MSG & vbcrlf
MSG = MSG & "Account Status: Active" & vbcrlf
End if
'If User.LastLogin < 0 Then
'MSG = MSG & vbcrlf
'MSG = MSG & LstNm & " is not logged on to domain." & vbcrlf
'Else
'MSG = MSG & vbcrlf
'MSG = MSG & LstNm & " Last" & vbCRLF & "User Logon" & vbCRLF & "Time: " & User.LastLogin & vbcrlf
'End if
If User.IsAccountLocked = -1 Then
MSG = MSG & vbcrlf
MSG = MSG & "Do you want to unlock " & vbcrlf
result=msgbox (msg,4,Username & " Status")
Else
MSG = MSG & vbcrlf
MSG = MSG & "The user is not locked out." & vbcrlf
result=msgbox (msg,0,Username & " Status")
End if
if result=6 then
User.IsAccountLocked = 0
User.SetInfo
result = msgbox(username & " has been unlocked successfully.")
end if
result = msgbox (username & " Attempt to change the password of the user?",4,"Password")
if result = 6 then
newpass = InputBox(" Please enter the user's new password : ", "New Password")
Call User.SetPassword(NewPass)
result = msgbox (username & " The password has been changed successfully.",0,"Password change")
end if
result = msgbox (username & " user is allowed to change his/her password" & vbcrlf & "at next logon?",4,"Authorization State")
if result = 6 then
User.passwordexpired = 1
User.SetInfo
result = msgbox (username & " will be able to change his/her password at next logon.",0,"Status Change")
end if
set User = nothing
set LstNm = nothing
set Acry = nothing
set wu = nothing
End If
wu = MsgBox("Do you want to enter another user name?",4,"New User")
if wu=6 then call main
end sub |
Partager