From d6a5b810dfa861ebbb6d7b863169a1602d254a4e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 4 Jun 2012 18:46:30 -0500 Subject: Add return codes for basic functions --- src/libtdeldap.cpp | 34 +++++++++++++++++++++++++++------- src/libtdeldap.h | 6 +++--- 2 files changed, 30 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp index 3fc2006..f7afe0d 100644 --- a/src/libtdeldap.cpp +++ b/src/libtdeldap.cpp @@ -476,12 +476,13 @@ printf("[RAJA DEBUG 100.3] %s: %s\n\r", attr, vals[i]->bv_val); return userinfo; } -LDAPUserInfoList LDAPManager::users() { +LDAPUserInfoList LDAPManager::users(int* mretcode) { int retcode; LDAPUserInfoList users; printf("[RAJA DEBUG 100.0] In LDAPManager::users()\n\r"); fflush(stdout); if (bind() < 0) { + if (mretcode) *mretcode = -1; return LDAPUserInfoList(); } else { @@ -492,6 +493,7 @@ printf("[RAJA DEBUG 100.1] In LDAPManager::users() bind was OK\n\r"); fflush(std retcode = ldap_search_ext_s(m_ldap, ldap_base_dn.ascii(), LDAP_SCOPE_SUBTREE, ldap_filter.ascii(), ldap_user_and_operational_attributes, 0, NULL, NULL, NULL, 0, &msg); if (retcode != LDAP_SUCCESS) { KMessageBox::error(0, i18n("LDAP search failure

Reason: [%3] %4").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error")); + if (mretcode) *mretcode = -1; return LDAPUserInfoList(); } @@ -506,6 +508,7 @@ printf("[RAJA DEBUG 100.2] The number of entries returned was %d\n\n", ldap_coun // clean up ldap_msgfree(msg); + if (mretcode) *mretcode = 0; return users; } @@ -658,6 +661,7 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user) { add_single_attribute_operation(mods, &i, "uidNumber", TQString("%1").arg(user.uid)); add_single_attribute_operation(mods, &i, "loginShell", user.shell); add_single_attribute_operation(mods, &i, "homeDirectory", user.homedir); + add_single_attribute_operation(mods, &i, "userPassword", "{SASL}" + user.name + "@" + m_realm.upper()); add_single_attribute_operation(mods, &i, "gidNumber", TQString("%1").arg(user.primary_gid)); add_single_attribute_operation(mods, &i, "krb5KDCFlags", TQString("%1").arg(user.status)); // Default active user is 586 [KRB5_ACTIVE_DEFAULT] and locked out user is 7586 [KRB5_DISABLED_ACCOUNT] // add_single_attribute_operation(mods, &i, "", user.password_expires); @@ -754,7 +758,7 @@ int LDAPManager::updateGroupInfo(LDAPGroupInfo group) { else { // Assemble the LDAPMod structure // We will replace any existing attributes with the new values - int number_of_parameters = 2; // 2 primary attributes + int number_of_parameters = 3; // 3 primary attributes LDAPMod *mods[number_of_parameters+1]; for (i=0;iLDAP search failure

Reason: [%3] %4").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error")); + if (mretcode) *mretcode = -1; return LDAPGroupInfoList(); } @@ -1142,18 +1158,20 @@ printf("[RAJA DEBUG 110.2] The number of entries returned was %d\n\n", ldap_coun // clean up ldap_msgfree(msg); + if (mretcode) *mretcode = 0; return groups; } return LDAPGroupInfoList(); } -LDAPMachineInfoList LDAPManager::machines() { +LDAPMachineInfoList LDAPManager::machines(int* mretcode) { int retcode; LDAPMachineInfoList machines; printf("[RAJA DEBUG 120.0] In LDAPManager::machines()\n\r"); fflush(stdout); if (bind() < 0) { + if (mretcode) *mretcode = -1; return LDAPMachineInfoList(); } else { @@ -1164,6 +1182,7 @@ printf("[RAJA DEBUG 120.1] In LDAPManager::machines() bind was OK\n\r"); fflush( retcode = ldap_search_ext_s(m_ldap, ldap_base_dn.ascii(), LDAP_SCOPE_SUBTREE, ldap_filter.ascii(), ldap_user_and_operational_attributes, 0, NULL, NULL, NULL, 0, &msg); if (retcode != LDAP_SUCCESS) { KMessageBox::error(0, i18n("LDAP search failure

Reason: [%3] %4").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error")); + if (mretcode) *mretcode = -1; return LDAPMachineInfoList(); } @@ -1178,6 +1197,7 @@ printf("[RAJA DEBUG 120.2] The number of entries returned was %d\n\n", ldap_coun // clean up ldap_msgfree(msg); + if (mretcode) *mretcode = 0; return machines; } diff --git a/src/libtdeldap.h b/src/libtdeldap.h index eb9aceb..2579902 100644 --- a/src/libtdeldap.h +++ b/src/libtdeldap.h @@ -218,9 +218,9 @@ class LDAPManager : public TQObject { TQString basedn(); int bind(TQString* errstr=0); int unbind(bool force, TQString* errstr=0); - LDAPUserInfoList users(); - LDAPGroupInfoList groups(); - LDAPMachineInfoList machines(); + LDAPUserInfoList users(int* retcode=0); + LDAPGroupInfoList groups(int* retcode=0); + LDAPMachineInfoList machines(int* retcode=0); LDAPUserInfo getUserByDistinguishedName(TQString dn); LDAPGroupInfo getGroupByDistinguishedName(TQString dn, TQString *errstr=0); int updateUserInfo(LDAPUserInfo user); -- cgit v1.2.1