-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Possibility to edit account validity dates (#190)
* Fix typo on new ppolicy attributes * Display if account is valid or not * Improve template for account validity * Display start date and end date * Update lang keys * Update validity dates * Dashboard for invalid accounts * Update docs
- Loading branch information
Showing
15 changed files
with
308 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Update start and end validity dates | ||
=================================== | ||
|
||
Some LDAP directories provide attributes to define start and end account validify dates. | ||
|
||
For OpenLDAP since 2.5 version, attributes are ``pwdStartTime`` and ``pwdEndTime``. | ||
|
||
For Active Directory, only end time is available, in ``accountExpires`` attribute. | ||
|
||
Show validity status | ||
------------------- | ||
|
||
Service Desk will display if account is valid or not. To allow this feature: | ||
|
||
.. code-block:: php | ||
$show_validitystatus = true; | ||
Update start date | ||
----------------- | ||
|
||
This feature allows to edit the account start validity date. This requires to have the `starttime` field defined in the attributes map. | ||
|
||
To enable this feature: | ||
|
||
.. code-block:: php | ||
$use_updatestarttime = true; | ||
Update end date | ||
----------------- | ||
|
||
This feature allows to edit the account end validity date. This requires to have the `endtime` field defined in the attributes map. | ||
|
||
To enable this feature: | ||
|
||
.. code-block:: php | ||
$use_updateendtime = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/* | ||
* Update start time and end time in LDAP directory | ||
*/ | ||
|
||
$result = ""; | ||
$dn = ""; | ||
$start_date = ""; | ||
$end_date = ""; | ||
$comment = ""; | ||
$returnto = "display"; | ||
|
||
if (isset($_POST["returnto"]) and $_POST["returnto"]) { | ||
$returnto = $_POST["returnto"]; | ||
} | ||
|
||
if (isset($_POST["dn"]) and $_POST["dn"]) { | ||
$dn = $_POST["dn"]; | ||
} else { | ||
$result = "dnrequired"; | ||
} | ||
|
||
if (isset($_POST["comment"]) and $_POST["comment"]) { | ||
$comment = $_POST["comment"]; | ||
} | ||
|
||
if (isset($_POST["start_date"]) and $_POST["start_date"]) { | ||
$start_date = $_POST["start_date"]; | ||
} | ||
|
||
if (isset($_POST["end_date"]) and $_POST["end_date"]) { | ||
$end_date = $_POST["end_date"]; | ||
} | ||
|
||
if (!($use_updatestarttime or $use_updateendtime)) { | ||
$result = "actionforbidden"; | ||
} | ||
|
||
if ($result === "") { | ||
|
||
require_once("../conf/config.inc.php"); | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
|
||
# Connect to LDAP | ||
$ldap_connection = $ldapInstance->connect(); | ||
|
||
$ldap = $ldap_connection[0]; | ||
$result = $ldap_connection[1]; | ||
|
||
# DN match | ||
if ( !$ldapInstance->matchDn($dn, $dnAttribute, $ldap_user_filter, $ldap_user_base, $ldap_scope) ) { | ||
$result = "noentriesfound"; | ||
error_log("LDAP - $dn not found using the configured search settings, reject request"); | ||
} else { | ||
if ($use_updatestarttime and $start_date) { | ||
$startDate = new DateTime($start_date); | ||
$ldapStartDate = $directory->getLdapDate($startDate); | ||
$update = $ldapInstance->modify_attributes($dn, array( $attributes_map['starttime']['attribute'] => $ldapStartDate)); | ||
if ( $update[0] == 0 ) { | ||
$result = "validiydatesupdated"; | ||
} else { | ||
$result = "ldaperror"; | ||
} | ||
} | ||
if ($use_updateendtime and $end_date) { | ||
$endDate = new DateTime($end_date); | ||
$ldapEndDate = $directory->getLdapDate($endDate); | ||
$update = $ldapInstance->modify_attributes($dn, array( $attributes_map['endtime']['attribute'] => $ldapEndDate)); | ||
if ( $update[0] == 0 and $result !== "ldaperror" ) { | ||
$result = "validiydatesupdated"; | ||
} else { | ||
$result = "ldaperror"; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if ($audit_log_file) { | ||
auditlog($audit_log_file, $dn, $audit_admin, "updatevaliditydates", $result, $comment); | ||
} | ||
|
||
header('Location: index.php?page='.$returnto.'&dn='.$dn.'&updatevaliditydatesresult='.$result); |
Oops, something went wrong.