index 2141c2ec34891abe5fb420e33ec4369e9f03d486..8c1b16b0eeb529d01a4c6888c22484421080458e 100644 (file)
var $plHeadline= "Generic";
var $plDescription= "This does something";
var $plHeadline= "Generic";
var $plDescription= "This does something";
- /* CLI vars */
- var $cli_summary= "Handling of GOsa's user base object";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* Plugin specific values */
var $base= "";
/* Plugin specific values */
var $base= "";
+ var $orig_base= "";
var $cn= "";
var $cn= "";
+ var $new_dn= "";
var $personalTitle= "";
var $academicTitle= "";
var $homePostalAddress= "";
var $personalTitle= "";
var $academicTitle= "";
var $homePostalAddress= "";
/* attribute list for save action */
var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
/* attribute list for save action */
var $attributes= array("sn", "givenName", "uid", "personalTitle", "academicTitle",
- "homePostalAddress", "homePhone", "labeledURI", "o", "ou", "dateOfBirth", "gender","preferredLanguage",
- "departmentNumber", "employeeNumber", "employeeType", "l", "st",
+ "homePostalAddress", "homePhone", "labeledURI", "ou", "o", "dateOfBirth", "gender","preferredLanguage",
+ "departmentNumber", "employeeNumber", "employeeType", "l", "st","jpegPhoto",
"roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
"postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
"roomNumber", "telephoneNumber", "mobile", "pager", "cn", "userPKCS12",
"postalAddress", "facsimileTelephoneNumber", "userSMIMECertificate");
if (isset ($this->attrs['gender'])){
$this->gender= strtoupper($this->attrs['gender'][0]);
}
if (isset ($this->attrs['gender'])){
$this->gender= strtoupper($this->attrs['gender'][0]);
}
+
+ $this->orig_base = $this->base;
}
}
} else {
if(is_array($this->dateOfBirth)){
$date = $this->dateOfBirth;
} else {
if(is_array($this->dateOfBirth)){
$date = $this->dateOfBirth;
- }else{
+
+ // Trigger on dates like 1985-04-01, getdate only understands timestamps
+ } else if (!empty($this->dateOfBirth) && !is_numeric($this->dateOfBirth)){
+ $date= getdate(strtotime($this->dateOfBirth));
+
+ } else {
$date = getdate($this->dateOfBirth);
}
}
$date = getdate($this->dateOfBirth);
}
}
$smarty->assign("gender_list", $sex);
/* Assign prefered langage */
$smarty->assign("gender_list", $sex);
/* Assign prefered langage */
- $language= array(0 => " ", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), "nl_NL" => ("nl_NL"));
+ $language= array(0 => " ", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"),
+ "de_DE" => ("de_DE"), "it_IT" => ("it_IT"),
+ "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"),
+ "zh_CN" => ("zh_CN"));
$smarty->assign("preferredLanguage_list", $language);
/* Get random number for pictures */
$smarty->assign("preferredLanguage_list", $language);
/* Get random number for pictures */
/* Remove picture? */
if (isset($_POST['picture_remove'])){
/* Remove picture? */
if (isset($_POST['picture_remove'])){
+ $this->set_picture ();
$this->jpegPhoto= "*removed*";
$this->jpegPhoto= "*removed*";
- $this->set_picture ("./images/default.jpg");
$this->is_modified= TRUE;
return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
$this->is_modified= TRUE;
return($smarty->fetch (get_template_path('generic_picture.tpl', TRUE, dirname(__FILE__))));
/* Read out data*/
$timeto = $certificate->getvalidto_date();
$timefrom = $certificate->getvalidfrom_date();
/* Read out data*/
$timeto = $certificate->getvalidto_date();
$timefrom = $certificate->getvalidfrom_date();
- $str = "<table summary=\"\" border=0><tr><td style='vertical-align:top'>CN</td><td>".preg_replace("/ /", " ", $certificate->getname())."</td></tr></table><br>".
- sprintf(_("Certificate is valid from %s to %s and is currently %s."), "<b>".date('d M Y',$timefrom)."</b>","<b>".date('d M Y',$timeto)."</b>", $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":"<b><font style='color:red'>"._("invalid")."</font></b>");
+
+ /* Additional info if start end time is '0' */
+ $add_str_info = "";
+ if($timeto == 0 && $timefrom == 0){
+ $add_str_info = "<br><i>"._("(Some types of certificates are currently not supported and may be displayed as 'invalid'.)")."</i>";
+ }
+
+ $str = "<table summary=\"\" border=0>
+ <tr>
+ <td style='vertical-align:top'>CN</td>
+ <td>".preg_replace("/ /", " ", $certificate->getname())."</td>
+ </tr>
+ </table><br>".
+
+ sprintf(_("Certificate is valid from %s to %s and is currently %s."),
+ "<b>".date('d M Y',$timefrom)."</b>",
+ "<b>".date('d M Y',$timeto)."</b>",
+ $certificate->isvalid()?"<b><font style='color:green'>"._("valid")."</font></b>":
+ "<b><font style='color:red'>"._("invalid")."</font></b>").$add_str_info;
$smarty->assign($cert."info",$str);
$smarty->assign($cert."_state","true");
} else {
$smarty->assign($cert."info",$str);
$smarty->assign($cert."_state","true");
} else {
$this->pw_storage= $this->config->current['HASH'];
}
$this->pw_storage= $this->config->current['HASH'];
}
- $temp = passwordMethod::get_available_methods();
+ $temp = @passwordMethod::get_available_methods();
$hashes = $temp['name'];
$smarty->assign("pwmode", $hashes);
$hashes = $temp['name'];
$smarty->assign("pwmode", $hashes);
$og->save ();
}
$og->save ();
}
+ /* Kerberos server defined? */
+ if (isset($this->config->data['SERVERS']['KERBEROS'])){
+ $cfg= $this->config->data['SERVERS']['KERBEROS'];
+ }
+ if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
+
+ /* Connect to the admin interface */
+ $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
+ $cfg['ADMIN'], $cfg['PASSWORD']);
+
+ /* Errors? */
+ if ($handle === FALSE){
+ print_red (_("Kerberos database communication failed"));
+ return (2);
+ }
+
+ /* Build user principal, get list of existsing principals */
+ $principal= $this->uid."@".$cfg['REALM'];
+ $principals = kadm5_get_principals($handle);
+
+ /* User exists in database? */
+ if (in_array($principal, $principals)){
+
+ /* Ok. User exists. Remove him/her */
+ $ret= kadm5_delete_principal ( $handle, $principal);
+ if ($ret === FALSE){
+ print_red (_("Can't remove user from kerberos database."));
+ }
+ }
+
+ /* Free kerberos admin handle */
+ kadm5_destroy($handle);
+ }
+
+
/* Optionally execute a command after we're done */
/* Optionally execute a command after we're done */
- $this->handle_post_events("remove");
+ $this->handle_post_events("remove",array("uid" => $this->uid));
}
}
/* Save base and pw_storage, since these are no LDAP attributes */
if (isset($_POST['base'])){
foreach(array("base", "pw_storage") as $val){
/* Save base and pw_storage, since these are no LDAP attributes */
if (isset($_POST['base'])){
foreach(array("base", "pw_storage") as $val){
- if(isset($_POST[$val])){
+
+ if(isset($_POST[$val]) && chkacl ($this->acl, "$val") == ""){
$data= validate($_POST[$val]);
if ($data != $this->$val){
$this->is_modified= TRUE;
$data= validate($_POST[$val]);
if ($data != $this->$val){
$this->is_modified= TRUE;
/* Only force save of changes ....
If this attributes aren't changed, avoid saving.
*/
/* Only force save of changes ....
If this attributes aren't changed, avoid saving.
*/
- if ($this->use_dob == "1"){
- $this->dateOfBirth= date("Y-m-d", $this->dateOfBirth);
- }
if($this->gender=="0") $this->gender ="";
if($this->preferredLanguage=="0") $this->preferredLanguage ="";
if($this->gender=="0") $this->gender ="";
if($this->preferredLanguage=="0") $this->preferredLanguage ="";
/* First use parents methods to do some basic fillup in $this->attrs */
plugin::save ();
/* First use parents methods to do some basic fillup in $this->attrs */
plugin::save ();
+ if ($this->use_dob == "1"){
+ /* If it is an array, the generic page has never been loaded - so there's no difference. Using an array would cause an error btw. */
+ if(!is_array($this->attrs['dateOfBirth'])) {
+ $this->attrs['dateOfBirth']= date("Y-m-d", $this->attrs['dateOfBirth']);
+ }
+ }
/* Remove additional objectClasses */
$tmp= array();
foreach ($this->attrs['objectClass'] as $key => $set){
/* Remove additional objectClasses */
$tmp= array();
foreach ($this->attrs['objectClass'] as $key => $set){
$this->attrs["jpegPhoto"] = $output;
}
$this->attrs["jpegPhoto"] = $output;
}
- } elseif(!$this->new) {
+ } else{
$this->attrs["jpegPhoto"] = array();
}
$this->attrs["jpegPhoto"] = array();
}
- /* Build new dn */
- if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
- $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
- } else {
- $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
- }
-
/* This only gets called when user is renaming himself */
$ldap= $this->config->get_ldap_link();
/* This only gets called when user is renaming himself */
$ldap= $this->config->get_ldap_link();
- if ($this->dn != $new_dn){
+ if ($this->dn != $this->new_dn){
/* Write entry on new 'dn' */
/* Write entry on new 'dn' */
- $this->move($this->dn, $new_dn);
+ $this->move($this->dn, $this->new_dn);
/* Happen to use the new one */
/* Happen to use the new one */
- change_ui_dn($this->dn, $new_dn);
- $this->dn= $new_dn;
+ change_ui_dn($this->dn, $this->new_dn);
+ $this->dn= $this->new_dn;
}
}
/* Ok. User exists. Remove him/her when pw_storage has
changed to be NOT kerberos. */
/* Ok. User exists. Remove him/her when pw_storage has
changed to be NOT kerberos. */
- if ($this->pw_storage != "kerberos"){
+ if ($this->pw_storage != $this->config->current['KRBSASL']){
$ret= kadm5_delete_principal ( $handle, $principal);
if ($ret === FALSE){
$ret= kadm5_delete_principal ( $handle, $principal);
if ($ret === FALSE){
} else {
} else {
- /* User doesn't exists, create it when pw_storage is kerberos. */
- if ($this->pw_storage == "kerberos"){
+ /* User doesn't exists, create it when pw_storage is kerberos or SASL. */
+ if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
$ret= kadm5_create_principal ( $handle, $principal);
if ($ret === FALSE){
$ret= kadm5_create_principal ( $handle, $principal);
if ($ret === FALSE){
/* Optionally execute a command after we're done */
if ($mode == "add"){
/* Optionally execute a command after we're done */
if ($mode == "add"){
- $this->handle_post_events("add");
+ $this->handle_post_events("add",array("uid" => $this->uid));
} elseif ($this->is_modified){
} elseif ($this->is_modified){
- $this->handle_post_events("modify");
+ $this->handle_post_events("modify",array("uid" => $this->uid));
}
/* Fix tagging if needed */
}
/* Fix tagging if needed */
$message= plugin::check();
/* Assemble cn */
$message= plugin::check();
/* Assemble cn */
- $this->cn= $this->givenName." ".$this->sn;
+ $pt= "";
+ if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
+ if(!empty($this->personalTitle)){
+ $pt = $this->personalTitle." ";
+ }
+ }
+
+ $this->cn= $pt.$this->givenName." ".$this->sn;
/* Permissions for that base? */
if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
/* Permissions for that base? */
if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
- $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
+ $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
} else {
} else {
- $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
+ /* Don't touch dn, if cn hasn't changed */
+ if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn &&
+ $this->orig_base == $this->base){
+ $this->new_dn= $this->dn;
+ } else {
+ $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
+ }
}
$ui= get_userinfo();
}
$ui= get_userinfo();
- $acl= get_permissions ($new_dn, $ui->subtreeACL);
- $acl= get_module_permission($acl, "user", $new_dn);
+ $acl= get_permissions ($this->new_dn, $ui->subtreeACL);
+ $acl= get_module_permission($acl, "user", $this->new_dn);
if ($this->dn == "new" && chkacl($acl, "create") != ""){
$message[]= _("You have no permissions to create a user on this 'Base'.");
if ($this->dn == "new" && chkacl($acl, "create") != ""){
$message[]= _("You have no permissions to create a user on this 'Base'.");
- } elseif ($this->dn != $new_dn && $this->dn != "new"){
+ } elseif ($this->dn != $this->new_dn && $this->dn != "new"){
$acl= get_permissions ($this->dn, $ui->subtreeACL);
$acl= get_module_permission($acl, "user", $this->dn);
if (chkacl($acl, "create") != ""){
$acl= get_permissions ($this->dn, $ui->subtreeACL);
$acl= get_module_permission($acl, "user", $this->dn);
if (chkacl($acl, "create") != ""){
$message[]= _("The required field 'Login' is not set.");
}
if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
$message[]= _("The required field 'Login' is not set.");
}
if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(cn=".$this->cn.")", array("uid"));
- $ldap->fetch();
- if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
+ $ldap->cat($this->new_dn);
+ if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
$message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
}
}
$message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
}
}
/* Load picture from file to object */
/* Load picture from file to object */
- function set_picture($filename)
+ function set_picture($filename ="")
{
{
- if (!is_file($filename)){
+ if (!is_file($filename) || $filename == ""){
$filename= "./images/default.jpg";
$this->jpegPhoto= "*removed*";
}
$filename= "./images/default.jpg";
$this->jpegPhoto= "*removed*";
}
foreach($attrs['gosaSubtreeACL'] as $attr){
if((preg_match("/:user#/",$attr))||(preg_match("/:all/",$attr))){
foreach($attrs['gosaSubtreeACL'] as $attr){
if((preg_match("/:user#/",$attr))||(preg_match("/:all/",$attr))){
- $s = preg_replace("/^.*ou=groups,/","",$attrs['dn']);
+ $s = preg_replace("/^.*".get_groups_ou().",/","",$attrs['dn']);
foreach($this->config->idepartments as $key => $dep) {
if(preg_match("/".$s."/i",$key)){
foreach($this->config->idepartments as $key => $dep) {
if(preg_match("/".$s."/i",$key)){
}
}
}
}
}
}
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ /* Reset certificate information addepted from source user
+ to avoid setting the same user certificate for the destination user. */
+ $this->userPKCS12= "";
+ $this->userSMIMECertificate= "";
+ $this->userCertificate= "";
+ $this->certificateSerialNumber= "";
+ $this->old_certificateSerialNumber= "";
+ $this->old_userPKCS12= "";
+ $this->old_userSMIMECertificate= "";
+ $this->old_userCertificate= "";
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: