diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm index 2d57012c090af8fcd4c28825fa9fd53431ba71dd..3bcc9e3cc1e3e517ec5f2f704225766eaa9167b1 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm @@ -137,6 +137,29 @@ sub searchOnExpr { return \%res; } +sub searchGt { + my ( $class, $args, $selectField, $value, @fields ) = splice @_; + return $args->{backend}->searchGt( $args, $selectField, $value, @fields ) + if ( _load( $args->{backend}, 'searchGt' ) ); + my %res = (); + $class->get_key_from_all_sessions( + $args, + sub { + my $entry = shift; + my $id = shift; + return undef unless ( $entry->{$selectField} > $value ); + if (@fields) { + $res{$id}->{$_} = $entry->{$_} foreach (@fields); + } + else { + $res{$id} = $entry; + } + undef; + } + ); + return \%res; +} + sub searchLt { my ( $class, $args, $selectField, $value, @fields ) = splice @_; return $args->{backend}->searchLt( $args, $selectField, $value, @fields ) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/CliSessions.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/CliSessions.pm index 5c855e79b811fc8de15f27878eb4e1fbeef0a63b..9863b59ea04da08010c385cbc9b45b0d22d984d7 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/CliSessions.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/CliSessions.pm @@ -73,6 +73,14 @@ sub _search { $res = Lemonldap::NG::Common::Apache::Session->searchOn( $args, $selectField, $value, @fields ); } + elsif ( $self->opts->{where} =~ /^(\w+)\s*<\s*(.*)/ ) { + $res = Lemonldap::NG::Common::Apache::Session->searchLt( $args, + $1, $2, @fields ); + } + elsif ( $self->opts->{where} =~ /^(\w+)\s*>\s*(.*)/ ) { + $res = Lemonldap::NG::Common::Apache::Session->searchGt( $args, + $1, $2, @fields ); + } else { die "Invalid --where option : " . $self->opts->{where}; } diff --git a/lemonldap-ng-common/scripts/lemonldap-ng-sessions b/lemonldap-ng-common/scripts/lemonldap-ng-sessions index d68e21060b447a0f0b623cf5698d20d88dfe0c80..19dbf8f6395ff63e0a8a7f841126cfc34d20a182 100755 --- a/lemonldap-ng-common/scripts/lemonldap-ng-sessions +++ b/lemonldap-ng-common/scripts/lemonldap-ng-sessions @@ -179,6 +179,9 @@ Examples lemonldap-ng-sessions search --where uid=dwho \ --select authenticationLevel + lemonldap-ng-sessions search --where '_startTime>20240410063538' + lemonldap-ng-sessions search --where '_startTime<20240410063538' + =head2 Delete lemonldap-ng-sessions delete [ ...]