'Get UserManager.Server object
Dim UM:Set UM = CreateObject("UserManager.Server")
Dim User, Hour
'Add a test user
Set User = UM.Users.Add("~TestUser", "1TestPassword")
'Test user does not have access in sunday
For Hour=0 To 23
User.LogonHours(Hour) = False
Next
'List of account logon hours, sun, mon
Dim Out: Out = "Logon hours info:" & vbCrLf
Out = Out & toS("Account",25) & toS("Logon hours - sun", 25) & _
toS("Logon hours - mon", 25) & vbCrLf
For Each User In UM.Users
Out = Out & toS(User.Name,25)
For Hour=0 To 47
If User.LogonHours(Hour) Then
Out = Out & "X"
Else
Out = Out & "-"
End If
If (Hour+1) Mod 24 = 0 Then Out = Out & " "
Next
Out = Out & vbCrLf
Next
Wscript.Echo Out
'Delete the test account
UM.Users("~TestUser").Delete
Function toS(byval W, Cols)
W = "" & W: If W = "" Then W = "-"
On Error Resume Next
W = W & Space(Cols-Len(W))
toS = W
End Function |