DESCRIPTION
This "OnDeprovision" script notifies the manager of the target user object that is being deprovisioned.
Note This code may use functions from the Active Roles Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.
SCRIPT
'*********************************************************************************
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
'*********************************************************************************
' ********************************************************
' ********************************************************
'
' The purpose of this script is to send an email to the deprovisioned
' user object's manager, if one is configured
'
' ********************************************************
' ********************************************************
Sub onDeprovision(Request)
On Error Resume Next
' ********************************************************
' Set mail constants
strCmdMailCC = ""
constSmtpPort = 25
constSmtpServer = "smtp.itt.net"
' ********************************************************
' Access target user object and retrieve information
DirObj.GetInfo
DirObj.GetInfoEx "manager",0
strManager = DirObj.Get("manager")
' ********************************************************
' Send an email to the deprovisioned user object's manager
Set objManager = GetObject("EDMS://" & strManager)
objManager.GetInfo
strManagerMail = objManager.Get("mail")
' set remaining mail data and call mail subroutine
strCmdMsgText = "According to Active Directory data, a subordinate of yours has been deprovisioned " & vbCRLF
strCmdMsgText = strCmdMsgText & "from Active Directory. Their account will no longer function. " & vbCRLF & vbCRLF
strCmdMsgText = strCmdMsgText & "Please contact the Help Desk if this action is in error." & vbCRLF & vbCRLF
strCmdMsgText = strCmdMsgText & "User account being deprovisioned - " & strDeproDisplayName & vbCRLF & vbCRLF
strCmdMsgText = strCmdMsgText & "Description field of user account - " & strDepro
strCmdSubject = "Change to a subordinate's Active Directory account"
strCmdMailTo = strManagerMail
ITT_SendMail strCmdMsgText, strCmdSubject, strCmdMailTo, strCmdMailCC, strCmdMailFrom, constSmtpServer, constSmtpPort
' ********************************************************
End Sub
' ********************************************************
' ********************************************************
Sub ITT_SendMail(ByVal strMsg, ByVal strSubj, ByVal strMailTo, ByVal strMailCC, ByVal strMailFrom, SmtpServer, SmtpPort)
' Specify that the message will be sent using the network
' (SMTP over the network).
Const CdoSendUsingPort =2
Set iMsg = CreateObject("CDO.Message")
With iMsg
.From = strMailFrom
.To = strMailTo
.CC = strMailCC
.Subject = strSubj
End With
Set iBp = iMsg.BodyPart
' iBp.ContentMediaType = "multipart/mixed"
iBp.ContentMediaType = "text/plain"
Set iBp2 = iBp.AddBodyPart
With iBp2
.ContentMediaType = "text/plain"
.ContentTransferEncoding = "7bit"
Set Stm = .GetDecodedContentStream
Stm.WriteText strMsg
Stm.Flush
End With
' Configure message
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = CdoSendUsingPort
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SmtpServer
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SmtpPort
Flds.Update
Set iMsg.Configuration = iConf
' Send message
iMsg.Send
End Sub
'***** END OF CODE ***************************************************************