+
diff --git a/www/account_manager/show_user.php b/www/account_manager/show_user.php
index 63cd96a..66ad7fc 100644
--- a/www/account_manager/show_user.php
+++ b/www/account_manager/show_user.php
@@ -24,7 +24,11 @@ if ($SIMPLE_INTERFACE == FALSE) {
}
$LDAP['default_attribute_map']["mail"] = array("label" => "Email", "onkeyup" => "check_if_we_should_enable_sending_email();");
-$attribute_map = ldap_complete_account_attribute_array();
+$attribute_map = $LDAP['default_attribute_map'];
+if (isset($LDAP['account_additional_attributes'])) { $attribute_map = ldap_complete_attribute_array($attribute_map,$LDAP['account_additional_attributes']); }
+if (! array_key_exists($LDAP['account_attribute'], $attribute_map)) {
+ $attribute_r = array_merge($attribute_map, array($LDAP['account_attribute'] => array("label" => "Account UID")));
+}
if (!isset($_POST['account_identifier']) and !isset($_GET['account_identifier'])) {
?>
@@ -164,30 +168,10 @@ if ($ldap_search) {
}
if ($updated_account) {
- ?>
-
-
+ $attr_r) {
+ $label = $attr_r['label'];
+ if (isset($attr_r['onkeyup'])) { $onkeyup = $attr_r['onkeyup']; } else { $onkeyup = ""; }
+ if ($attribute == $LDAP['account_attribute']) { $label = "
"; }
+ if (isset($$attribute)) { $these_values=$$attribute; } else { $these_values = array(); }
+ if (isset($attr_r['multiple'])) { $multiple = $attr_r['multiple']; } else { $multiple = FALSE; }
+ render_attribute_fields($attribute,$label,$these_values,$onkeyup,$multiple);
+ }
+ ?>
- $attr_r) {
- $label = $attr_r['label'];
- if (isset($attr_r['onkeyup'])) { $onkeyup = $attr_r['onkeyup']; } else { $onkeyup = ""; }
- if ($attribute == $LDAP['account_attribute']) { $label = "
"; }
- if (isset($$attribute)) { $these_values=$$attribute; } else { $these_values = array(); }
- if (isset($attr_r['multiple'])) { $multiple = $attr_r['multiple']; } else { $multiple = FALSE; }
- render_attribute_fields($attribute,$label,$these_values,$onkeyup,$multiple);
- }
-?>
-
-
-
+
+
+
+
+
+
-
+
diff --git a/www/includes/config.inc.php b/www/includes/config.inc.php
index f30f661..da7d16a 100644
--- a/www/includes/config.inc.php
+++ b/www/includes/config.inc.php
@@ -12,6 +12,11 @@
"mail" => array("label" => "Email", "onkeyup" => "auto_email_update = false; check_email_validity(document.getElementById('mail').value);")
);
+ $LDAP['group_objectclasses'] = array( 'person', 'inetOrgPerson', 'posixAccount' );
+ $LDAP['default_group_attribute_map'] = array( "gidnumber" => array("label" => "Group ID number")
+ );
+
+
#Mandatory
$LDAP['uri'] = getenv('LDAP_URI');
diff --git a/www/includes/ldap_functions.inc.php b/www/includes/ldap_functions.inc.php
index 53c4195..3b4da4e 100644
--- a/www/includes/ldap_functions.inc.php
+++ b/www/includes/ldap_functions.inc.php
@@ -438,19 +438,17 @@ function ldap_get_group_list($ldap_connection,$start=0,$entries=NULL,$sort="asc"
##################################
-function ldap_get_dn_of_group($ldap_connection,$group_name) {
+function ldap_get_group_entry($ldap_connection,$group_name) {
global $log_prefix, $LDAP, $LDAP_DEBUG;
if (isset($group_name)) {
$ldap_search_query = "(${LDAP['group_attribute']}=" . ldap_escape($group_name, "", LDAP_ESCAPE_FILTER) . ")";
- $ldap_search = @ ldap_search($ldap_connection, "${LDAP['group_dn']}", $ldap_search_query , array("dn"));
+ $ldap_search = @ ldap_search($ldap_connection, "${LDAP['group_dn']}", $ldap_search_query);
$result = @ ldap_get_entries($ldap_connection, $ldap_search);
- if (isset($result[0]['dn'])) {
- return $result[0]['dn'];
- }
+ return $result;
}
@@ -567,7 +565,7 @@ function ldap_user_group_membership($ldap_connection,$username) {
##################################
-function ldap_new_group($ldap_connection,$group_name,$initial_member="") {
+function ldap_new_group($ldap_connection,$group_name,$initial_member="",$extra_attributes=array()) {
global $log_prefix, $LDAP, $LDAP_DEBUG;
@@ -575,61 +573,70 @@ function ldap_new_group($ldap_connection,$group_name,$initial_member="") {
if (isset($group_name)) {
- $new_group = ldap_escape($group_name, "", LDAP_ESCAPE_FILTER);
- $initial_member = ldap_escape($initial_member, "", LDAP_ESCAPE_FILTER);
+ $new_group = ldap_escape($group_name, "", LDAP_ESCAPE_FILTER);
+ $initial_member = ldap_escape($initial_member, "", LDAP_ESCAPE_FILTER);
+ $update_gid_store=FALSE;
- $ldap_search_query = "(${LDAP['group_attribute']}=$new_group,${LDAP['group_dn']})";
- $ldap_search = @ ldap_search($ldap_connection, "${LDAP['group_dn']}", $ldap_search_query);
- $result = @ ldap_get_entries($ldap_connection, $ldap_search);
+ $ldap_search_query = "(${LDAP['group_attribute']}=$new_group,${LDAP['group_dn']})";
+ $ldap_search = @ ldap_search($ldap_connection, "${LDAP['group_dn']}", $ldap_search_query);
+ $result = @ ldap_get_entries($ldap_connection, $ldap_search);
- if ($result['count'] == 0) {
+ if ($result['count'] == 0) {
- $highest_gid = ldap_get_highest_id($ldap_connection,'gid');
- $new_gid = $highest_gid + 1;
+ if ($rfc2307bis_available == FALSE) { $objectclasses = array('top','posixGroup'); } else { $objectclasses = array('top','groupOfUniqueNames','posixGroup'); }
+ if (isset($LDAP['group_additional_objectclasses']) and $LDAP['group_additional_objectclasses'] != "") {
+ $objectclasses = array_merge($objectclasses, explode(",", $LDAP['group_additional_objectclasses']));
+ }
+ if ($LDAP['group_membership_uses_uid'] == FALSE and $initial_member != "") { $initial_member = "${LDAP['account_attribute']}=$initial_member,${LDAP['user_dn']}"; }
- if ($rfc2307bis_available == FALSE) { $objectclasses = array('top','posixGroup'); } else { $objectclasses = array('top','groupOfUniqueNames','posixGroup'); }
- if (isset($LDAP['group_additional_objectclasses']) and $LDAP['group_additional_objectclasses'] != "")
- $objectclasses = array_merge($objectclasses, explode(",", $LDAP['group_additional_objectclasses']));
- if ($LDAP['group_membership_uses_uid'] == FALSE and $initial_member != "") { $initial_member = "${LDAP['account_attribute']}=$initial_member,${LDAP['user_dn']}"; }
+ $new_group_array=array( 'objectClass' => $objectclasses,
+ 'cn' => $new_group,
+ $LDAP['group_membership_attribute'] => $initial_member
+ );
- $new_group_array=array( 'objectClass' => $objectclasses,
- 'cn' => $new_group,
- 'gidNumber' => $new_gid,
- $LDAP['group_membership_attribute'] => $initial_member
- );
+ $new_group_array = array_merge($new_group_array,$extra_attributes);
- $group_dn="cn=$new_group,${LDAP['group_dn']}";
+ if (!isset($new_group_array["gidnumber"][0]) or !is_numeric($new_group_array["gidnumber"][0])) {
+ $highest_gid = ldap_get_highest_id($ldap_connection,'gid');
+ $new_gid = $highest_gid + 1;
+ $new_group_array["gidnumber"] = $new_gid;
+ $update_gid_store=TRUE;
+ }
- $add_group = @ ldap_add($ldap_connection, $group_dn, $new_group_array);
+ $group_dn="cn=$new_group,${LDAP['group_dn']}";
- if (! $add_group ) {
- $this_error="$log_prefix LDAP: unable to add new group (${group_dn}): " . ldap_error($ldap_connection);
- if ($LDAP_DEBUG == TRUE) { error_log("$log_prefix DEBUG add_group array: ". print_r($new_group_array,true),0); }
- error_log($this_error,0);
- }
- else {
- error_log("$log_prefix Added new group $group_name",0);
+ $add_group = @ ldap_add($ldap_connection, $group_dn, $new_group_array);
- $this_gid = fetch_id_stored_in_ldap($ldap_connection,"gid");
- if ($this_gid != FALSE) {
- $update_gid = @ ldap_mod_replace($ldap_connection, "cn=lastGID,${LDAP['base_dn']}", array( 'serialNumber' => $new_gid ));
- if ($update_gid) {
- error_log("$log_prefix Updated cn=lastGID with $new_gid",0);
+ if (! $add_group ) {
+ $this_error="$log_prefix LDAP: unable to add new group (${group_dn}): " . ldap_error($ldap_connection);
+ if ($LDAP_DEBUG == TRUE) { error_log("$log_prefix DEBUG add_group array: ". print_r($new_group_array,true),0); }
+ error_log($this_error,0);
}
else {
- error_log("$log_prefix Unable to update cn=lastGID to $new_gid - this could cause groups to share the same GID.",0);
- }
- }
- return TRUE;
- }
+ error_log("$log_prefix Added new group $group_name",0);
- }
- else {
- error_log("$log_prefix Create group; group $group_name already exists.",0);
- }
+ if ($update_gid_store == TRUE) {
+ $this_gid = fetch_id_stored_in_ldap($ldap_connection,"gid");
+ if ($this_gid != FALSE) {
+ $update_gid = @ ldap_mod_replace($ldap_connection, "cn=lastGID,${LDAP['base_dn']}", array( 'serialNumber' => $new_gid ));
+ if ($update_gid) {
+ error_log("$log_prefix Updated cn=lastGID with $new_gid",0);
+ }
+ else {
+ error_log("$log_prefix Unable to update cn=lastGID to $new_gid - this could cause groups to share the same GID.",0);
+ }
+ }
+ return TRUE;
+ }
+ }
+
+ }
+ else {
+ error_log("$log_prefix Create group; group $group_name already exists.",0);
+ }
}
else {
- error_log("$log_prefix Create group; group name wasn't set.",0);
+ error_log("$log_prefix Create group; group name wasn't set.",0);
}
return FALSE;
@@ -637,6 +644,37 @@ function ldap_new_group($ldap_connection,$group_name,$initial_member="") {
}
+##################################
+
+function ldap_update_group_attributes($ldap_connection,$group_name,$extra_attributes) {
+
+ global $log_prefix, $LDAP, $LDAP_DEBUG;
+
+ if (isset($group_name) and (count($extra_attributes) > 0)) {
+
+ $group_name = ldap_escape($group_name, "", LDAP_ESCAPE_FILTER);
+ $group_dn = "${LDAP['group_attribute']}=$group_name,${LDAP['group_dn']}";
+
+ $update_group = @ ldap_mod_replace($ldap_connection, $group_dn, $extra_attributes);
+
+ if (!$update_group ) {
+ $this_error="$log_prefix LDAP: unable to update group attributes for group (${group_dn}): " . ldap_error($ldap_connection);
+ if ($LDAP_DEBUG == TRUE) { error_log("$log_prefix DEBUG update group attributes array: ". print_r($extra_attributes,true),0); }
+ error_log($this_error,0);
+ return FALSE;
+ }
+ else {
+ error_log("$log_prefix Updated group attributes for $group_name",0);
+ return TRUE;
+ }
+ }
+ else {
+ error_log("$log_prefix Update group attributes; group name wasn't set.",0);
+ return FALSE;
+ }
+
+}
+
##################################
function ldap_delete_group($ldap_connection,$group_name) {
@@ -687,58 +725,54 @@ function ldap_get_gid_of_group($ldap_connection,$group_name) {
##################################
-function ldap_complete_account_attribute_array() {
+function ldap_complete_attribute_array($default_attributes,$additional_attributes) {
- global $LDAP;
+ global $LDAP;
- $attribute_r = $LDAP['default_attribute_map'];
- $additional_attributes_r = array();
+ if (is_array($additional_attributes) and count($additional_attributes > 0)) {
- if (isset($LDAP['account_additional_attributes'])) {
+ $user_attribute_r = explode(",", $additional_attributes);
+ $to_merge = array();
- $user_attribute_r = explode(",", $LDAP['account_additional_attributes']);
+ foreach ($user_attribute_r as $this_attr) {
- foreach ($user_attribute_r as $this_attr) {
+ $this_r = array();
+ $kv = explode(":", $this_attr);
+ $attr_name = strtolower(filter_var($kv[0], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
+ if (substr($attr_name, -1) == '+') {
+ $this_r['multiple'] = TRUE;
+ $attr_name = rtrim($attr_name, '+');
+ }
+ else {
+ $this_r['multiple'] = FALSE;
+ }
- $this_r = array();
- $kv = explode(":", $this_attr);
- $attr_name = strtolower(filter_var($kv[0], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
- if (substr($attr_name, -1) == '+') {
- $this_r['multiple'] = TRUE;
- $attr_name = rtrim($attr_name, '+');
- }
- else {
- $this_r['multiple'] = FALSE;
+ if (preg_match('/^[a-zA-Z0-9\-]+$/', $attr_name) == 1) {
+
+ if (isset($kv[1]) and $kv[1] != "") {
+ $this_r['label'] = filter_var($kv[1], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
+ }
+ else {
+ $this_r['label'] = $attr_name;
+ }
+
+ if (isset($kv[2]) and $kv[2] != "") {
+ $this_r['default'] = filter_var($kv[2], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
+ }
+
+ $to_merge[$attr_name] = $this_r;
+
+ }
}
+ $attribute_r = array_merge($default_attributes, $to_merge);
- if (preg_match('/^[a-zA-Z0-9\-]+$/', $attr_name) == 1) {
+ return($attribute_r);
- if (isset($kv[1]) and $kv[1] != "") {
- $this_r['label'] = filter_var($kv[1], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
- }
- else {
- $this_r['label'] = $attr_name;
- }
-
- if (isset($kv[2]) and $kv[2] != "") {
- $this_r['default'] = filter_var($kv[2], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
- }
-
- $additional_attributes_r[$attr_name] = $this_r;
-
- }
}
-
- $attribute_r = array_merge($attribute_r, $additional_attributes_r);
-
- }
-
- if (! array_key_exists($LDAP['account_attribute'], $attribute_r)) {
- $attribute_r = array_merge($attribute_r, array($LDAP['account_attribute'] => array("label" => "Account UID")));
- }
-
- return($attribute_r);
+ else {
+ return($default_attributes);
+ }
}
diff --git a/www/includes/web_functions.inc.php b/www/includes/web_functions.inc.php
index 179b65e..5af6772 100644
--- a/www/includes/web_functions.inc.php
+++ b/www/includes/web_functions.inc.php
@@ -654,6 +654,19 @@ function render_attribute_fields($attribute,$label,$values_r,$onkeyup="",$multip
}
+######################################################
+
+function render_alert_banner($message,$alert_class="success",$timeout=4000) {
-##EoFilelocal
+?>
+
+
+