#!/usr/bin/perl use strict; use warnings; my $days = 30; #use FindBin qw($Bin); our $Bin; BEGIN { $Bin='/opt/otrs/bin'; } use lib "$Bin/.."; use lib "$Bin/../Kernel/cpan-lib"; use lib "$Bin/../Custom"; use Kernel::System::ObjectManager; # create object manager local $Kernel::OM = Kernel::System::ObjectManager->new( 'Kernel::System::Log' => { LogPrefix => 'OTRS-PDV.ShowSMIME.pl', }, ); my $TimeObject = $Kernel::OM->Get('Kernel::System::Time'); my $SystemTime = $TimeObject->CurrentTimestamp(); my $TimeStamp = $TimeObject->SystemTime2TimeStamp( SystemTime => $TimeObject->SystemTime() + $days*86400, ); # f��r OTRS4 # --- $Kernel::OM->ObjectParamAdd( 'Kernel::System::Crypt' => { CryptType => 'SMIME' } ); my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt'); # --- # f��r OTRS5 # --- my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME'); # --- my @List = (); if ($SMIMEObject) { @List = $SMIMEObject->Search(); } for my $Attributes (@List) { if ($Attributes->{ShortEndDate} lt $SystemTime) { print "$Attributes->{Type} $Attributes->{Subject} is expired\n"; } elsif ($Attributes->{ShortEndDate} lt $TimeStamp) { print "$Attributes->{Type} $Attributes->{Subject} will expire in less than $days days\n"; } }