diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:54:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:54:12 +0000 |
commit | b527294153be3b79563c82c66102adc0004736c0 (patch) | |
tree | 9b423a224848441885190b5ea7cf0feb23510c9d /contrib/ldapc++/src/LDAPSchema.cpp | |
parent | Initial commit. (diff) | |
download | openldap-upstream/2.6.7+dfsg.tar.xz openldap-upstream/2.6.7+dfsg.zip |
Adding upstream version 2.6.7+dfsg.upstream/2.6.7+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | contrib/ldapc++/src/LDAPSchema.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/ldapc++/src/LDAPSchema.cpp b/contrib/ldapc++/src/LDAPSchema.cpp new file mode 100644 index 0000000..38fe282 --- /dev/null +++ b/contrib/ldapc++/src/LDAPSchema.cpp @@ -0,0 +1,84 @@ +// $OpenLDAP$ +/* + * Copyright 2003-2022 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "LDAPSchema.h" + +#include <ctype.h> +#include <ldap.h> + +#include "debug.h" +#include "StringList.h" + + +using namespace std; + +LDAPSchema::LDAPSchema(){ + DEBUG(LDAP_DEBUG_CONSTRUCT, + "LDAPSchema::LDAPSchema( )" << endl); +} + +LDAPSchema::~LDAPSchema() { + DEBUG(LDAP_DEBUG_DESTROY,"LDAPSchema::~LDAPSchema()" << endl); +} + +void LDAPSchema::setObjectClasses (const StringList &ocs) { + DEBUG(LDAP_DEBUG_TRACE,"LDAPSchema::setObjectClasses()" << endl); + + // parse the stringlist and save it to global map... + StringList::const_iterator i,j; + for (i = ocs.begin(); i != ocs.end(); i++) { + LDAPObjClass oc ( (*i) ); + StringList names = oc.getNames(); + // there could be more names for one object... + for (j = names.begin(); j != names.end(); j++) { + string lc_name = *j; + string::iterator k; + for ( k = lc_name.begin(); k != lc_name.end(); k++ ) { + (*k) = tolower(*k); + } + object_classes [lc_name] = LDAPObjClass (oc); + } + } +} + +void LDAPSchema::setAttributeTypes (const StringList &ats) { + DEBUG(LDAP_DEBUG_TRACE,"LDAPSchema::setAttributeTypes()" << endl); + + // parse the stringlist and save it to global map... + StringList::const_iterator i,j; + for (i = ats.begin(); i != ats.end(); i++) { + LDAPAttrType at ( (*i) ); + StringList names = at.getNames(); + // there could be more names for one object... + for (j = names.begin(); j != names.end(); j++) { + string lc_name = *j; + string::iterator k; + for ( k = lc_name.begin(); k != lc_name.end(); k++ ) { + (*k) = tolower(*k); + } + attr_types [lc_name] = LDAPAttrType (at); + } + } +} + +LDAPObjClass LDAPSchema::getObjectClassByName (string name) { + string lc_name = name; + string::iterator k; + for ( k = lc_name.begin(); k != lc_name.end(); k++ ) { + (*k) = tolower(*k); + } + return object_classes [lc_name]; +} + +LDAPAttrType LDAPSchema::getAttributeTypeByName (string name) { + string lc_name = name; + string::iterator k; + for ( k = lc_name.begin(); k != lc_name.end(); k++ ) { + (*k) = tolower(*k); + } + + return attr_types [lc_name]; +} |