|
|
@ -623,8 +623,9 @@ LDAPUserInfo LDAPManager::parseLDAPUserRecord(LDAPMessage* entry) {
|
|
|
|
return userinfo;
|
|
|
|
return userinfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LDAPUserInfoList LDAPManager::users(int* mretcode) {
|
|
|
|
LDAPUserInfoList LDAPManager::users(int* mretcode, TQString *errstr) {
|
|
|
|
int retcode;
|
|
|
|
int retcode;
|
|
|
|
|
|
|
|
int errcode;
|
|
|
|
LDAPUserInfoList users;
|
|
|
|
LDAPUserInfoList users;
|
|
|
|
|
|
|
|
|
|
|
|
if (bind() < 0) {
|
|
|
|
if (bind() < 0) {
|
|
|
@ -635,24 +636,110 @@ LDAPUserInfoList LDAPManager::users(int* mretcode) {
|
|
|
|
LDAPMessage* msg;
|
|
|
|
LDAPMessage* msg;
|
|
|
|
TQString ldap_base_dn = m_basedc;
|
|
|
|
TQString ldap_base_dn = m_basedc;
|
|
|
|
TQString ldap_filter = "(objectClass=posixAccount)";
|
|
|
|
TQString ldap_filter = "(objectClass=posixAccount)";
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
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) {
|
|
|
|
if ((retcode != LDAP_SUCCESS) && (retcode != LDAP_SIZELIMIT_EXCEEDED)) {
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
return LDAPUserInfoList();
|
|
|
|
return LDAPUserInfoList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (retcode == LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
|
|
|
|
LDAPMessage* entry;
|
|
|
|
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
users.append(parseLDAPUserRecord(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
// clean up
|
|
|
|
LDAPMessage* entry;
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
users.append(parseLDAPUserRecord(entry));
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
|
|
|
|
return users;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (retcode == LDAP_SIZELIMIT_EXCEEDED) {
|
|
|
|
|
|
|
|
// Try paged access
|
|
|
|
|
|
|
|
bool morePages = false;
|
|
|
|
|
|
|
|
unsigned long pageSize = 100;
|
|
|
|
|
|
|
|
struct berval cookie = {0, NULL};
|
|
|
|
|
|
|
|
char pagingCriticality = 'T';
|
|
|
|
|
|
|
|
LDAPControl* pageControl = NULL;
|
|
|
|
|
|
|
|
LDAPControl* serverControls[2] = { NULL, NULL };
|
|
|
|
|
|
|
|
LDAPControl** returnedControls = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
do {
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
retcode = ldap_create_page_control(m_ldap, pageSize, &cookie, pagingCriticality, &pageControl);
|
|
|
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPUserInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
serverControls[0] = pageControl;
|
|
|
|
|
|
|
|
retcode = ldap_search_ext_s(m_ldap, ldap_base_dn.ascii(), LDAP_SCOPE_SUBTREE, ldap_filter.ascii(), ldap_user_and_operational_attributes, 0, serverControls, NULL, NULL, 0, &msg);
|
|
|
|
|
|
|
|
if ((retcode != LDAP_SUCCESS) && (retcode != LDAP_PARTIAL_RESULTS)) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPUserInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = ldap_parse_result(m_ldap, msg, &errcode, NULL, NULL, NULL, &returnedControls, false);
|
|
|
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPUserInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cookie.bv_val != NULL) {
|
|
|
|
|
|
|
|
ber_memfree(cookie.bv_val);
|
|
|
|
|
|
|
|
cookie.bv_val = NULL;
|
|
|
|
|
|
|
|
cookie.bv_len = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!returnedControls) {
|
|
|
|
|
|
|
|
retcode = ldap_parse_pageresponse_control(m_ldap, returnedControls[0], NULL, &cookie);
|
|
|
|
|
|
|
|
morePages = (cookie.bv_val && (strlen(cookie.bv_val) > 0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
morePages = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
if (returnedControls != NULL) {
|
|
|
|
return users;
|
|
|
|
ldap_controls_free(returnedControls);
|
|
|
|
|
|
|
|
returnedControls = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
serverControls[0] = NULL;
|
|
|
|
|
|
|
|
ldap_control_free(pageControl);
|
|
|
|
|
|
|
|
pageControl = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
|
|
|
|
LDAPMessage* entry;
|
|
|
|
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
users.append(parseLDAPUserRecord(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
|
|
|
|
} while (morePages);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
|
|
|
|
return users;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return LDAPUserInfoList();
|
|
|
|
return LDAPUserInfoList();
|
|
|
@ -2128,8 +2215,9 @@ LDAPServiceInfo LDAPManager::parseLDAPMachineServiceRecord(LDAPMessage* entry) {
|
|
|
|
return machineserviceinfo;
|
|
|
|
return machineserviceinfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LDAPGroupInfoList LDAPManager::groups(int* mretcode) {
|
|
|
|
LDAPGroupInfoList LDAPManager::groups(int* mretcode, TQString *errstr) {
|
|
|
|
int retcode;
|
|
|
|
int retcode;
|
|
|
|
|
|
|
|
int errcode;
|
|
|
|
LDAPGroupInfoList groups;
|
|
|
|
LDAPGroupInfoList groups;
|
|
|
|
|
|
|
|
|
|
|
|
if (bind() < 0) {
|
|
|
|
if (bind() < 0) {
|
|
|
@ -2141,30 +2229,116 @@ LDAPGroupInfoList LDAPManager::groups(int* mretcode) {
|
|
|
|
TQString ldap_base_dn = m_basedc;
|
|
|
|
TQString ldap_base_dn = m_basedc;
|
|
|
|
TQString ldap_filter = "(objectClass=posixGroup)";
|
|
|
|
TQString ldap_filter = "(objectClass=posixGroup)";
|
|
|
|
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);
|
|
|
|
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) {
|
|
|
|
if ((retcode != LDAP_SUCCESS) && (retcode != LDAP_SIZELIMIT_EXCEEDED)) {
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (retcode == LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
|
|
|
|
LDAPMessage* entry;
|
|
|
|
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
groups.append(parseLDAPGroupRecord(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
// clean up
|
|
|
|
LDAPMessage* entry;
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
groups.append(parseLDAPGroupRecord(entry));
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
|
|
|
|
return groups;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (retcode == LDAP_SIZELIMIT_EXCEEDED) {
|
|
|
|
|
|
|
|
// Try paged access
|
|
|
|
|
|
|
|
bool morePages = false;
|
|
|
|
|
|
|
|
unsigned long pageSize = 100;
|
|
|
|
|
|
|
|
struct berval cookie = {0, NULL};
|
|
|
|
|
|
|
|
char pagingCriticality = 'T';
|
|
|
|
|
|
|
|
LDAPControl* pageControl = NULL;
|
|
|
|
|
|
|
|
LDAPControl* serverControls[2] = { NULL, NULL };
|
|
|
|
|
|
|
|
LDAPControl** returnedControls = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
do {
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
retcode = ldap_create_page_control(m_ldap, pageSize, &cookie, pagingCriticality, &pageControl);
|
|
|
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
serverControls[0] = pageControl;
|
|
|
|
|
|
|
|
retcode = ldap_search_ext_s(m_ldap, ldap_base_dn.ascii(), LDAP_SCOPE_SUBTREE, ldap_filter.ascii(), ldap_user_and_operational_attributes, 0, serverControls, NULL, NULL, 0, &msg);
|
|
|
|
|
|
|
|
if ((retcode != LDAP_SUCCESS) && (retcode != LDAP_PARTIAL_RESULTS)) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = ldap_parse_result(m_ldap, msg, &errcode, NULL, NULL, NULL, &returnedControls, false);
|
|
|
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cookie.bv_val != NULL) {
|
|
|
|
|
|
|
|
ber_memfree(cookie.bv_val);
|
|
|
|
|
|
|
|
cookie.bv_val = NULL;
|
|
|
|
|
|
|
|
cookie.bv_len = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!returnedControls) {
|
|
|
|
|
|
|
|
retcode = ldap_parse_pageresponse_control(m_ldap, returnedControls[0], NULL, &cookie);
|
|
|
|
|
|
|
|
morePages = (cookie.bv_val && (strlen(cookie.bv_val) > 0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
morePages = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
if (returnedControls != NULL) {
|
|
|
|
return groups;
|
|
|
|
ldap_controls_free(returnedControls);
|
|
|
|
|
|
|
|
returnedControls = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
serverControls[0] = NULL;
|
|
|
|
|
|
|
|
ldap_control_free(pageControl);
|
|
|
|
|
|
|
|
pageControl = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
|
|
|
|
LDAPMessage* entry;
|
|
|
|
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
groups.append(parseLDAPGroupRecord(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
|
|
|
|
} while (morePages);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
|
|
|
|
return groups;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
return LDAPGroupInfoList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LDAPMachineInfoList LDAPManager::machines(int* mretcode) {
|
|
|
|
LDAPMachineInfoList LDAPManager::machines(int* mretcode, TQString *errstr) {
|
|
|
|
int retcode;
|
|
|
|
int retcode;
|
|
|
|
|
|
|
|
int errcode;
|
|
|
|
LDAPMachineInfoList machines;
|
|
|
|
LDAPMachineInfoList machines;
|
|
|
|
|
|
|
|
|
|
|
|
if (bind() < 0) {
|
|
|
|
if (bind() < 0) {
|
|
|
@ -2176,29 +2350,114 @@ LDAPMachineInfoList LDAPManager::machines(int* mretcode) {
|
|
|
|
TQString ldap_base_dn = m_basedc;
|
|
|
|
TQString ldap_base_dn = m_basedc;
|
|
|
|
TQString ldap_filter = "(&(objectClass=krb5Principal)(uid=host/*))";
|
|
|
|
TQString ldap_filter = "(&(objectClass=krb5Principal)(uid=host/*))";
|
|
|
|
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);
|
|
|
|
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) {
|
|
|
|
if ((retcode != LDAP_SUCCESS) && (retcode != LDAP_SIZELIMIT_EXCEEDED)) {
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (retcode == LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
|
|
|
|
LDAPMessage* entry;
|
|
|
|
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
machines.append(parseLDAPMachineRecord(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
// clean up
|
|
|
|
LDAPMessage* entry;
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
machines.append(parseLDAPMachineRecord(entry));
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
|
|
|
|
return machines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (retcode == LDAP_SIZELIMIT_EXCEEDED) {
|
|
|
|
|
|
|
|
// Try paged access
|
|
|
|
|
|
|
|
bool morePages = false;
|
|
|
|
|
|
|
|
unsigned long pageSize = 100;
|
|
|
|
|
|
|
|
struct berval cookie = {0, NULL};
|
|
|
|
|
|
|
|
char pagingCriticality = 'T';
|
|
|
|
|
|
|
|
LDAPControl* pageControl = NULL;
|
|
|
|
|
|
|
|
LDAPControl* serverControls[2] = { NULL, NULL };
|
|
|
|
|
|
|
|
LDAPControl** returnedControls = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
do {
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
retcode = ldap_create_page_control(m_ldap, pageSize, &cookie, pagingCriticality, &pageControl);
|
|
|
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
serverControls[0] = pageControl;
|
|
|
|
|
|
|
|
retcode = ldap_search_ext_s(m_ldap, ldap_base_dn.ascii(), LDAP_SCOPE_SUBTREE, ldap_filter.ascii(), ldap_user_and_operational_attributes, 0, serverControls, NULL, NULL, 0, &msg);
|
|
|
|
|
|
|
|
if ((retcode != LDAP_SUCCESS) && (retcode != LDAP_PARTIAL_RESULTS)) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = ldap_parse_result(m_ldap, msg, &errcode, NULL, NULL, NULL, &returnedControls, false);
|
|
|
|
|
|
|
|
if (retcode != LDAP_SUCCESS) {
|
|
|
|
|
|
|
|
if (errstr) {
|
|
|
|
|
|
|
|
*errstr = i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cookie.bv_val != NULL) {
|
|
|
|
|
|
|
|
ber_memfree(cookie.bv_val);
|
|
|
|
|
|
|
|
cookie.bv_val = NULL;
|
|
|
|
|
|
|
|
cookie.bv_len = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!returnedControls) {
|
|
|
|
|
|
|
|
retcode = ldap_parse_pageresponse_control(m_ldap, returnedControls[0], NULL, &cookie);
|
|
|
|
|
|
|
|
morePages = (cookie.bv_val && (strlen(cookie.bv_val) > 0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
morePages = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
if (returnedControls != NULL) {
|
|
|
|
return machines;
|
|
|
|
ldap_controls_free(returnedControls);
|
|
|
|
|
|
|
|
returnedControls = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
serverControls[0] = NULL;
|
|
|
|
|
|
|
|
ldap_control_free(pageControl);
|
|
|
|
|
|
|
|
pageControl = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate through the returned entries
|
|
|
|
|
|
|
|
LDAPMessage* entry;
|
|
|
|
|
|
|
|
for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
|
|
|
|
|
|
|
|
machines.append(parseLDAPMachineRecord(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
|
|
|
|
ldap_msgfree(msg);
|
|
|
|
|
|
|
|
} while (morePages);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mretcode) *mretcode = 0;
|
|
|
|
|
|
|
|
return machines;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
return LDAPMachineInfoList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LDAPServiceInfoList LDAPManager::services(int* mretcode) {
|
|
|
|
LDAPServiceInfoList LDAPManager::services(int* mretcode, TQString *errstr) {
|
|
|
|
LDAPServiceInfoList services;
|
|
|
|
LDAPServiceInfoList services;
|
|
|
|
|
|
|
|
|
|
|
|
if (bind() < 0) {
|
|
|
|
if (bind() < 0) {
|
|
|
@ -2207,7 +2466,7 @@ LDAPServiceInfoList LDAPManager::services(int* mretcode) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
int machineSearchRet;
|
|
|
|
int machineSearchRet;
|
|
|
|
LDAPMachineInfoList machineList = machines(&machineSearchRet);
|
|
|
|
LDAPMachineInfoList machineList = machines(&machineSearchRet, errstr);
|
|
|
|
if (machineSearchRet != 0) {
|
|
|
|
if (machineSearchRet != 0) {
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
if (mretcode) *mretcode = -1;
|
|
|
|
return LDAPServiceInfoList();
|
|
|
|
return LDAPServiceInfoList();
|
|
|
@ -3529,7 +3788,7 @@ KerberosTicketInfo::~KerberosTicketInfo() {
|
|
|
|
LDAPPamConfig::LDAPPamConfig() {
|
|
|
|
LDAPPamConfig::LDAPPamConfig() {
|
|
|
|
enable_cached_credentials = true;
|
|
|
|
enable_cached_credentials = true;
|
|
|
|
autocreate_user_directories_enable = true;
|
|
|
|
autocreate_user_directories_enable = true;
|
|
|
|
autocreate_user_directories_umask;
|
|
|
|
autocreate_user_directories_umask = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LDAPPamConfig::~LDAPPamConfig() {
|
|
|
|
LDAPPamConfig::~LDAPPamConfig() {
|
|
|
|