From b6f7d36a544a7a8c18c815ef4158cf684108d06d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 16 Aug 2009 03:01:12 +0200 Subject: =?UTF-8?q?Passw=C3=B6rter=20k=C3=B6nnen=20gesetzt=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserConfigBackendKrb5.cpp | 23 ++++++++++++++++++++++ .../UserConfigBackendKrb5/UserConfigBackendKrb5.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'src/modules/UserConfigBackendKrb5') diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp index 5a577ad..9a43691 100644 --- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp +++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp @@ -19,6 +19,7 @@ #include "UserConfigBackendKrb5.h" #include +#include #include @@ -125,6 +126,8 @@ void UserConfigBackendKrb5::checkUserInfo(const Common::UserInfo &userInfo) thro } void UserConfigBackendKrb5::addUser(const Common::UserInfo &userInfo) throw(Core::Exception) { + application->getThreadManager()->detach(); + std::string princStr = userInfo.getUsername() + "@" + realm; kadm5_principal_ent_rec princ; @@ -169,6 +172,8 @@ void UserConfigBackendKrb5::updateUser(const Common::UserInfo &oldUserInfo, cons } void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception) { + application->getThreadManager()->detach(); + std::string princStr = userInfo.getUsername() + "@" + realm; krb5_principal princ; @@ -184,6 +189,24 @@ void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(C // throw Core::Exception("kadm5_delete_principal", Core::Exception::INTERNAL_ERRNO, err); } +void UserConfigBackendKrb5::setPassword(const Common::UserInfo &userInfo, const std::string &password) throw(Core::Exception) { + application->getThreadManager()->detach(); + + std::string princStr = userInfo.getUsername() + "@" + realm; + krb5_principal princ; + + krb5_error_code err = krb5_parse_name(context, princStr.c_str(), &princ); + if(err) + throw Core::Exception("krb5_parse_name", Core::Exception::INTERNAL_ERRNO, err); + + err = kadm5_chpass_principal(handle, princ, const_cast(password.c_str())); + + krb5_free_principal(context, princ); + + if(err) + throw Core::Exception("kadm5_chpass_principal", Core::Exception::INTERNAL_ERRNO, err); +} + } } } diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h index afb7663..6571220 100644 --- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h +++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h @@ -58,6 +58,8 @@ class UserConfigBackendKrb5 : public Common::UserConfigBackend, private Core::Co virtual void updateUser(const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo) throw(Core::Exception); virtual void deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception); + virtual void setPassword(const Common::UserInfo &userInfo, const std::string &password) throw(Core::Exception); + public: UserConfigBackendKrb5(Common::Application *application0) : application(application0), handle(0) { krb5_error_code err = krb5_init_context(&context); -- cgit v1.2.3