summaryrefslogtreecommitdiffstats
path: root/src/modules/UserBackendMysql/UserBackendMysql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/UserBackendMysql/UserBackendMysql.cpp')
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index 3ef44d1..f2729ab 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -128,6 +128,18 @@ bool UserBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool /*
if(entry[4].empty())
queryDeleteUser = entry[3][0];
}
+ else if(entry[3].getKey().matches("AddGroup")) {
+ if(entry[4].empty())
+ queryAddGroup = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("UpdateGroup")) {
+ if(entry[4].empty())
+ queryUpdateGroup = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("DeleteGroup")) {
+ if(entry[4].empty())
+ queryDeleteGroup = entry[3][0];
+ }
else if(entry[3].getKey().matches("AddUserToGroup")) {
if(entry[4].empty())
queryAddUserToGroup = entry[3][0];
@@ -538,6 +550,65 @@ void UserBackendMysql::deleteUser(unsigned long uid) throw(Core::Exception) {
lastUpdate = boost::posix_time::microsec_clock::universal_time();
}
+void UserBackendMysql::addGroup(const Common::GroupInfo &groupInfo) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
+ boost::lock_guard<boost::mutex> lock(mutex);
+
+ ArgumentMap args;
+ args.insert(std::make_pair("GID", groupInfo.getGid()));
+ args.insert(std::make_pair("GROUP", groupInfo.getName()));
+
+ Result result = query(queryAddGroup, args);
+
+ if(result.getErrno()) {
+ if(result.getErrno() == ER_DUP_ENTRY)
+ throw Core::Exception(Core::Exception::DUPLICATE_ENTRY);
+ else
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+ }
+
+ lastUpdate = boost::posix_time::microsec_clock::universal_time();
+}
+
+void UserBackendMysql::updateGroup(unsigned long gid, const Common::GroupInfo &groupInfo) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
+ boost::lock_guard<boost::mutex> lock(mutex);
+
+ ArgumentMap args;
+ args.insert(std::make_pair("ORIG_GID", gid));
+ args.insert(std::make_pair("GID", groupInfo.getGid()));
+ args.insert(std::make_pair("GROUP", groupInfo.getName()));
+
+ Result result = query(queryUpdateGroup, args);
+
+ if(result.getErrno()) {
+ if(result.getErrno() == ER_DUP_ENTRY)
+ throw Core::Exception(Core::Exception::DUPLICATE_ENTRY);
+ else
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+ }
+
+ lastUpdate = boost::posix_time::microsec_clock::universal_time();
+}
+
+void UserBackendMysql::deleteGroup(unsigned long gid) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
+ boost::lock_guard<boost::mutex> lock(mutex);
+
+ ArgumentMap args;
+ args.insert(std::make_pair("GID", gid));
+
+ Result result = query(queryDeleteGroup, args);
+
+ if(result.getErrno())
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+
+ lastUpdate = boost::posix_time::microsec_clock::universal_time();
+}
+
void UserBackendMysql::addUserToGroup(unsigned long uid, unsigned long gid) throw(Core::Exception) {
application->getThreadManager()->detach();