X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_password-methods-kerberos.inc;h=af48ee998497b8ddd001d903c2f00ad6fc6d367a;hb=387a8ff163da84a9885feaa4fb936031c93eebf5;hp=4e8ff4862e93c258b8b2a50f91d96ebc4e86fa1a;hpb=8b8c82c2aa3941a1d7cff3bf600ae847c479ce38;p=gosa.git diff --git a/include/class_password-methods-kerberos.inc b/include/class_password-methods-kerberos.inc index 4e8ff4862..af48ee998 100644 --- a/include/class_password-methods-kerberos.inc +++ b/include/class_password-methods-kerberos.inc @@ -23,7 +23,7 @@ class passwordMethodkerberos extends passwordMethod function passwordMethodkerberos($config) { - $this->config=$config; + $this->config= &$config; } function is_available() @@ -62,11 +62,54 @@ class passwordMethodkerberos extends passwordMethod kadm5_destroy($handle); - $newpass= "{kerberos}".$this->attrs['uid'][0]."@".$cfg['REALM']; + $mode= "kerberos"; + if (isset($this->config->current['KRBSASL']) && preg_match('/^true$/i', $this->config->current['KRBSASL'])){ + $mode= "sasl"; + } + $newpass= "{$mode}".$this->attrs['uid'][0]."@".$cfg['REALM']; return $newpass; } } + + + function remove_from_parent() + { + /* 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); + } + } + } /* Dummy class for OpenLDAP Kerberos/SASL change */