Re: script to check change in groups
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Feb 2008 10:40:02 -0600
tdubb wrote:
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
The format of the whenChanged attribute is generalizedTime, similar to:
20080207000000.0Z
The format is YYYYMMDDhhmmss.0Z, where 0Z is the time zone offset, since the
dates are in UTC (Coordinated Universal Time, or what used to be called
GMT).
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: script to check change in groups
- From: tdubb
- Re: script to check change in groups
- From: tony
- Re: script to check change in groups
- References:
- script to check change in groups
- From: tdubb
- script to check change in groups
- Prev by Date: Re: script to find all files in folder/subfolders
- Next by Date: Re: Writing to a text file
- Previous by thread: Re: script to check change in groups
- Next by thread: Re: script to check change in groups
- Index(es):
Relevant Pages
|