script to check change in groups



I have a script that is suppose to check the modification of a group on a
domain:

but its not working

Option Explicit
Dim strWhenChanged, strLastChanged
Dim strLastDateFile, objFSO, objDateFile
Dim strDomainAdmsDN, strAdminsDN, objDomainAdms, objAdmins
Dim objEmail
Const ForReading = 1
Const ForWriting = 2
Const OpenAsASCII = 0
Const CreateIfNotExist = True

' Specify Distinguished Names of groups to monitor.
strDomainAdmsDN = "cn=admins,ou=admin group,ou=ops,dc=domain,dc=com"


' Specify file where last change date (in UTC) is saved.
strLastDateFile = "C:\LastDate.txt"

' Retrieve last change date.
Set objFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set objDateFile = objFSO.OpenTextFile(strLastDateFile, ForReading)
If (Err.Number <> 0) Then
On Error GoTo 0

' Assign default date.
strLastChanged = "2/14/2007 3:03 PM"
Else
On Error GoTo 0
strLastChanged = objDateFile.ReadLine
objDateFile.Close
End If

' Bind to WEbops Windows Admin Group
Set objDomainAdms = GetObject("LDAP://"; & strDomainAdmsDN)

' Check if changed.
If (CDate(objDomainAdms.whenChanged) > CDate(strLastChanged)) Then

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "myemail@xxxxxxxxxx"
objEmail.To = myemail@xxxxxxxxxx
objEmail.Subject = "URGENT - Change admin group"
objEmail.Textbody = Join( Array( _
"****Automatic email****," _
, " "_
, "ALERT."_
, " "_
, "A change has been made to the xxxxxxxxxxxxxx" _
, " "_
, "Please check this group Immediately as the change could be suspect or
have been made in error"_
, " "_
, "If you are aware of the change please reply to everyone in this email to
confirm this is a genuine change"_
, " "_
, " "_
, "admin group was changed " & objDomainAdms.whenChanged & " "_
, " "_
, "Regards"_
, " "_
, "Admin group"_
, "ccccccc."_
, " "_
, " "_
, "myemail@xxxxxxxxxx"_
, " "_
, " "_
, " "_
, "Please contact the admin group with any issues"_
, " "_
, " "_
, " " ), vbCrLf )
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver";) =
"smtp.domain.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If


.



Relevant Pages

  • Re: script to check change in groups
    ... in group membership of a domain group. ... Dim strLastDateFile, objFSO, objDateFile ... Const ForReading = 1 ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • script to monitor change in group membership
    ... My script below works but it just sends me an alert whether the group has ... Dim strLastDateFile, objFSO, objDateFile ... Const ForReading = 1 ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: script to check change in groups
    ... Dim strLastDateFile, objFSO, objDateFile ... Const ForReading = 1 ... On Error GoTo 0 ... ' Bind to WEbops Windows Admin Group ...
    (microsoft.public.windows.server.scripting)
  • Re: script to check change in groups
    ... Dim strLastDateFile, objFSO, objDateFile ... Const ForReading = 1 ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: E-Mail on AD Group Membership Change
    ... Dim strLastDateFile, objFSO, objDateFile ... Const ForReading = 1 ... Set objDateFile = objFSO.OpenTextFile ... On Error GoTo 0 ...
    (microsoft.public.scripting.vbscript)

Loading