mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
- improvments on schema parsing
- return server message on modification errors
This commit is contained in:
parent
bde0761a04
commit
f32368254d
@ -13,6 +13,8 @@ LDAPAttrType::LDAPAttrType(){
|
||||
|
||||
oid = string ();
|
||||
desc = string ();
|
||||
equality = string ();
|
||||
syntax = string ();
|
||||
names = StringList ();
|
||||
single = false;
|
||||
}
|
||||
@ -23,6 +25,8 @@ LDAPAttrType::LDAPAttrType (const LDAPAttrType &at){
|
||||
|
||||
oid = at.oid;
|
||||
desc = at.desc;
|
||||
equality = at.equality;
|
||||
syntax = at.syntax;
|
||||
names = at.names;
|
||||
single = at.single;
|
||||
}
|
||||
@ -40,6 +44,8 @@ LDAPAttrType::LDAPAttrType (string at_item) {
|
||||
if (a) {
|
||||
this->setNames (a->at_names);
|
||||
this->setDesc (a->at_desc);
|
||||
this->setEquality (a->at_equality_oid);
|
||||
this->setSyntax (a->at_syntax_oid);
|
||||
this->setOid (a->at_oid);
|
||||
this->setSingle (a->at_single_value);
|
||||
}
|
||||
@ -64,6 +70,20 @@ void LDAPAttrType::setDesc (char *at_desc) {
|
||||
desc = at_desc;
|
||||
}
|
||||
|
||||
void LDAPAttrType::setEquality (char *at_equality_oid) {
|
||||
equality = string ();
|
||||
if (at_equality_oid) {
|
||||
equality = at_equality_oid;
|
||||
}
|
||||
}
|
||||
|
||||
void LDAPAttrType::setSyntax (char *at_syntax_oid) {
|
||||
syntax = string ();
|
||||
if (at_syntax_oid) {
|
||||
syntax = at_syntax_oid;
|
||||
}
|
||||
}
|
||||
|
||||
void LDAPAttrType::setOid (char *at_oid) {
|
||||
oid = string ();
|
||||
if (at_oid)
|
||||
@ -82,6 +102,14 @@ string LDAPAttrType::getDesc () {
|
||||
return desc;
|
||||
}
|
||||
|
||||
string LDAPAttrType::getEquality () {
|
||||
return equality;
|
||||
}
|
||||
|
||||
string LDAPAttrType::getSyntax () {
|
||||
return syntax;
|
||||
}
|
||||
|
||||
StringList LDAPAttrType::getNames () {
|
||||
return names;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ using namespace std;
|
||||
class LDAPAttrType{
|
||||
private :
|
||||
StringList names;
|
||||
string desc, oid;
|
||||
string desc, oid, equality, syntax;
|
||||
bool single;
|
||||
|
||||
public :
|
||||
@ -63,6 +63,16 @@ class LDAPAttrType{
|
||||
*/
|
||||
string getOid ();
|
||||
|
||||
/**
|
||||
* Returns equality matching rule
|
||||
*/
|
||||
string getEquality ();
|
||||
|
||||
/**
|
||||
* Returns attribute syntax definition
|
||||
*/
|
||||
string getSyntax ();
|
||||
|
||||
/**
|
||||
* Returns attribute name (first one if there are more of them)
|
||||
*/
|
||||
@ -74,12 +84,14 @@ class LDAPAttrType{
|
||||
StringList getNames();
|
||||
|
||||
/**
|
||||
* Returns true if attribute type hllows only single value
|
||||
* Returns true if attribute type allows only single value
|
||||
*/
|
||||
bool isSingle();
|
||||
|
||||
void setNames (char **at_names);
|
||||
void setDesc (char *at_desc);
|
||||
void setEquality (char *at_equality_oid);
|
||||
void setSyntax (char *at_syntax_oid);
|
||||
void setOid (char *at_oid);
|
||||
void setSingle (int at_single_value);
|
||||
|
||||
|
@ -198,9 +198,10 @@ void LDAPConnection::modify(const string& dn, const LDAPModList* mods,
|
||||
}
|
||||
break;
|
||||
default :
|
||||
string srvMsg = res->getErrMsg();
|
||||
delete res;
|
||||
delete msg;
|
||||
throw LDAPException(resCode);
|
||||
throw LDAPException(resCode,srvMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,19 +15,19 @@
|
||||
using namespace std;
|
||||
|
||||
LDAPException::LDAPException(int res_code, const string& err_string){
|
||||
m_res_code=res_code;
|
||||
m_res_string=string(ldap_err2string(res_code));
|
||||
m_res_code=res_code;
|
||||
m_res_string=string(ldap_err2string(res_code));
|
||||
m_err_string=err_string;
|
||||
}
|
||||
|
||||
LDAPException::LDAPException(const LDAPAsynConnection *lc){
|
||||
m_err_string=string();
|
||||
m_res_string=string();
|
||||
LDAP *l = lc->getSessionHandle();
|
||||
ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
|
||||
m_res_string=string(ldap_err2string(m_res_code));
|
||||
m_err_string=string();
|
||||
m_res_string=string();
|
||||
LDAP *l = lc->getSessionHandle();
|
||||
ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
|
||||
m_res_string=string(ldap_err2string(m_res_code));
|
||||
char* err_string;
|
||||
ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
|
||||
ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
|
||||
m_err_string=string(err_string);
|
||||
}
|
||||
|
||||
@ -35,11 +35,11 @@ LDAPException::~LDAPException(){
|
||||
}
|
||||
|
||||
int LDAPException::getResultCode() const{
|
||||
return m_res_code;
|
||||
return m_res_code;
|
||||
}
|
||||
|
||||
const string& LDAPException::getResultMsg() const{
|
||||
return m_res_string;
|
||||
return m_res_string;
|
||||
}
|
||||
|
||||
const string& LDAPException::getServerMsg() const{
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "StringList.h"
|
||||
#include "LDAPSchema.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
LDAPSchema::LDAPSchema(){
|
||||
@ -28,7 +30,12 @@ void LDAPSchema::setObjectClasses (const StringList &ocs) {
|
||||
StringList names = oc.getNames();
|
||||
// there could be more names for one object...
|
||||
for (j = names.begin(); j != names.end(); j++) {
|
||||
object_classes [(*j)] = LDAPObjClass (oc);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,17 +50,31 @@ void LDAPSchema::setAttributeTypes (const StringList &ats) {
|
||||
StringList names = at.getNames();
|
||||
// there could be more names for one object...
|
||||
for (j = names.begin(); j != names.end(); j++) {
|
||||
attr_types [(*j)] = LDAPAttrType (at);
|
||||
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) {
|
||||
|
||||
return object_classes [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 [name];
|
||||
return attr_types [lc_name];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user