Skip to content

Commit

Permalink
Dashboard for invalid accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed Nov 28, 2024
1 parent 32ee346 commit 9b2bc80
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions conf/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
$show_validitystatus = true;
$use_updatestarttime = true;
$use_updateendtime = true;
$use_searchinvalid = true;

# Local password policy
# This is applied before directory password policy
Expand Down
2 changes: 2 additions & 0 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ function sha256($string)
$smarty->assign('show_validitystatus',$show_validitystatus);
$smarty->assign('use_updatestarttime',$attributes_map['starttime'] ? $use_updatestarttime : false);
$smarty->assign('use_updateendtime',$attributes_map['endtime'] ? $use_updateendtime : false);
$smarty->assign('use_searchinvalid',$use_searchinvalid);

# Assign messages
$smarty->assign('lang',$lang);
Expand Down Expand Up @@ -271,6 +272,7 @@ function sha256($string)
if ( $page === "searchidle" and !$use_searchidle ) { $page = "welcome"; }
if ( $page === "auditlog" and !$use_showauditlog ) { $page = "welcome"; }
if ( $page === "updatevaliditydates" and !($use_updatestarttime or $use_updateendtime) ) { $page = "welcome"; }
if ( $page === "searchinvalid" and !$use_searchinvalid ) { $page = "welcome"; }
if ( file_exists($page.".php") ) { require_once($page.".php"); }
$smarty->assign('page',$page);

Expand Down
44 changes: 44 additions & 0 deletions htdocs/searchinvalid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/*
* Search invalid entries in LDAP directory
*/

require_once("../conf/config.inc.php");
require __DIR__ . '/../vendor/autoload.php';
require_once("../lib/date.inc.php");

# Compute idle date
$date= new DateTime();
$dateLdap = $directory->getLdapDate($date);

# Search filter
$ldap_filter = "(&". $ldap_user_filter . "(|";
if ( isset($attributes_map['starttime']) ) {
$ldap_filter .= "(" . $attributes_map['starttime']['attribute'] .">=". $dateLdap .")";
$search_result_items[] = "starttime";
}
if ( isset($attributes_map['endtime']) ) {
$ldap_filter .= "(" . $attributes_map['endtime']['attribute'] ."<=". $dateLdap .")";
$search_result_items[] = "endtime";
}
$ldap_filter.= "))";

[$ldap,$result,$nb_entries,$entries,$size_limit_reached] = $ldapInstance->search($ldap_filter, array(), $attributes_map, $search_result_title, $search_result_sortby, $search_result_items, $ldap_scope);

if ( !empty($entries) )
{
$smarty->assign("page_title", "invalidaccountstitle");
$smarty->assign("nb_entries", $nb_entries);
$smarty->assign("entries", $entries);
$smarty->assign("size_limit_reached", $size_limit_reached);

$columns = $search_result_items;
if (! in_array($search_result_title, $columns)) array_unshift($columns, $search_result_title);
$smarty->assign("listing_columns", $columns);
$smarty->assign("listing_linkto", isset($search_result_linkto) ? $search_result_linkto : array($search_result_title));
$smarty->assign("listing_sortby", array_search($search_result_sortby, $columns));
$smarty->assign("show_undef", $search_result_show_undefined);
$smarty->assign("truncate_value_after", $search_result_truncate_value_after);
}

?>
2 changes: 2 additions & 0 deletions lang/en.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
$messages['idleaccounts'] = "Idle accounts";
$messages['idleaccountstitle'] = "Accounts idle for more than $idledays days";
$messages['insert_comment'] = "Insert comment";
$messages['invalidaccounts'] = "Invalid accounts";
$messages['invalidaccountstitle'] = "Invalid accounts";
$messages['pager_all'] = "All";
$messages['print_all'] = "Print all results";
$messages['print_page'] = "Print this page";
Expand Down
2 changes: 2 additions & 0 deletions lang/fr.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
$messages['idleaccounts'] = "Comptes inactifs";
$messages['idleaccountstitle'] = "Comptes inactifs depuis plus de $idledays jours";
$messages['insert_comment'] = "Insérer un commentaire";
$messages['invalidaccounts'] = "Comptes invalides";
$messages['invalidaccountstitle'] = "Comptes invalides";
$messages['pager_all'] = "Tout";
$messages['print_all'] = "Imprimer tous les résultats";
$messages['print_page'] = "Imprimer cette page";
Expand Down
3 changes: 3 additions & 0 deletions templates/menu.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
{if $use_searchidle}
<li><a href="index.php?page=searchidle" class="dropdown-item"><i class="fa fa-fw fa-hourglass-o"></i> {$msg_idleaccounts}</a></li>
{/if}
{if $use_searchinvalid}
<li><a href="index.php?page=searchinvalid" class="dropdown-item"><i class="fa fa-fw fa-user-xmark"></i> {$msg_invalidaccounts}</a></li>
{/if}
</ul>
</li>
{if $use_showauditlog}
Expand Down
11 changes: 11 additions & 0 deletions templates/searchinvalid.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="alert alert-warning">
{$nb_entries} {if $nb_entries==1}{$msg_entryfound}{else}{$msg_entriesfound}{/if}
</div>

{if {$size_limit_reached}}
<div class="alert alert-warning"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_sizelimit}</div>
{/if}

<table id="search-listing" class="table table-striped table-hover table-condensed dataTable">
{include 'listing_table.tpl' display="search"}
</table>

0 comments on commit 9b2bc80

Please sign in to comment.