diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-02-28 20:15:47 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-02-28 20:15:47 -0600 |
commit | 660b499a222d556fb6404fdddfb6b492a42b42ac (patch) | |
tree | 8d25a55c44c2eafda1bde52ae7e5ef3a06b3fa07 | |
parent | 298b514806b7a3e19d60dc2dcb69fd89662aaabc (diff) | |
download | libtdeldap-660b499a222d556fb6404fdddfb6b492a42b42ac.tar.gz libtdeldap-660b499a222d556fb6404fdddfb6b492a42b42ac.zip |
Remove user from member groups before deletion
-rw-r--r-- | src/libtdeldap.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp index f9cc4f0..709f81a 100644 --- a/src/libtdeldap.cpp +++ b/src/libtdeldap.cpp @@ -1723,6 +1723,20 @@ int LDAPManager::deleteUserInfo(LDAPUserInfo user, TQString *errstr) { return -1; } else { + // Remove the user from all member groups + LDAPGroupInfoList groupInfoList = groups(&retcode); + LDAPGroupInfoList::Iterator it; + for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) { + LDAPGroupInfo group = *it; + if (group.userlist.contains(user.distinguishedName)) { + group.userlist.remove(user.distinguishedName); + retcode = updateGroupInfo(group, errstr); + if (retcode != 0) { + return retcode; + } + } + } + // Delete the base DN entry retcode = ldap_delete_ext_s(m_ldap, user.distinguishedName.ascii(), NULL, NULL); if (retcode != LDAP_SUCCESS) { |