summaryrefslogtreecommitdiffstats
path: root/src/libtdeldap.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-13 17:42:34 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-13 17:42:34 -0600
commita3118cb55bc12866b608441b7719c529206cfc4c (patch)
tree0999de2bbead2bfde9e92e26979cccee800d568d /src/libtdeldap.cpp
parent347de0fcc77f48a4704bc6d93cf4f7828d930a98 (diff)
downloadlibtdeldap-a3118cb55bc12866b608441b7719c529206cfc4c.tar.gz
libtdeldap-a3118cb55bc12866b608441b7719c529206cfc4c.zip
Update library to allow usage from command line applications
Diffstat (limited to 'src/libtdeldap.cpp')
-rw-r--r--src/libtdeldap.cpp72
1 files changed, 56 insertions, 16 deletions
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index 2e4cd4a..9faaecd 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -740,7 +740,7 @@ void add_multiple_attributes_operation(LDAPMod **mods, int *i, TQString attr, TQ
(*i)++;
}
-int LDAPManager::updateUserInfo(LDAPUserInfo user) {
+int LDAPManager::updateUserInfo(LDAPUserInfo user, TQString *errstr) {
int retcode;
int i;
LDAPUserInfo userinfo;
@@ -842,7 +842,12 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user) {
}
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP modification failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP modification failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP modification failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1322,7 +1327,7 @@ int LDAPManager::destroyKerberosTicket(TQString principal, TQString *errstr) {
return 0;
}
-int LDAPManager::updateGroupInfo(LDAPGroupInfo group) {
+int LDAPManager::updateGroupInfo(LDAPGroupInfo group, TQString *errstr) {
int retcode;
int i;
LDAPGroupInfo groupinfo;
@@ -1387,7 +1392,12 @@ int LDAPManager::updateGroupInfo(LDAPGroupInfo group) {
}
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP modification failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP modification failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP modification failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1396,7 +1406,7 @@ int LDAPManager::updateGroupInfo(LDAPGroupInfo group) {
}
}
-int LDAPManager::addUserInfo(LDAPUserInfo user) {
+int LDAPManager::addUserInfo(LDAPUserInfo user, TQString *errstr) {
int retcode;
int i;
LDAPUserInfo userinfo;
@@ -1457,7 +1467,12 @@ int LDAPManager::addUserInfo(LDAPUserInfo user) {
}
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP addition failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP addition failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP addition failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1466,7 +1481,7 @@ int LDAPManager::addUserInfo(LDAPUserInfo user) {
}
}
-int LDAPManager::addGroupInfo(LDAPGroupInfo group) {
+int LDAPManager::addGroupInfo(LDAPGroupInfo group, TQString *errstr) {
int retcode;
int i;
LDAPGroupInfo groupinfo;
@@ -1520,7 +1535,12 @@ int LDAPManager::addGroupInfo(LDAPGroupInfo group) {
}
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP addition failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP addition failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP addition failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1644,7 +1664,7 @@ int LDAPManager::addServiceInfo(LDAPServiceInfo service, TQString *errstr) {
}
}
-int LDAPManager::deleteUserInfo(LDAPUserInfo user) {
+int LDAPManager::deleteUserInfo(LDAPUserInfo user, TQString *errstr) {
int retcode;
LDAPUserInfo userinfo;
@@ -1655,7 +1675,12 @@ int LDAPManager::deleteUserInfo(LDAPUserInfo user) {
// Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, user.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1664,7 +1689,7 @@ int LDAPManager::deleteUserInfo(LDAPUserInfo user) {
}
}
-int LDAPManager::deleteGroupInfo(LDAPGroupInfo group) {
+int LDAPManager::deleteGroupInfo(LDAPGroupInfo group, TQString *errstr) {
int retcode;
LDAPGroupInfo groupinfo;
@@ -1675,7 +1700,12 @@ int LDAPManager::deleteGroupInfo(LDAPGroupInfo group) {
// Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, group.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1684,7 +1714,7 @@ int LDAPManager::deleteGroupInfo(LDAPGroupInfo group) {
}
}
-int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine) {
+int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine, TQString *errstr) {
int retcode;
LDAPMachineInfo machineinfo;
@@ -1695,7 +1725,12 @@ int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine) {
// Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, machine.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {
@@ -1704,7 +1739,7 @@ int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine) {
}
}
-int LDAPManager::deleteServiceInfo(LDAPServiceInfo service) {
+int LDAPManager::deleteServiceInfo(LDAPServiceInfo service, TQString *errstr) {
int retcode;
LDAPServiceInfo serviceinfo;
@@ -1715,7 +1750,12 @@ int LDAPManager::deleteServiceInfo(LDAPServiceInfo service) {
// Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, service.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) {
- KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ if (errstr) {
+ *errstr = i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>LDAP deletion failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
+ }
return -2;
}
else {