Is there anywhere in LFDS that allows you to create a trigger which sends an email notification out whenever the Directory Sync fails?
Question
Question
Replies
Hi Tyler,
As others have mentioned, this functionality is not present in LFDS at this time. Improvements to Active Directory group synchronization are on our backlog though and this includes the functionality you are asking about.
No there's not, but it would be a great feature
Since this was a few years ago, has this feature ever been added? Or is using a PowerShell script or other third party application the only way to receive a notification of a sync failure?
Hi Tyler,
Not to my knowledge. I do believe it records an Event Log event (error or warning) that you could potentially set up an email alert for using 3rd party tools.
Hey Sam, Tyler-
Quick note on this. I set up a PowerShell script to email me from a scheduled task that's triggered on an event.
However, there's a flaw with that (hopefully you can pass it on to the Devs): the sync failure logs an error with Event ID 2. Unfortunately, opening the LFDS web page, not having a valid authentication cookie, and it seamlessly authenticating you to go do admin stuff also throws an error with Event ID 2. So every time one of the folks on my team open LFDS to do something, an email alert fires off.
I would guess that it's possible to parse the event itself to determine if the email should fire off, but that would require additional extra work that I'm not familiar with. Would be very helpful if those two very different events were logged with different levels and/or IDs.
Hey Pieter,
Mind sharing your PowerShell script? Sanitized as necessary, of course. I'd be willing to take a look and see if it's easy to add event content parsing. Would also be helpful if you had the full event log message text for a sync failure handy as I do not.
Here's the script along with a screenshot of the event trigger. Basically, the trigger is an event comes in to the LFDS operation log with ID = 2, then the script will grab the most recent event in that log with ID = 2 and put it into the email body. The sleep at the end of the script is in case something goes haywire and starts logging errors every few seconds, we'll only get the alerts once every 15 minutes.
As a side note, I have scripts like this set up for a couple other LF modules that don't send alerts when there are problems, like Import Agent.
$EventId = 2 $A = Get-WinEvent -MaxEvents 1 -FilterHashTable @{Logname = "Laserfiche-Directory Service-Server/Operational" ; ID = $EventId} $Message = $A.Message $EventID = $A.Id $MachineName = $A.MachineName $Source = $A.ProviderName $EmailFrom = "FROM Address Here" $EmailTo = "TO Address Here" $Subject ="Alert From $MachineName" $Body = "EventID: $EventID`nSource: $Source`nMachineName: $MachineName `nMessage: $Message" $SMTPServer = "SMTP Server Here" $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25) $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body) Start-Sleep -s 900