index a8e8c29f05774f2ee21af840c47a2c6793baf3a7..961abc56a65296dd2956d70ccedb1935c1750b08 100644 (file)
/* Configuration file location */
define ("CONFIG_DIR", "/etc/gosa");
-define ("CONFIG_FILE", "gosa.conf-trunk");
+define ("CONFIG_FILE", "gosa.conf");
define ("CONFIG_TEMPLATE_DIR", "../contrib/");
-define ("HELP_BASEDIR", "/var/www/doc/");
/* Define get_list flags */
define("GL_NONE", 0);
$attrs["cn"] = "$name";
$ldap->add($attrs);
if (!$ldap->success()){
- msg_dialog::display(_("Internal error"), sprintf(_("Adding a lock failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), "cn=$name,".$config->current['CONFIG'], 0, ERROR_DIALOG));
return;
}
}
"mimetypeou" => "ou=mime,");
/* Preset ou... */
- if (isset($config->current[$name])){
- $ou= $config->current[$name];
+ if (isset($config->current[strtoupper($name)])){
+ $ou= $config->current[strtoupper($name)];
} elseif (isset($map[$name])) {
$ou = $map[$name];
return($ou);
if ($ou != ""){
if (!preg_match('/^[^=]+=[^=]+/', $ou)){
- return @LDAP::convert("ou=$ou,");
+ $ou = @LDAP::convert("ou=$ou");
} else {
- return @LDAP::convert("$ou,");
+ $ou = @LDAP::convert("$ou");
}
+
+ if(preg_match("/".normalizePreg($config->current['BASE'])."$/",$ou)){
+ return($ou);
+ }else{
+ return("$ou,");
+ }
+
} else {
return "";
}
}
-function print_red()
-{
- trigger_error("Use of obsolete print_red");
- /* Check number of arguments */
- if (func_num_args() < 1){
- return;
- }
-
- /* Get arguments, save string */
- $array = func_get_args();
- $string= $array[0];
-
- /* Step through arguments */
- for ($i= 1; $i<count($array); $i++){
- $string= preg_replace ("/%s/", $array[$i], $string, 1);
- }
-
- /* If DEBUGLEVEL is set, we're in web mode, use textual output in
- the other case... */
- if($string !== NULL){
- if (preg_match("/"._("LDAP error:")."/", $string)){
- $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
- } else {
- if (!preg_match('/[.!?]$/', $string)){
- $string.= ".";
- }
- $string= preg_replace('/<br>/', ' ', $string);
- $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
- $addmsg = "";
- }
- if(empty($addmsg)){
- $addmsg = _("Error");
- }
- msg_dialog::display($addmsg, $string,ERROR_DIALOG);
- return;
- }else{
- return;
- }
-
-}
-
-
function gen_locked_message($user, $dn)
{
global $plug, $config;
} else {
$smarty->assign ("action", _("Edit anyway"));
}
- $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries '%s'"), "<b>".$msg."</b>", ""));
+ $smarty->assign ("message", sprintf(_("You're going to edit the LDAP entry/entries %s"), "<b>".$msg."</b>", ""));
return ($smarty->fetch (get_template_path('islocked.tpl')));
}
function back_to_main()
{
$string= '<br><p class="plugbottom"><input type=submit name="password_back" value="'.
- _("Back").'"></p><input type="hidden" name="ignore">';
+ msgPool::backButton().'"></p><input type="hidden" name="ignore">';
return ($string);
}
if (preg_match("/^[0-9]+$/", $output[0])){
return ($output[0]);
} else {
- msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
+ msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base!"), WARNING_DIALOG);
return ($config->current['UIDBASE']);
}
} else {
- msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
+ msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base!"), WARNING_DIALOG);
return ($config->current['UIDBASE']);
}
} else {
- msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
+ msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base!"), WARNING_DIALOG);
return ($config->current['UIDBASE']);
}
// Get all available encryption Methods
// NON STATIC CALL :)
- $tmp = new passwordMethod(session::get('config'));
- $available = $tmp->get_available_methods();
+ $methods = new passwordMethod(session::get('config'));
+ $available = $methods->get_available_methods();
// read current password entry for $dn, to detect the encryption Method
$ldap = $config->get_ldap_link();
/* Extract used hash */
if ($hash == ""){
- $hash= strtolower($matches[1]);
+ $test = passwordMethod::get_method($attrs['userPassword'][0]);
+ } else {
+ $test = new $available[$hash]($config);
+ $test->set_hash($hash);
}
- $test = new $available[$hash]($config);
-
} else {
// User MD5 by default
$hash= "md5";
$attrs= generate_smb_nt_hash($password);
}
- /* Readd ! if user was deactivated */
+ /* Read ! if user was deactivated */
if($deactivated){
$newpass = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$newpass);
}
# Try to use gosa-si?
if (isset($config->current['GOSA_SI'])){
- $res= gosaSupportDaemon::send("gosa_gen_smb_hash", "GOSA", array("password" => $password), TRUE);
- $hash= $res['XML']['HASH'];
+ $res= gosaSupportDaemon::send("gosa_gen_smb_hash", "GOSA", array("password" => $password), TRUE);
+ if (isset($res['XML']['HASH'])){
+ $hash= $res['XML']['HASH'];
+ } else {
+ $hash= "";
+ }
} else {
$tmp= $config->data['MAIN']['SMBHASH']." ".escapeshellarg($password);
@DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $tmp, "Execute");
}
-function crypt_single($string,$enc_type )
-{
- return( passwordMethod::crypt_single_str($string,$enc_type));
-}
-
-
function getEntryCSN($dn)
{
global $config;
@@ -2707,11 +2670,66 @@ function send_binary_content($data,$name,$type = "application/octet-stream")
HTML output, without breaking quotes.
@param The String we want to encode.
@return The encoded String
-*/
+ */
function xmlentities($str)
+{
+ if(is_string($str)){
+ return(htmlentities($str,ENT_QUOTES));
+ }elseif(is_array($str)){
+ foreach($str as $name => $value){
+ $str[$name] = xmlentities($value);
+ }
+ }
+ return($str);
+}
+
+
+/*! \brief Updates all accessTo attributes from a given value to a new one.
+ For example if a host is renamed.
+ @param String $from The source accessTo name.
+ @param String $to The destination accessTo name.
+*/
+function update_accessTo($from,$to)
{
- return (htmlentities($str,ENT_QUOTES));
+ global $config;
+ $ldap = $config->get_ldap_link();
+ $ldap->cd($config->current['BASE']);
+ $ldap->search("(&(objectClass=trustAccount)(accessTo=".$from."))",array("objectClass","accessTo"));
+ while($attrs = $ldap->fetch()){
+ $new_attrs = array("accessTo" => array());
+ $dn = $attrs['dn'];
+ for($i = 0 ; $i < $attrs['objectClass']['count']; $i++){
+ $new_attrs['objectClass'][] = $attrs['objectClass'][$i];
+ }
+ for($i = 0 ; $i < $attrs['accessTo']['count']; $i++){
+ if($attrs['accessTo'][$i] == $from){
+ if(!empty($to)){
+ $new_attrs['accessTo'][] = $to;
+ }
+ }else{
+ $new_attrs['accessTo'][] = $attrs['accessTo'][$i];
+ }
+ }
+ $ldap->cd($dn);
+ $ldap->modify($new_attrs);
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, "update_accessTo($from,$to)"));
+ }
+ new log("modify","update_accessTo($from,$to)",$dn,array_keys($new_attrs),$ldap->get_error());
+ }
}
+
+function get_random_char () {
+ $randno = rand (0, 63);
+ if ($randno < 12) {
+ return (chr ($randno + 46)); // Digits, '/' and '.'
+ } else if ($randno < 38) {
+ return (chr ($randno + 53)); // Uppercase
+ } else {
+ return (chr ($randno + 59)); // Lowercase
+ }
+ }
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>