2003-06-24 14:05:03 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright 2003, OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "StringList.h"
|
|
|
|
|
#include "LDAPSchema.h"
|
|
|
|
|
|
2004-08-13 07:37:21 -04:00
|
|
|
#include <ctype.h>
|
|
|
|
|
|
2003-06-24 14:05:03 -04:00
|
|
|
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++) {
|
2004-08-13 07:37:21 -04:00
|
|
|
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);
|
2003-06-24 14:05:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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++) {
|
2004-08-13 07:37:21 -04:00
|
|
|
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);
|
2003-06-24 14:05:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPObjClass LDAPSchema::getObjectClassByName (string name) {
|
2004-08-13 07:37:21 -04:00
|
|
|
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];
|
2003-06-24 14:05:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPAttrType LDAPSchema::getAttributeTypeByName (string name) {
|
2004-08-13 07:37:21 -04:00
|
|
|
string lc_name = name;
|
|
|
|
|
string::iterator k;
|
|
|
|
|
for ( k = lc_name.begin(); k != lc_name.end(); k++ ) {
|
|
|
|
|
(*k) = tolower(*k);
|
|
|
|
|
}
|
2003-06-24 14:05:03 -04:00
|
|
|
|
2004-08-13 07:37:21 -04:00
|
|
|
return attr_types [lc_name];
|
2003-06-24 14:05:03 -04:00
|
|
|
}
|