summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libtdeldap.cpp68
-rw-r--r--src/libtdeldap.h1
2 files changed, 69 insertions, 0 deletions
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index 156c372..940a91d 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -2847,6 +2847,74 @@ int LDAPManager::setRealmCAMaster(TQString masterFQDN, TQString* errstr) {
}
}
+int LDAPManager::getLdapCertificateStoreAttribute(TQString attribute, TQString* value, TQString* errstr) {
+ int retcode;
+ int returncode;
+ LDAPTDEBuiltinsInfo builtininfo;
+
+ TQString dn = TQString("cn=certificate store,o=tde,cn=tde realm data,ou=master services,ou=core,ou=realm,%1").arg(m_basedc);
+
+ if (!value) {
+ if (errstr) *errstr = i18n("Invalid string handle passed by host application");
+ return -1;
+ }
+
+ if (bind(errstr) < 0) {
+ return -1;
+ }
+ else {
+ LDAPMessage* msg;
+ retcode = ldap_search_ext_s(m_ldap, dn.ascii(), LDAP_SCOPE_SUBTREE, NULL, ldap_user_and_operational_attributes, 0, NULL, NULL, NULL, 0, &msg);
+ 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"));
+ return -1;
+ }
+
+ returncode = -2;
+
+ // Iterate through the returned entries
+ LDAPMessage* entry;
+ for(entry = ldap_first_entry(m_ldap, msg); entry != NULL; entry = ldap_next_entry(m_ldap, entry)) {
+ char* attr;
+ struct berval **vals;
+ BerElement* ber;
+ int i;
+
+ LDAPTDEBuiltinsInfo builtininfo;
+
+ for( attr = ldap_first_attribute(m_ldap, entry, &ber); attr != NULL; attr = ldap_next_attribute(m_ldap, entry, ber)) {
+ if ((vals = ldap_get_values_len(m_ldap, entry, attr)) != NULL) {
+ builtininfo.informationValid = true;
+ TQString ldap_field = attr;
+ i=0;
+ if (ldap_field == attribute) {
+ *value = vals[i]->bv_val;
+ returncode = 0;
+ }
+ ldap_value_free_len(vals);
+ }
+ ldap_memfree(attr);
+ }
+ if (returncode != 0) {
+ // Resource not found
+ if (errstr) *errstr = i18n("Resource \"%s\" not found in LDAP certificate store").arg(attribute);
+ }
+
+ if (ber != NULL) {
+ ber_free(ber, 0);
+ }
+ }
+
+ // clean up
+ ldap_msgfree(msg);
+
+ return returncode;
+ }
+
+ return -1;
+}
+
int LDAPManager::setLdapCertificateStoreAttribute(TQString attribute, TQString value, TQString* errstr) {
int retcode;
int i;
diff --git a/src/libtdeldap.h b/src/libtdeldap.h
index c14a437..83428e3 100644
--- a/src/libtdeldap.h
+++ b/src/libtdeldap.h
@@ -526,6 +526,7 @@ class LDAPManager : public TQObject {
TQString getRealmCAMaster(TQString* errstr=0);
int setRealmCAMaster(TQString masterFQDN, TQString* errstr=0);
+ int getLdapCertificateStoreAttribute(TQString attribute, TQString* value, TQString* errstr=0);
int setLdapCertificateStoreAttribute(TQString attribute, TQString value, TQString* errstr=0);
LDAPTDEBuiltinsInfo getTDEBuiltinMappings(TQString *errstr=0);