'------------------------------------------------------------------
'Title: GroupWise User Account Enable Script
'Purpose: To Clear Disable Logins checkbox, un-Expire,
' and Set Visibility to 'system' using the GroupWise API
'Creator: Corey Sines
'Version: 1.1
'Date: 02/21/2014
'------------------------------------------------------------------
On error resume next
dim GWSystem
dim GWUsers
dim GWUser, TempGWuser
dim Args, sGWDomainPath, sGivenName, sSurName, sMailBoxID
dim iUserCount, bEnabledUser
If wscript.arguments.count = 4 then ' needs all 3 arguments
Set Args = Wscript.Arguments
Else
Wscript.echo "Usage: GWUserEnable.vbs GWDomainPath GivenName Surname GWMailboxID"
wscript.quit(1)
End If
' Setting variables to Arguments supplied
sGWDomainPath = Args(0) ' Needs to a UNC or Mapped Drive Path the current user has read rights to
sGivenName = Args(1)
sSurName = Args(2)
sMailBoxID = Args(3)
Set fso = CreateObject("Scripting.FileSystemObject")
'Checking if GW Domain Path exists and is accessible
If (fso.FolderExists(sGWDomainPath)) Then
set GWSystem=CreateObject("NovellGroupWareAdmin")
GWSystem.Connect( sGWDomainPath ) ' Connecting to the GroupWise System using the UNC / Mapped Path
Else
wscript.echo "GW Domain Path:" & sGWDomainPath & " appears invalid, or the user doesn't have rights to this location."
wscript.quit(97) ' Error Occurred, sending exit code 99
End If
'iterate through the collection of users and output users with login disabled or an expiration date greater than zero and less than today
bEnabledUser = False
GWuser = Null
set GWPostOffices = GWSystem.PostOffices
For Each PO in GWPostOffices
set TempGWUser = PO.FindObject(sMailBoxID)
If (Ucase(TempGWUser.GivenName) = Ucase(sGivenName)) and (Ucase(TempGWUser.SurName) = Ucase(sSurName)) Then
wscript.echo sGivenName & " " & sSurName & " Name Matched in GroupWise.."
set GWUser = PO.FindObject(sMailBoxID)
End If
Next
If (IsNull(GWUser)) Then
Wscript.echo "No GW Accounts returned in search for User:" & sGivenName & " " & sSurName
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
wscript.quit(99) ' Error Occurred, sending exit code 99
Else
'Checking if the GW Account is really disabled or expired
if GWUser.DisableLogin = True _
or ( GWUser.MailBoxExpDate < now() _
and GWUser.MailBoxExpDate > 0 ) then
wscript.echo "GW User Account Found, current settings are:"
wscript.echo "GW User Name: " & GWUser.Name & VbCrLf _
& "GW SurName: " & GWUser.Surname & VbCrLf _
& "GW Given Name: " & GWUser.GivenName & VbCrLf _
& "GW MailboxID: " & GWUser.MailboxID & VbCrLf _
& "GW Expiration Date " & GWUser.MailBoxExpDate & VbCrLf _
& "GW Visibility: " & GWUser.Visibility & VbCrLf _
& "GW Is Logins Disabled?: " & GWUser.DisableLogin
if GWUser.MailboxID = sMailBoxID Then
wscript.echo "Mailbox ID:" & sMailBoxID & " matches, Attempting to re-enable the GroupWise Account.."
GWUser.DisableLogin = False ' Clears the check box for disable logins
GWUser.MailboxExpDate = CDate("1/1/1899 1:00:00 AM") 'This date clears the Expiration
GWUser.Visibility = 2 ' 2 is System Visibility
'Commit the Changes
GWUser.Commit()
GWSystem.Commit()
wscript.sleep 2000
If GWUser.DisableLogin = False then
Wscript.echo "Success!!"
bEnabledUser = True
Else
wscript.echo "Failed!!"
End If
End if
Else
wscript.echo "GW Account:" & sGivenName & " " & sSurName & " was not disabled, so no work to do..."
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
wscript.quit(98) ' Error Occurred, sending exit code 98
End If
End If
If bEnabledUser = False Then
wscript.echo "Unknown Error..GW Account:" & sGivenName & " " & sSurName & " Was not successfully enabled..."
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
wscript.quit(96) ' Error Occurred, sending exit code 96
End If
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
##########################################################################
'------------------------------------------------------------------
'Title: GroupWise User Account Disable Script
'Purpose: To Disable Logins, Expire, and Set Visibility to 'none'
' using the GroupWise API
'Creator: Corey Sines
'Version: 1.1
'Date: 02/21/2014
'------------------------------------------------------------------
On error resume next
dim GWSystem
dim GWUsers
dim GWUser
dim Args, sGWDomainPath, sGivenName, sSurName
dim iUserCount, bUserDisabled
dim fso
If wscript.arguments.count = 4 then ' needs all 3 arguments
Set Args = Wscript.Arguments
Else
Wscript.echo "Usage: GWUserDisable.vbs GWDomainPath GivenName Surname MailboxID"
wscript.quit(1)
End If
' Setting variables to Arguments supplied
sGWDomainPath = Args(0) ' Needs to a UNC or Mapped Drive Path the current user has read rights to
sGivenName = Args(1)
sSurName = Args(2)
sMailBoxID = Args(3)
Set fso = CreateObject("Scripting.FileSystemObject")
'Checking if GW Domain Path exists and is accessible
If (fso.FolderExists(sGWDomainPath)) Then
set GWSystem=CreateObject("NovellGroupWareAdmin")
GWSystem.Connect( sGWDomainPath ) ' Connecting to the GroupWise System using the UNC / Mapped Path
Else
wscript.echo "GW Domain Path:" & sGWDomainPath & " appears invalid, or the user doesn't have rights to this location."
wscript.quit(97) ' Error Occurred, sending exit code 99
End If
'iterate through the collection of users and output users with login disabled or an expiration date greater than zero and less than today
bUserDisabled = False
GWuser = Null
set GWPostOffices = GWSystem.PostOffices
For Each PO in GWPostOffices
set TempGWUser = PO.FindObject(sMailBoxID)
If (Ucase(TempGWUser.GivenName) = Ucase(sGivenName)) and (Ucase(TempGWUser.SurName) = Ucase(sSurName)) Then
wscript.echo sGivenName & " " & sSurName & " Name Matched in GroupWise.."
set GWUser = TempGWUser
End If
Next
If (IsNull(GWUser)) Then
wscript.echo "No GW Accounts returned in search for User:" & sGivenName & " " & sSurName
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
wscript.quit(99) ' Error Occurred, sending exit code 99
Else
if GWUser.DisableLogin = False _
or ( GWUser.MailBoxExpDate > now() _
and GWUser.MailBoxExpDate <= 0 ) then ' Checking if User account is disabled or expired
wscript.echo "GW User Account Found, current settings are:"
wscript.echo "GW User Name: " & GWUser.Name & VbCrLf _
& "GW SurName: " & GWUser.Surname & VbCrLf _
& "GW Given Name: " & GWUser.GivenName & VbCrLf _
& "GW MailboxID: " & GWUser.MailboxID & VbCrLf _
& "GW Expiration Date " & GWUser.MailBoxExpDate & VbCrLf _
& "GW Visibility: " & GWUser.Visibility & VbCrLf _
& "GW Is Logins Disabled?: " & GWUser.DisableLogin
if GWUser.MailboxID = sMailBoxID Then
wscript.echo "Mailbox ID:" & sMailBoxID & " matches, attempting to disable logins and expire the GroupWise Account.."
GWUser.DisableLogin = True
GWUser.MailboxExpDate = CDate(Now()) 'Disabling the account as of now
GWUser.Visibility = 4 ' 4 equals a visibility of 'none'
'Commit the Changes
GWUser.Commit()
GWSystem.Commit()
wscript.sleep 2000
If GWUser.DisableLogin = True then
wscript.echo "Success!!"
bUserDisabled = True
' wscript.echo "After Changes, here is the user info.."
' wscript.echo "GW User Name: " & GWUser.Name & VbCrLf _
' & "GW SurName: " & GWUser.Surname & VbCrLf _
' & "GW Given Name: " & GWUser.GivenName & VbCrLf _
' & "GW MailboxID: " & GWUser.MailboxID & VbCrLf _
' & "GW Expiration Date " & GWUser.MailBoxExpDate & VbCrLf _
' & "GW Visibility: " & GWUser.Visibility & VbCrLf _
' & "GW Is Logins Disabled?: " & GWUser.DisableLogin
End If
End If
Else
wscript.echo "GW Account:" & sGivenName & " " & sSurName & " was not enabled, so no work to do..."
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
wscript.quit(98) ' Error Occurred, sending exit code 98
End if
End If
If bUserDisabled = False Then
wscript.echo "Unknown Error..GW Account:" & sGivenName & " " & sSurName & " Was not successfully disabled..."
set GWUser = Nothing
set GWPostOffices = Nothing
Set GWSystem = Nothing
wscript.quit(96) ' Error Occurred, sending exit code 96
End If
No comments:
Post a Comment