Re: script to check change in groups



I am getting a

C:\SCRIPTS\notifygroupchange3.vbs(36, 1) Microsoft VBScript runtime error:
Type
mismatch: 'CDate'

error

My LastDate.txt file is like this

20080205140744.-8z



"tdubb" <tdubb123@xxxxxxxxx> wrote in message
news:%23Ithsi9dIHA.1376@xxxxxxxxxxxxxxxxxxxxxxx
ok for the time

2/5/2008 2:07:44 PM PST

this will be the UTC format?

20080205140744.-8Z

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23dFjCrjdIHA.4696@xxxxxxxxxxxxxxxxxxxxxxx
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
--






.



Relevant Pages

  • Re: Gap between Headings and Start of Output
    ... ' Format Distribution Categories ... Const MaxDist As Integer = 279 ... Dim DistSumAs Single ... don't like using active cell just for the reason we are havving here. ...
    (microsoft.public.excel.programming)
  • Re: script to check change in groups
    ... Dim strLastDateFile, objFSO, objDateFile ... ' Specify file where last change date (in UTC) is saved. ... The format of the whenChanged attribute is generalizedTime, ...
    (microsoft.public.windows.server.scripting)
  • Re: Setting field properties in code
    ... format that the user has defined in the Windows Control Panel, ... >> Sub StandardProperties(strTableName As String) ... >> Dim tdf As DAO.TableDef 'Table nominated in argument. ... >> Dim ind As DAO.Index ...
    (comp.databases.ms-access)
  • Re: Conditional format problem
    ... an Excel 5.0/95 format file, ... Anyone know how to save in a later Excel format from Access? ... Dim oXL As Object ... Dim strCondition1 As String ...
    (microsoft.public.excel.programming)
  • Re: Mail Merge HTML Format Word 2002 XP SP3
    ... HTML format as you have no control over how the recipient reads them. ... 'Creates a new e-mail item and modifies its properties. ... Dim olApp As Outlook.Application ...
    (microsoft.public.word.mailmerge.fields)