Update library to allow usage from command line applications

pull/1/head
Timothy Pearson 12 years ago
parent 347de0fcc7
commit a3118cb55b

@ -740,7 +740,7 @@ void add_multiple_attributes_operation(LDAPMod **mods, int *i, TQString attr, TQ
(*i)++; (*i)++;
} }
int LDAPManager::updateUserInfo(LDAPUserInfo user) { int LDAPManager::updateUserInfo(LDAPUserInfo user, TQString *errstr) {
int retcode; int retcode;
int i; int i;
LDAPUserInfo userinfo; LDAPUserInfo userinfo;
@ -842,7 +842,12 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user) {
} }
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { else {
@ -1322,7 +1327,7 @@ int LDAPManager::destroyKerberosTicket(TQString principal, TQString *errstr) {
return 0; return 0;
} }
int LDAPManager::updateGroupInfo(LDAPGroupInfo group) { int LDAPManager::updateGroupInfo(LDAPGroupInfo group, TQString *errstr) {
int retcode; int retcode;
int i; int i;
LDAPGroupInfo groupinfo; LDAPGroupInfo groupinfo;
@ -1387,7 +1392,12 @@ int LDAPManager::updateGroupInfo(LDAPGroupInfo group) {
} }
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { 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 retcode;
int i; int i;
LDAPUserInfo userinfo; LDAPUserInfo userinfo;
@ -1457,7 +1467,12 @@ int LDAPManager::addUserInfo(LDAPUserInfo user) {
} }
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { 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 retcode;
int i; int i;
LDAPGroupInfo groupinfo; LDAPGroupInfo groupinfo;
@ -1520,7 +1535,12 @@ int LDAPManager::addGroupInfo(LDAPGroupInfo group) {
} }
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { 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; int retcode;
LDAPUserInfo userinfo; LDAPUserInfo userinfo;
@ -1655,7 +1675,12 @@ int LDAPManager::deleteUserInfo(LDAPUserInfo user) {
// Delete the base DN entry // Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, user.distinguishedName.ascii(), NULL, NULL); retcode = ldap_delete_ext_s(m_ldap, user.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { else {
@ -1664,7 +1689,7 @@ int LDAPManager::deleteUserInfo(LDAPUserInfo user) {
} }
} }
int LDAPManager::deleteGroupInfo(LDAPGroupInfo group) { int LDAPManager::deleteGroupInfo(LDAPGroupInfo group, TQString *errstr) {
int retcode; int retcode;
LDAPGroupInfo groupinfo; LDAPGroupInfo groupinfo;
@ -1675,7 +1700,12 @@ int LDAPManager::deleteGroupInfo(LDAPGroupInfo group) {
// Delete the base DN entry // Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, group.distinguishedName.ascii(), NULL, NULL); retcode = ldap_delete_ext_s(m_ldap, group.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { else {
@ -1684,7 +1714,7 @@ int LDAPManager::deleteGroupInfo(LDAPGroupInfo group) {
} }
} }
int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine) { int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine, TQString *errstr) {
int retcode; int retcode;
LDAPMachineInfo machineinfo; LDAPMachineInfo machineinfo;
@ -1695,7 +1725,12 @@ int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine) {
// Delete the base DN entry // Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, machine.distinguishedName.ascii(), NULL, NULL); retcode = ldap_delete_ext_s(m_ldap, machine.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { else {
@ -1704,7 +1739,7 @@ int LDAPManager::deleteMachineInfo(LDAPMachineInfo machine) {
} }
} }
int LDAPManager::deleteServiceInfo(LDAPServiceInfo service) { int LDAPManager::deleteServiceInfo(LDAPServiceInfo service, TQString *errstr) {
int retcode; int retcode;
LDAPServiceInfo serviceinfo; LDAPServiceInfo serviceinfo;
@ -1715,7 +1750,12 @@ int LDAPManager::deleteServiceInfo(LDAPServiceInfo service) {
// Delete the base DN entry // Delete the base DN entry
retcode = ldap_delete_ext_s(m_ldap, service.distinguishedName.ascii(), NULL, NULL); retcode = ldap_delete_ext_s(m_ldap, service.distinguishedName.ascii(), NULL, NULL);
if (retcode != LDAP_SUCCESS) { 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; return -2;
} }
else { else {

@ -382,15 +382,15 @@ class LDAPManager : public TQObject {
LDAPServiceInfoList services(int* retcode=0); LDAPServiceInfoList services(int* retcode=0);
LDAPUserInfo getUserByDistinguishedName(TQString dn); LDAPUserInfo getUserByDistinguishedName(TQString dn);
LDAPGroupInfo getGroupByDistinguishedName(TQString dn, TQString *errstr=0); LDAPGroupInfo getGroupByDistinguishedName(TQString dn, TQString *errstr=0);
int updateUserInfo(LDAPUserInfo user); int updateUserInfo(LDAPUserInfo user, TQString *errstr=0);
int updateGroupInfo(LDAPGroupInfo group); int updateGroupInfo(LDAPGroupInfo group, TQString *errstr=0);
int addUserInfo(LDAPUserInfo user); int addUserInfo(LDAPUserInfo user, TQString *errstr=0);
int addGroupInfo(LDAPGroupInfo group); int addGroupInfo(LDAPGroupInfo group, TQString *errstr=0);
int addServiceInfo(LDAPServiceInfo service, TQString *errstr=0); int addServiceInfo(LDAPServiceInfo service, TQString *errstr=0);
int deleteUserInfo(LDAPUserInfo user); int deleteUserInfo(LDAPUserInfo user, TQString *errstr=0);
int deleteGroupInfo(LDAPGroupInfo group); int deleteGroupInfo(LDAPGroupInfo group, TQString *errstr=0);
int deleteMachineInfo(LDAPMachineInfo machine); int deleteMachineInfo(LDAPMachineInfo machine, TQString *errstr=0);
int deleteServiceInfo(LDAPServiceInfo service); int deleteServiceInfo(LDAPServiceInfo service, TQString *errstr=0);
LDAPCredentials currentLDAPCredentials(); LDAPCredentials currentLDAPCredentials();

Loading…
Cancel
Save