Hi,
I use OpenLDAP + PostgreSQL as a sql backend. Just for tests if hyphens are supported I defined object class and attribute having hyphen in the names:
Schema: attributetype ( 1.3.6.1.4.1.3814.4.4 NAME ( 'person-type' ) SUP name) objectClass ( 1.3.6.1.4.1.3814.3.5 NAME 'person-oc' DESC 'Test Person' SUP ( inetOrgPerson ) MAY ( person-type) )
insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (4,'person-oc','persons','id',NULL,NULL,0); insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (10,4,'person-type','persons.name','persons',NULL,NULL,NULL,3,0);
When I search for object having this object class and attribute I get the following in debug from slapd:
<= ldap_dn2bv(cn=kori hutton,o=sql,c=ru)=0 Success <<< dnPrettyNormal: <cn=Kori Hutton,o=sql,c=RU>, <cn=kori hutton,o=sql,c=ru> backsql_id2entry(): retrieving all attributes ==>backsql_get_attr_vals(): oc="person-oc" attr="ref" keyval=12478 <==backsql_get_attr_vals() ==>backsql_get_attr_vals(): oc="person-oc" attr="objectClass" keyval=12478 <==backsql_get_attr_vals() ==>backsql_get_attr_vals(): oc="person-oc" attr="person-type" keyval=12478 backsql_get_attr_values(): error executing attribute query "SELECT persons.name AS person-type FROM persons WHERE persons.id=? ORDER BY persons.name" Return code: -1 Native error code: 7 SQL engine state: 42601 Message: ERROR: syntax error at or near "-"; Error while executing the query
Looks that hyphen is not allowed in attribute name. Is it any workaround for this to support "-" in attribute names?
Thank you, greg
I use OpenLDAP + PostgreSQL as a sql backend. Just for tests if hyphens are supported I defined object class and attribute having hyphen in the names:
Schema: attributetype ( 1.3.6.1.4.1.3814.4.4 NAME ( 'person-type' ) SUP name) objectClass ( 1.3.6.1.4.1.3814.3.5 NAME 'person-oc' DESC 'Test Person' SUP ( inetOrgPerson ) MAY ( person-type) )
insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (4,'person-oc','persons','id',NULL,NULL,0); insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (10,4,'person-type','persons.name','persons',NULL,NULL,NULL,3,0);
When I search for object having this object class and attribute I get the following in debug from slapd:
<= ldap_dn2bv(cn=kori hutton,o=sql,c=ru)=0 Success <<< dnPrettyNormal: <cn=Kori Hutton,o=sql,c=RU>, <cn=kori hutton,o=sql,c=ru> backsql_id2entry(): retrieving all attributes ==>backsql_get_attr_vals(): oc="person-oc" attr="ref" keyval=12478 <==backsql_get_attr_vals() ==>backsql_get_attr_vals(): oc="person-oc" attr="objectClass" keyval=12478 <==backsql_get_attr_vals() ==>backsql_get_attr_vals(): oc="person-oc" attr="person-type" keyval=12478 backsql_get_attr_values(): error executing attribute query "SELECT persons.name AS person-type FROM persons WHERE persons.id=? ORDER BY persons.name" Return code: -1 Native error code: 7 SQL engine state: 42601 Message: ERROR: syntax error at or near "-"; Error while executing the query
Looks that hyphen is not allowed in attribute name. Is it any workaround for this to support "-" in attribute names?
back-sql allows whatever is legal LDAP in attribute names. Looks like the hyphen is not allowed by the underlying RDBMS. The short answer is "don't use hyphens unless tolerated by the underlying RDBMS". Perhaps the construct "AS <attr-name>" could be changed into "AS '<attr-name>'", as soon as the RDBMS allows it. Yet another customization parameter in back-sql... sigh.
p.
I use OpenLDAP + PostgreSQL as a sql backend. Just for tests if hyphens are supported I defined object class and attribute having hyphen in the names:
[...]
, hutton,o=sql,c=ru> backsql_id2entry(): retrieving all attributes ==>backsql_get_attr_vals(): oc="person-oc" attr="ref" keyval=12478 ==>backsql_get_attr_vals(): oc="person-oc" attr="objectClass" keyval=12478 ==>backsql_get_attr_vals(): oc="person-oc" attr="person-type" keyval=12478 backsql_get_attr_values(): error executing attribute query "SELECT persons.name AS person-type FROM persons WHERE persons.id=? ORDER BY persons.name" Return code: -1 Native error code: 7 SQL engine state: 42601 Message: ERROR: syntax error at or near "-"; Error while executing the query
Looks that hyphen is not allowed in attribute name. Is it any workaround for this to support "-" in attribute names?
back-sql allows whatever is legal LDAP in attribute names. Looks like the hyphen is not allowed by the underlying RDBMS. The short answer is "don't use hyphens unless tolerated by the underlying RDBMS". Perhaps the construct "AS " could be changed into "AS ''", as soon as the RDBMS allows it. Yet another customization parameter in back-sql... sigh.
p.
Thanks for the prompt answer. I tried to perform queries in the database using AS 'attr-name' and AS "attr-name" - both don't work. But even if they work, is the sql statement generator configurable somehow (at least for attribute queries) so the statements could be customized?
Forgot to add that I am using windows compiled version (v2.2.29), so not very fresh...
Regards, Greg
Thanks for the prompt answer. I tried to perform queries in the database using AS 'attr-name' and AS "attr-name" - both don't work.
OK, then you need to figure out a normalization rule that replaces "-" with an acceptable character, possibly not allowed by LDAP, so that bidirectional translation is possible.
But even if they work, is the sql statement generator configurable somehow (at least for attribute queries) so the statements could be customized?
It's not *that* customizable, but it's open source, so at least you get a chance to customize it.
Forgot to add that I am using windows compiled version (v2.2.29), so not very fresh...
Any generally useful modification would occur in the 2.4 branch, not earlier, so it sounds like you're on your own. I presume no patch for 2.2 would apply to 2.4 and vice-versa.
p.
openldap-technical@openldap.org